From 68d6ccb47e294f131bfc68d417023df5a940a30f Mon Sep 17 00:00:00 2001 From: Pokey Rule Date: Sun, 12 Dec 2021 17:19:46 +0000 Subject: [PATCH] Allow non-yaml files in recorded tests dir (#387) --- src/scripts/transformRecordedTests/index.ts | 9 ++------- .../surroundingPair/parseTreeParity/README.md | 3 +++ src/test/suite/getRecordedTestPaths.ts | 13 +++++++++++++ src/test/suite/recorded.test.ts | 14 +++++--------- 4 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 src/test/suite/fixtures/recorded/surroundingPair/parseTreeParity/README.md create mode 100644 src/test/suite/getRecordedTestPaths.ts diff --git a/src/scripts/transformRecordedTests/index.ts b/src/scripts/transformRecordedTests/index.ts index 195f12fb4e..eab82a20bf 100644 --- a/src/scripts/transformRecordedTests/index.ts +++ b/src/scripts/transformRecordedTests/index.ts @@ -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 = { upgrade, @@ -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]); diff --git a/src/test/suite/fixtures/recorded/surroundingPair/parseTreeParity/README.md b/src/test/suite/fixtures/recorded/surroundingPair/parseTreeParity/README.md new file mode 100644 index 0000000000..d92e7e7a21 --- /dev/null +++ b/src/test/suite/fixtures/recorded/surroundingPair/parseTreeParity/README.md @@ -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. \ No newline at end of file diff --git a/src/test/suite/getRecordedTestPaths.ts b/src/test/suite/getRecordedTestPaths.ts new file mode 100644 index 0000000000..796fff8d63 --- /dev/null +++ b/src/test/suite/getRecordedTestPaths.ts @@ -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") + ); +} diff --git a/src/test/suite/recorded.test.ts b/src/test/suite/recorded.test.ts index d9e07ade7b..2d38ecbe1a 100644 --- a/src/test/suite/recorded.test.ts +++ b/src/test/suite/recorded.test.ts @@ -16,7 +16,6 @@ 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"; @@ -24,6 +23,7 @@ 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); @@ -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)) ) ); });