Skip to content

Commit c825703

Browse files
authored
Move shouldUpgradeFixtures to common (#1711)
## Checklist - [ ] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [ ] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [ ] I have not broken the cheatsheet
1 parent d4de147 commit c825703

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

packages/common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export * from "./testUtil/testConstants";
5858
export * from "./testUtil/getFixturePaths";
5959
export * from "./testUtil/getCursorlessRepoRoot";
6060
export * from "./testUtil/serialize";
61+
export * from "./testUtil/shouldUpdateFixtures";
6162
export * from "./testUtil/TestCaseSnapshot";
6263
export * from "./testUtil/serializeTestFixture";
6364
export * from "./util/typeUtils";

packages/cursorless-vscode-e2e/src/shouldUpdateFixtures.ts renamed to packages/common/src/testUtil/shouldUpdateFixtures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
* Used to check weather the update fixtures launch config was used.
33
* @returns `true` if developer used to the update fixtures launch config
44
*/
5-
export default function shouldUpdateFixtures() {
5+
export function shouldUpdateFixtures() {
66
return process.env.CURSORLESS_TEST_UPDATE_FIXTURES === "true";
77
}

packages/cursorless-vscode-e2e/src/endToEndTestSetup.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { IDE, sleep, SpyIDE } from "@cursorless/common";
1+
import { IDE, shouldUpdateFixtures, sleep, SpyIDE } from "@cursorless/common";
22
import { getCursorlessApi } from "@cursorless/vscode-common";
33
import { Context } from "mocha";
44
import * as sinon from "sinon";
5-
import shouldUpdateFixtures from "./shouldUpdateFixtures";
65

76
/**
87
* The number of times the current test has been retried. Will be 0 the first

packages/cursorless-vscode-e2e/src/suite/recorded.vscode.test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
ExcludableSnapshotField,
44
extractTargetedMarks,
55
getRecordedTestPaths,
6+
getRecordedTestsDirPath,
67
HatStability,
78
marksToPlainObject,
89
omitByDeep,
@@ -13,6 +14,7 @@ import {
1314
SelectionPlainObject,
1415
SerializedMarks,
1516
serializeTestFixture,
17+
shouldUpdateFixtures,
1618
splitKey,
1719
SpyIDE,
1820
spyIDERecordedValuesToPlainObject,
@@ -26,14 +28,14 @@ import {
2628
runCursorlessCommand,
2729
} from "@cursorless/vscode-common";
2830
import { assert } from "chai";
29-
import { promises as fsp } from "fs";
3031
import * as yaml from "js-yaml";
31-
import { isUndefined } from "lodash";
32+
import { promises as fsp } from "node:fs";
33+
import * as path from "node:path";
3234
import * as vscode from "vscode";
3335
import asyncSafety from "../asyncSafety";
3436
import { endToEndTestSetup, sleepWithBackoff } from "../endToEndTestSetup";
35-
import shouldUpdateFixtures from "../shouldUpdateFixtures";
3637
import { setupFake } from "./setupFake";
38+
import { isUndefined } from "lodash";
3739

3840
function createPosition(position: PositionPlainObject) {
3941
return new vscode.Position(position.line, position.character);
@@ -55,10 +57,12 @@ suite("recorded test cases", async function () {
5557
setupFake(ide, HatStability.stable);
5658
});
5759

58-
getRecordedTestPaths().forEach((path) =>
60+
const relativeDir = path.dirname(getRecordedTestsDirPath());
61+
62+
getRecordedTestPaths().forEach((testPath) =>
5963
test(
60-
path.split(".")[0],
61-
asyncSafety(() => runTest(path, getSpy()!)),
64+
path.relative(relativeDir, testPath.split(".")[0]),
65+
asyncSafety(() => runTest(testPath, getSpy()!)),
6266
),
6367
);
6468
});

0 commit comments

Comments
 (0)