Skip to content

Commit

Permalink
Only parse stdin when - is passed as an argument
Browse files Browse the repository at this point in the history
This fixes issues when detecting TTY-ness in CI on Windows.
  • Loading branch information
isaacs committed May 17, 2019
1 parent c902175 commit e486938
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 21 deletions.
6 changes: 3 additions & 3 deletions bin/jack.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ To parse TAP data from stdin, specify "-" as a filename.
Short options are parsed gnu-style, so for example '-bCRspec' would be
equivalent to '--bail --no-color --reporter=spec'
If the --check-coverage or --coverage-report options are provided, and
no test files are specified, then a coverage report or coverage check
will be run on the data from the last test run.
If the --check-coverage or --coverage-report options are provided
explicitly, and no test files are specified, then a coverage report or
coverage check will be run on the data from the last test run.
Coverage is never enabled for stdin.
Expand Down
8 changes: 2 additions & 6 deletions bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const yaml = require('tap-yaml')
const path = require('path')
const exists = require('fs-exists-cached').sync
const os = require('os')
const isTTY = process.stdin.isTTY || process.env._TAP_IS_TTY === '1'
const tsNode = require.resolve('ts-node/register')
const esm = require.resolve('esm')
const jsx = require.resolve('./jsx.js')
Expand Down Expand Up @@ -205,8 +204,8 @@ const main = async options => {
return runCoverageReportOnly(options)

try {
debug('try to get default files?', options._.length === 0, isTTY)
if (options._.length === 0 && isTTY)
debug('try to get default files?', options._.length === 0)
if (options._.length === 0)
options._.push.apply(options._, await defaultFiles(options))
debug('added default files', options._)
} /* istanbul ignore next */ catch (er) /* istanbul ignore next */ {
Expand All @@ -219,9 +218,6 @@ const main = async options => {
options.files = globFiles(options._)
debug('after globbing', options.files)

if (options.files.length === 0 && !isTTY)
options.files.push('-')

if (options['output-dir'] !== null)
mkdirp(options['output-dir'])

Expand Down
7 changes: 3 additions & 4 deletions test/run/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ if (process.env.TAP_SNAPSHOT !== '1')

t.test('no args', t => {
const c = run([], {
env: { _TAP_IS_TTY: '1' },
cwd: dir,
}, (er, o, e) => {
t.match(er, { code: 1 })
Expand All @@ -23,8 +22,8 @@ t.test('no args', t => {
})
})

t.test('no args, quiet', t => {
const c = run([], { env: { _TAP_IS_TTY: '0' } }, (er, o, e) => {
t.test('stdin parsing', t => {
const c = run(['-'], {}, (er, o, e) => {
t.match(er, null)
t.equal(e, '')
t.end()
Expand Down Expand Up @@ -123,7 +122,7 @@ t.test('ignored files', t => {
`require(${tap}).fail('no foo included')`)

const args = ['--test-ignore=foo\\.test\\.js$']
const env = { _TAP_IS_TTY: '1' }
const env = {}
const cwd = dir + '/ig'
run([args], { cwd, env }, (er, o, e) => {
t.equal(er, null)
Expand Down
3 changes: 0 additions & 3 deletions test/run/dump-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ t.test('shotgun a bunch of option parsing junk', t => {
], { env: {
TAP: '0',
TAP_BAIL: '0',
_TAP_IS_TTY: '1'
}}, (er, o, e) => {
t.equal(er, null)
t.matchSnapshot(o, 'output')
Expand Down Expand Up @@ -70,7 +69,6 @@ t.test('package.json parsing', t => {
t.test('turn color off and back on again', t => {
run(['--no-color', '-c', '--dump-config'], { env: {
TAP: '0',
_TAP_IS_TTY: '1',
TAP_COLORS: '1',
}}, (er, o, e) => {
t.equal(er, null)
Expand Down Expand Up @@ -109,7 +107,6 @@ t.test('empty rc file', t => {
run(['--dump-config', '-c'], { env: {
TAP_RCFILE: rc,
TAP: '0',
_TAP_IS_TTY: '1',
TAP_COLORS: '1'
}}, (er, o, e) => {
t.equal(er, null)
Expand Down
2 changes: 1 addition & 1 deletion test/run/reporters.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const check = t => (er, o, e) => {
t.end()
}

const opt = {env: {TAP_COLORS: 0, _TAP_IS_TTY: 1, PATH: process.env.PATH}}
const opt = {env: {TAP_COLORS: 0, PATH: process.env.PATH}}

t.test('builtin reporter', t =>
run([ok, '-Rbase'], opt, check(t)))
Expand Down
2 changes: 0 additions & 2 deletions test/run/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const tapcode = 'TAP version 13\n1..1\nok\n'

t.test('with output file', t => {
const c = run(['-', '-c', '-Rspec', '-ofoo.txt', '--cov'], { env: {
_TAP_IS_TTY: '1',
TAP: '0'
}}, (er, o, e) => {
t.equal(er, null)
Expand All @@ -25,7 +24,6 @@ t.test('with output file', t => {

t.test('no output file', t => {
const c = run(['-', '--only', '-gx', '-iC', '-Rclassic'], { env: {
_TAP_IS_TTY: '1',
TAP: '0'
}}, (er, o, e) => {
t.equal(er, null)
Expand Down
4 changes: 2 additions & 2 deletions test/run/test-regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ t.test('no args, pull in default files, not exclusions', t => {
const t = require(${tap})
t.fail('should not run this')
`)
run([], { cwd: dir, env: { _TAP_IS_TTY: '1' }}, (er, o, e) => {
run([], { cwd: dir }, (er, o, e) => {
t.equal(er, null)
t.matchSnapshot(o, 'output')
t.end()
})
})

t.test('error out if loading files fails', t => {
run([], { cwd: '/dev', env: { _TAP_IS_TTY: '1' }}, (er, o, e) => {
run([], { cwd: '/dev' }, (er, o, e) => {
t.match(er, { code: 1 })
t.end()
})
Expand Down

0 comments on commit e486938

Please sign in to comment.