Skip to content

Commit

Permalink
fix: by-require does not need stripping
Browse files Browse the repository at this point in the history
  • Loading branch information
FauxFaux committed Mar 14, 2020
1 parent 6d8c831 commit e6adbb5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/by-require.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function byRequire(
// b) kills anything else in flight, catching our mistakes
tap.endAll();

const result = translateArray(output);
const result = translateArray(output, { strip: 0 });

result.displayName = testPath;
result.testFilePath = testPath;
Expand Down
3 changes: 2 additions & 1 deletion lib/by-spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export async function bySpawn(

const [code, sig] = await runTapOn(parser, tapCommand, testPath);

const result = translateArray(output);
// 1: the path of the file itself
const result = translateArray(output, { strip: 1 });

result.displayName = testPath;
result.testFilePath = testPath;
Expand Down
14 changes: 11 additions & 3 deletions lib/translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,26 @@ export function makeParser(): [TapParser, TapParserArray] {
return [parser, output];
}

export function translateArray(output: TapParserArray): TestResult {
/**
* @param strip remove leading path components; and ignore tests for fewer components
*/
export function translateArray(
output: TapParserArray,
{ strip }: { strip: number },
): TestResult {
const tests: Tests = new Map();
bunchUp(output, tests);

const tapSummary = [...tests.entries()].filter(([path]) => path.length > 1);
const tapSummary = [...tests.entries()].filter(
([path]) => path.length > strip,
);
const result = createEmptyTestResult();

result.failureMessage = '';

result.testResults = tapSummary.map(([fullPath, { results, time }]) => {
// removing the full path
const path = fullPath.slice(1);
const path = fullPath.slice(strip);
const passing = results.filter((r) => r.ok);
const notOkay = results.filter((r) => !r.ok);
const passed = notOkay.length === 0;
Expand Down

0 comments on commit e6adbb5

Please sign in to comment.