Skip to content

Commit

Permalink
consolidate --only tests
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jun 25, 2017
1 parent f60b060 commit efd024d
Show file tree
Hide file tree
Showing 7 changed files with 330 additions and 99 deletions.
25 changes: 0 additions & 25 deletions test/fixtures/only.js

This file was deleted.

43 changes: 0 additions & 43 deletions test/runner-only.js

This file was deleted.

82 changes: 77 additions & 5 deletions test/test/only--bail--buffer.tap
@@ -1,11 +1,83 @@
TAP version 13
ok 1 - normal ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - will log an error when run without TAP_ONLY=1
ok 1 - ___/.*(node|iojs)(.exe)?.*/~~~only.js child ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - normal ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - this is fine
1..1
}

# "only" has `only` set but all tests run
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - only do this
1..1
}

1..2
___/# time=[0-9.]+(ms)?/~~~
}

ok 2 - ___/.*(node|iojs)(.exe)?.*/~~~only.js child ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - normal # SKIP
# Subtest: only
ok 1 - only do this
1..1
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~

1..2
# skip: 1
___/# time=[0-9.]+(ms)?/~~~
}

ok 3 - ___/.*(node|iojs)(.exe)?/~~~ ./bin/run.js ___/.*/~~~only.js --test-arg=child ___/# time=[0-9.]+(ms)?/~~~ {
# Subtest: ___/.*/~~~only.js
ok 1 - normal # SKIP
# Subtest: only
ok 1 - only do this
1..1
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~

1..2
# skip: 1
___/# time=[0-9.]+(ms)?/~~~
ok 1 - ___/.*/~~~only.js ___/# time=[0-9.]+(ms)?/~~~

1..1
___/# time=[0-9.]+(ms)?/~~~
}

ok 4 - ___/.*(node|iojs)(.exe)?/~~~ ./bin/run.js ___/.*/~~~only.js --test-arg=child --only ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - ___/.*/~~~only.js ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - normal # SKIP
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - only do this
1..1
}

1..2
# skip: 1
___/# time=[0-9.]+(ms)?/~~~
}

1..1
___/# time=[0-9.]+(ms)?/~~~
}

ok 5 - ___/.*(node|iojs)(.exe)?/~~~ ./bin/run.js ___/.*/~~~only.js --test-arg=child -O ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - ___/.*/~~~only.js ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - normal # SKIP
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - only do this
1..1
}

1..2
# skip: 1
___/# time=[0-9.]+(ms)?/~~~
}

1..1
___/# time=[0-9.]+(ms)?/~~~
}

ok 2 - only # SKIP
1..2
# skip: 1
1..5
___/# time=[0-9.]+(ms)?/~~~

84 changes: 78 additions & 6 deletions test/test/only--bail.tap
@@ -1,11 +1,83 @@
TAP version 13
# Subtest: normal
ok 1 - will log an error when run without TAP_ONLY=1
# Subtest: ___/.*(node|iojs)(.exe)?.*/~~~only.js child
# Subtest: normal
ok 1 - this is fine
1..1
ok 1 - normal ___/# time=[0-9.]+(ms)?/~~~

# "only" has `only` set but all tests run
# Subtest: only
ok 1 - only do this
1..1
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~

1..2
___/# time=[0-9.]+(ms)?/~~~
ok 1 - ___/.*(node|iojs)(.exe)?.*/~~~only.js child ___/# time=[0-9.]+(ms)?/~~~

# Subtest: ___/.*(node|iojs)(.exe)?.*/~~~only.js child
ok 1 - normal # SKIP
# Subtest: only
ok 1 - only do this
1..1
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~

1..2
# skip: 1
___/# time=[0-9.]+(ms)?/~~~
ok 2 - ___/.*(node|iojs)(.exe)?.*/~~~only.js child ___/# time=[0-9.]+(ms)?/~~~

# Subtest: ___/.*(node|iojs)(.exe)?/~~~ ./bin/run.js ___/.*/~~~only.js --test-arg=child
# Subtest: ___/.*/~~~only.js
ok 1 - normal # SKIP
# Subtest: only
ok 1 - only do this
1..1
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~

1..2
# skip: 1
___/# time=[0-9.]+(ms)?/~~~
ok 1 - ___/.*/~~~only.js ___/# time=[0-9.]+(ms)?/~~~

1..1
___/# time=[0-9.]+(ms)?/~~~
ok 3 - ___/.*(node|iojs)(.exe)?/~~~ ./bin/run.js ___/.*/~~~only.js --test-arg=child ___/# time=[0-9.]+(ms)?/~~~

# Subtest: ___/.*(node|iojs)(.exe)?/~~~ ./bin/run.js ___/.*/~~~only.js --test-arg=child --only
# Subtest: ___/.*/~~~only.js
ok 1 - normal # SKIP
# Subtest: only
ok 1 - only do this
1..1
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~

1..2
# skip: 1
___/# time=[0-9.]+(ms)?/~~~
ok 1 - ___/.*/~~~only.js ___/# time=[0-9.]+(ms)?/~~~

1..1
___/# time=[0-9.]+(ms)?/~~~
ok 4 - ___/.*(node|iojs)(.exe)?/~~~ ./bin/run.js ___/.*/~~~only.js --test-arg=child --only ___/# time=[0-9.]+(ms)?/~~~

# Subtest: ___/.*(node|iojs)(.exe)?/~~~ ./bin/run.js ___/.*/~~~only.js --test-arg=child -O
# Subtest: ___/.*/~~~only.js
ok 1 - normal # SKIP
# Subtest: only
ok 1 - only do this
1..1
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~

1..2
# skip: 1
___/# time=[0-9.]+(ms)?/~~~
ok 1 - ___/.*/~~~only.js ___/# time=[0-9.]+(ms)?/~~~

1..1
ok 1 - normal ___/# time=[0-9.]+(ms)?/~~~
___/# time=[0-9.]+(ms)?/~~~
ok 5 - ___/.*(node|iojs)(.exe)?/~~~ ./bin/run.js ___/.*/~~~only.js --test-arg=child -O ___/# time=[0-9.]+(ms)?/~~~

ok 2 - only # SKIP
1..2
# skip: 1
1..5
___/# time=[0-9.]+(ms)?/~~~

82 changes: 77 additions & 5 deletions test/test/only--buffer.tap
@@ -1,11 +1,83 @@
TAP version 13
ok 1 - normal ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - will log an error when run without TAP_ONLY=1
ok 1 - ___/.*(node|iojs)(.exe)?.*/~~~only.js child ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - normal ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - this is fine
1..1
}

# "only" has `only` set but all tests run
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - only do this
1..1
}

1..2
___/# time=[0-9.]+(ms)?/~~~
}

ok 2 - ___/.*(node|iojs)(.exe)?.*/~~~only.js child ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - normal # SKIP
# Subtest: only
ok 1 - only do this
1..1
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~

1..2
# skip: 1
___/# time=[0-9.]+(ms)?/~~~
}

ok 3 - ___/.*(node|iojs)(.exe)?/~~~ ./bin/run.js ___/.*/~~~only.js --test-arg=child ___/# time=[0-9.]+(ms)?/~~~ {
# Subtest: ___/.*/~~~only.js
ok 1 - normal # SKIP
# Subtest: only
ok 1 - only do this
1..1
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~

1..2
# skip: 1
___/# time=[0-9.]+(ms)?/~~~
ok 1 - ___/.*/~~~only.js ___/# time=[0-9.]+(ms)?/~~~

1..1
___/# time=[0-9.]+(ms)?/~~~
}

ok 4 - ___/.*(node|iojs)(.exe)?/~~~ ./bin/run.js ___/.*/~~~only.js --test-arg=child --only ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - ___/.*/~~~only.js ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - normal # SKIP
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - only do this
1..1
}

1..2
# skip: 1
___/# time=[0-9.]+(ms)?/~~~
}

1..1
___/# time=[0-9.]+(ms)?/~~~
}

ok 5 - ___/.*(node|iojs)(.exe)?/~~~ ./bin/run.js ___/.*/~~~only.js --test-arg=child -O ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - ___/.*/~~~only.js ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - normal # SKIP
ok 2 - only ___/# time=[0-9.]+(ms)?/~~~ {
ok 1 - only do this
1..1
}

1..2
# skip: 1
___/# time=[0-9.]+(ms)?/~~~
}

1..1
___/# time=[0-9.]+(ms)?/~~~
}

ok 2 - only # SKIP
1..2
# skip: 1
1..5
___/# time=[0-9.]+(ms)?/~~~

29 changes: 20 additions & 9 deletions test/test/only.js
@@ -1,11 +1,22 @@
var test = require('../..').test
var t = require('../..')
var run = require.resolve('../../bin/run.js')
var node = process.execPath

test('normal', function (t) {
t.pass('will log an error when run without TAP_ONLY=1')
t.end()
})
if (process.argv[2] === 'child') {
t.test('normal', function (t) {
t.pass('this is fine')
t.end()
})

test('only', {skip: true}, function (t) {
t.pass('ok')
t.end()
})
t.test('only', { only: true }, function (t) {
t.pass('only do this')
t.end()
})
} else {
var env = { env: { TAP_ONLY: '1' } }
t.spawn(node, [__filename, 'child'])
t.spawn(node, [__filename, 'child'], env)
t.spawn(node, [run, __filename, '--test-arg=child'], env)
t.spawn(node, [run, __filename, '--test-arg=child', '--only'])
t.spawn(node, [run, __filename, '--test-arg=child', '-O'])
}

0 comments on commit efd024d

Please sign in to comment.