Skip to content

Commit

Permalink
Allow non-yaml files in recorded tests dir (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
pokey authored Dec 12, 2021
1 parent 9df55b6 commit 68d6ccb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
9 changes: 2 additions & 7 deletions src/scripts/transformRecordedTests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FixtureTransformation } from "./types";
import { upgrade } from "./transformations/upgrade";
import { identity } from "./transformations/identity";
import { transformFile } from "./transformFile";
import getRecordedTestPaths from "../../test/suite/getRecordedTestPaths";

const AVAILABLE_TRANSFORMATIONS: Record<string, FixtureTransformation> = {
upgrade,
Expand All @@ -23,13 +24,7 @@ async function main(transformationName: string | undefined) {
throw new Error(`Unknown transformation ${transformationName}`);
}

const directory = path.join(
__dirname,
"../../../src/test/suite/fixtures/recorded"
);
const files = walkFilesSync(directory);

files.forEach((file) => transformFile(transformation, file));
getRecordedTestPaths().forEach((path) => transformFile(transformation, path));
}

main(process.argv[2]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Parse-tree parity

This directory contains a copy of all of the surrounding pair tests that were written for plaintext, but with their language mode set to typescript, to ensure that they are handled identically when we have a parse tree.
13 changes: 13 additions & 0 deletions src/test/suite/getRecordedTestPaths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as path from "path";
import { walkFilesSync } from "../../testUtil/walkSync";

export default function getRecordedTestPaths() {
const directory = path.join(
__dirname,
"../../../src/test/suite/fixtures/recorded"
);

return walkFilesSync(directory).filter(
(path) => path.endsWith(".yml") || path.endsWith(".yaml")
);
}
14 changes: 5 additions & 9 deletions src/test/suite/recorded.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import {
SelectionPlainObject,
SerializedMarks,
} from "../../testUtil/toPlainObject";
import { walkFilesSync } from "../../testUtil/walkSync";
import { getCursorlessApi } from "../../util/getExtensionApi";
import { enableDebugLog } from "../../util/debug";
import { extractTargetedMarks } from "../../testUtil/extractTargetedMarks";
import asyncSafety from "./asyncSafety";
import { ReadOnlyHatMap } from "../../core/IndividualHatMap";
import { mockPrePhraseGetVersion } from "../mockPrePhraseGetVersion";
import { openNewEditor } from "../openNewEditor";
import getRecordedTestPaths from "./getRecordedTestPaths";

function createPosition(position: PositionPlainObject) {
return new vscode.Position(position.line, position.character);
Expand All @@ -38,21 +38,17 @@ function createSelection(selection: SelectionPlainObject): vscode.Selection {
suite("recorded test cases", async function () {
this.timeout("100s");
this.retries(5);
const directory = path.join(
__dirname,
"../../../src/test/suite/fixtures/recorded"
);
const files = walkFilesSync(directory);

enableDebugLog(false);

teardown(() => {
sinon.restore();
});

files.forEach((file) =>
getRecordedTestPaths().forEach((path) =>
test(
file.split(".")[0],
asyncSafety(() => runTest(file))
path.split(".")[0],
asyncSafety(() => runTest(path))
)
);
});
Expand Down

0 comments on commit 68d6ccb

Please sign in to comment.