Skip to content

Commit

Permalink
#57: test: support test.only
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelzhang committed Dec 19, 2022
1 parent 189ff4f commit 8d56752
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
46 changes: 40 additions & 6 deletions test/fixtures/cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,38 @@ const cases = [
// }
// ],
/////////////////////////////////////////////////////////////////////
[
'charactor ?',
[
'foo?bar'
],
{
'foo/bar': 0,
'fooxbar': 1,
'fooxxbar': 0
}
],
[
'#57, normal * and normal consecutive *',
[
'**foo',
'*bar',
'ba*z'
],
{
'foo': 1,
'a/foo': 1,
'afoo': 1,
'abfoo': 1,
'abcfoo': 1,
'bar': 1,
'abar': 1,
'baz': 1,
'ba/z': 0,
'baaaaaaz': 1
},
true
],
[
'#76 (invalid), comments with no heading whitespace',
[
Expand Down Expand Up @@ -992,12 +1024,13 @@ const real_cases = cases_to_test_only.length
: cases

exports.cases = iteratee => {
real_cases.forEach(c => {
const description = c[0]
const patterns = c[1]
const paths_object = c[2]
const skip_test_fixture = c[4]

real_cases.forEach(([
description,
patterns,
paths_object,
test_only,
skip_test_fixture
]) => {
// All paths to test
const paths = Object.keys(paths_object)

Expand All @@ -1018,6 +1051,7 @@ exports.cases = iteratee => {
description,
patterns,
paths_object,
test_only,
skip_test_fixture,
paths,
expected,
Expand Down
18 changes: 13 additions & 5 deletions test/ignore.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const {test} = require('tap')
const {
test,
only
} = require('tap')

const ignore = require('..')
const {
Expand All @@ -13,11 +16,16 @@ cases(({
description,
patterns,
paths_object,
test_only,
paths,
expect_result
}) => {
const tt = test_only
? only
: test

checkEnv('IGNORE_ONLY_FILTER')
&& test(`.filter(): ${description}`, t => {
&& tt(`.filter(): ${description}`, t => {
const ig = ignore()
const result = ig
.addPattern(patterns)
Expand All @@ -28,7 +36,7 @@ cases(({
})

checkEnv('IGNORE_ONLY_CREATE_FILTER')
&& test(`.createFilter(): ${description}`, t => {
&& tt(`.createFilter(): ${description}`, t => {
const result = paths.filter(
ignore()
.addPattern(patterns)
Expand All @@ -42,7 +50,7 @@ cases(({
})

checkEnv('IGNORE_ONLY_IGNORES')
&& test(`.ignores(path): ${description}`, t => {
&& tt(`.ignores(path): ${description}`, t => {
const ig = ignore().addPattern(patterns)

Object.keys(paths_object).forEach(path => {
Expand All @@ -56,7 +64,7 @@ cases(({
}

checkEnv('IGNORE_ONLY_WIN32')
&& test(`win32: .filter(): ${description}`, t => {
&& tt(`win32: .filter(): ${description}`, t => {
const win_paths = paths.map(make_win32)

const ig = ignore()
Expand Down

0 comments on commit 8d56752

Please sign in to comment.