Skip to content

Commit 76bd8b2

Browse files
committed
Fix: when converting to patterns to directories, append path.sep to prevent overlapping dirs from being omitted. Fixes gh-135
1 parent f7fd157 commit 76bd8b2

File tree

8 files changed

+55
-6
lines changed

8 files changed

+55
-6
lines changed

lib/test-stream.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function patternsToDirectories(patterns) {
2525
return true;
2626
});
2727

28-
return parts.join(path.sep)
28+
return `${parts.join(path.sep)}${path.sep}`;
2929
})
3030
.filter((name) => name !== '')
3131
// Remove elements that would cause the same files to be visited more than
@@ -50,7 +50,7 @@ function patternsToDirectories(patterns) {
5050
// All other values are unique and should be allowed
5151
return true;
5252
});
53-
});
53+
}).map(dir => dir.slice(0, -1));
5454
}
5555

5656
class TestStream extends Subject {

test/collateral-nested-similar-names/README.md

Whitespace-only changes.

test/collateral-nested-similar-names/harness/.gitkeep

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version": "3.0.0"}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*---
2+
description: Should not test in sloppy mode
3+
flags: [onlyStrict]
4+
expected:
5+
pass: true
6+
---*/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*---
2+
description: Should not test in sloppy mode
3+
flags: [onlyStrict]
4+
expected:
5+
pass: true
6+
---*/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*---
2+
description: Should not test in sloppy mode
3+
flags: [onlyStrict]
4+
expected:
5+
pass: true
6+
---*/

test/file-matching.js

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ const path = require('path');
55
const tap = require('tap');
66

77
const sameMembers = (assert, actual, expected) => {
8-
const expectedSet = expected.map((expectedMember) => {
9-
return expectedMember.split('/').join(path.sep);
10-
});
11-
assert.equal(actual.length, expected.length);
8+
const expectedSet = expected.map((expectedMember) => path.normalize(expectedMember));
9+
assert.equal(actual.length, expected.length, `
10+
Expected:
11+
12+
${actual}
13+
14+
to have the same length as:
15+
16+
${expected}
17+
`);
1218

1319
for (let actualMember of actual) {
1420
assert.assert(expectedSet.includes(actualMember), actualMember);
@@ -102,6 +108,30 @@ tap.test('file matching: file names (siblings)', assert => {
102108
}).then(assert.done, assert.fail);
103109
});
104110

111+
tap.test('file matching: directories with name overlap', assert => {
112+
run([
113+
'test/collateral-nested-similar-names/test/get/index.js',
114+
'test/collateral-nested-similar-names/test/getOwnPropertyDescriptor/index.js',
115+
'test/collateral-nested-similar-names/test/getPrototypeOf/index.js',
116+
])
117+
.then((results) => {
118+
const files = results.map((result) => result.file);
119+
const relativePaths = results.map((result) => result.relative);
120+
const expectedFiles = [
121+
'test/collateral-nested-similar-names/test/get/index.js',
122+
'test/collateral-nested-similar-names/test/getOwnPropertyDescriptor/index.js',
123+
'test/collateral-nested-similar-names/test/getPrototypeOf/index.js',
124+
];
125+
sameMembers(assert, files, expectedFiles);
126+
const expectedRelPaths = [
127+
'get/index.js',
128+
'getOwnPropertyDescriptor/index.js',
129+
'getPrototypeOf/index.js',
130+
];
131+
sameMembers(assert, relativePaths, expectedRelPaths);
132+
}).then(assert.done, assert.fail);
133+
});
134+
105135
tap.test('file matching: file names (subdirectory first)', assert => {
106136
run([
107137
'test/collateral-nested/test/evens/deep/26.js',

0 commit comments

Comments
 (0)