Skip to content

Commit 9d230ca

Browse files
committed
checkpoint: scripts detection of missing test companions
1 parent 5a9278f commit 9d230ca

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {
2+
toPath,
3+
} from '../@internal/File';
4+
5+
import {
6+
serialized,
7+
} from '../@internal/FilesystemPath';
8+
9+
import {
10+
TestableUnit,
11+
} from './TestableUnit';
12+
13+
const unitsWithoutCompanions = TestableUnit.getAllThatAreMissingTestCompanion();
14+
15+
if (unitsWithoutCompanions === null) {
16+
console.error('Could not determine which units are missing test companions');
17+
process.exit(1);
18+
}
19+
else if (
20+
unitsWithoutCompanions.length === 0
21+
) process.exit(0);
22+
23+
const pathFromCurrentModuleToProjectRoot = '../';
24+
25+
const projectRoot = toPath(new URL(
26+
pathFromCurrentModuleToProjectRoot,
27+
import.meta.url,
28+
));
29+
30+
const absolutePathToProjectRoot = serialized(projectRoot);
31+
32+
const serializedUnitsWithoutCompanions = unitsWithoutCompanions
33+
.map($0 => serialized($0).replace(absolutePathToProjectRoot, ''))
34+
.join('\n');
35+
36+
console.error(`The following ${unitsWithoutCompanions.length.toString()} unit(s) have no test companion:\n${serializedUnitsWithoutCompanions}`);
37+
process.exit(1);

0 commit comments

Comments
 (0)