Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-yaml files in recorded tests dir #387

Merged
merged 2 commits into from
Dec 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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