8000 fix: disable spinner in CI by antongolub · Pull Request #1009 · google/zx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: disable spinner in CI #1009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/build-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ apis.forEach((name) => {
: ''
fileContents += `
describe('vendor ${name} API ', () => {
// prettier-ignore
test('exports', () => {
assert.equal(typeof ${name}, '${typeof api}')${methodChecks}
})
Expand Down
10000 2 changes: 2 additions & 0 deletions src/goods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ export async function spinner<T>(
callback = title
title = ''
}
if (process.env.CI) return callback!()

let i = 0
const spin = () =>
process.stderr.write(` ${'⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'[i++ % 10]} ${title}\r`)
Expand Down
53 changes: 36 additions & 17 deletions test/goods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,31 +132,50 @@ describe('goods', () => {
assert.ok(Date.now() >= now + 2 + 4 + 8 + 16 + 32)
})

test('spinner() works', async () => {
const out = await zx(`
describe('spinner()', () => {
test('works', async () => {
const out = await zx(
`
process.env.CI = ''
echo(await spinner(async () => {
await sleep(100)
await $\`echo hidden\`
return $\`echo result\`
}))
`)
assert(out.stdout.includes('result'))
assert(!out.stderr.includes('result'))
assert(!out.stderr.includes('hidden'))
})

test('spinner() with title works', async () => {
const out = await zx(`
`
)
assert(out.stdout.includes('result'))
assert(out.stderr.includes('⠋'))
assert(!out.stderr.includes('result'))
assert(!out.stderr.includes('hidden'))
})

test('with title', async () => {
const out = await zx(
`
process.env.CI = ''
await spinner('processing', () => sleep(100))
`)
assert.match(out.stderr, /processing/)
})
`
)
assert.match(out.stderr, /processing/)
})

test('disabled in CI', async () => {
const out = await zx(
`
process.env.CI = 'true'
await spinner('processing', () => sleep(100))
`
)
assert.doesNotMatch(out.stderr, /processing/)
})

test('spinner() stops on throw', async () => {
const out = await zx(`
test('stops on throw', async () => {
const out = await zx(`
await spinner('processing', () => $\`wtf-cmd\`)
`)
assert.match(out.stderr, /Error:/)
assert(out.exitCode !== 0)
assert.match(out.stderr, /Error:/)
assert(out.exitCode !== 0)
})
})
})
31 changes: 11 additions & 20 deletions test/vendor-export.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@ import {
} from '../build/vendor.js'

describe('vendor chalk API ', () => {
// prettier-ignore
test('exports', () => {
assert.equal(typeof chalk, 'function')
assert.equal(typeof chalk.level, 'number', 'chalk.level')
})
})

describe('vendor depseek API ', () => {
// prettier-ignore
test('exports', () => {
assert.equal(typeof depseek, 'function')
})
})

describe('vendor fs API ', () => {
// prettier-ignore
test('exports', () => {
assert.equal(typeof fs, 'object')
assert.equal(typeof fs.default, 'object', 'fs.default')
Expand All @@ -56,11 +59,7 @@ describe('vendor fs API ', () => {
assert.equal(typeof fs.cp, 'function', 'fs.cp')
assert.equal(typeof fs.cpSync, 'function', 'fs.cpSync')
assert.equal(typeof fs.createReadStream, 'function', 'fs.createReadStream')
assert.equal(
typeof fs.createWriteStream,
'function',
'fs.createWriteStream'
)
assert.equal(typeof fs.createWriteStream, 'function', 'fs.createWriteStream')
assert.equal(typeof fs.exists, 'function', 'fs.exists')
assert.equal(typeof fs.existsSync, 'function', 'fs.existsSync')
assert.equal(typeof fs.fchown, 'function', 'fs.fchown')
Expand Down Expand Up @@ -167,17 +166,9 @@ describe('vendor fs API ', () => {
assert.equal(typeof fs.ensureLink, 'function', 'fs.ensureLink')
assert.equal(typeof fs.ensureLinkSync, 'function', 'fs.ensureLinkSync')
assert.equal(typeof fs.createSymlink, 'function', 'fs.createSymlink')
assert.equal(
typeof fs.createSymlinkSync,
'function',
'fs.createSymlinkSync'
)
assert.equal(typeof fs.createSymlinkSync, 'function', 'fs.createSymlinkSync')
assert.equal(typeof fs.ensureSymlink, 'function', 'fs.ensureSymlink')
assert.equal(
typeof fs.ensureSymlinkSync,
'function',
'fs.ensureSymlinkSync'
)
assert.equal(typeof fs.ensureSymlinkSync, 'function', 'fs.ensureSymlinkSync')
assert.equal(typeof fs.readJson, 'function', 'fs.readJson')
assert.equal(typeof fs.readJsonSync, 'function', 'fs.readJsonSync')
assert.equal(typeof fs.writeJson, 'function', 'fs.writeJson')
Expand Down Expand Up @@ -208,12 +199,14 @@ describe('vendor fs API ', () => {
})

describe('vendor minimist API ', () => {
// prettier-ignore
test('exports', () => {
assert.equal(typeof minimist, 'function')
})
})

describe('vendor ps API ', () => {
// prettier-ignore
test('exports', () => {
assert.equal(typeof ps, 'object')
assert.equal(typeof ps.kill, 'function', 'ps.kill')
Expand All @@ -225,13 +218,15 @@ describe('vendor ps API ', () => {
})

describe('vendor which API ', () => {
// prettier-ignore
test('exports', () => {
assert.equal(typeof which, 'function')
assert.equal(typeof which.sync, 'function', 'which.sync')
})
})

describe('vendor YAML API ', () => {
// prettier-ignore
test('exports', () => {
assert.equal(typeof YAML, 'object')
assert.equal(typeof YAML.Alias, 'function', 'YAML.Alias')
Expand Down Expand Up @@ -259,11 +254,7 @@ describe('vendor YAML API ', () => {
assert.equal(typeof YAML.isScalar, 'function', 'YAML.isScalar')
assert.equal(typeof YAML.isSeq, 'function', 'YAML.isSeq')
assert.equal(typeof YAML.parse, 'function', 'YAML.parse')
assert.equal(
typeof YAML.parseAllDocuments,
'function',
'YAML.parseAllDocuments'
)
assert.equal(typeof YAML.parseAllDocuments, 'function', 'YAML.parseAllDocuments')
assert.equal(typeof YAML.parseDocument, 'function', 'YAML.parseDocument')
assert.equal(typeof YAML.stringify, 'function', 'YAML.stringify')
assert.equal(typeof YAML.visit, 'function', 'YAML.visit')
Expand Down
Loading
0