Skip to content

Commit fe2523f

Browse files
committed
TEST_STANDALONE should be a constant
1 parent ff46c00 commit fe2523f

6 files changed

Lines changed: 26 additions & 11 deletions

File tree

tests/config/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const FORMAT_TEST_DIRECTORY = normalizeDirectory(
1010
path.join(__dirname, "../format/"),
1111
);
1212

13-
export const { FULL_TEST } = process.env;
13+
export const { FULL_TEST, TEST_STANDALONE } = process.env;
1414
export const BOM = "\uFEFF";
1515

1616
export const CURSOR_PLACEHOLDER = "<|>";

tests/config/get-create-parser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { TEST_STANDALONE } from "./constants.js";
2+
13
function getCreateParserInternal() {
2-
const entry = process.env.TEST_STANDALONE
4+
const entry = TEST_STANDALONE
35
? "../../dist/create-parser.js"
46
: "../../src/slang-utils/create-parser.js";
57

tests/config/get-plugins.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import path from "node:path";
22
import createEsmUtils from "esm-utils";
33
import getPrettier from "./get-prettier.js";
4+
import { TEST_STANDALONE } from "./constants.js";
45

56
const { __dirname } = createEsmUtils(import.meta);
67

78
// populate the root object for the standalone in node
8-
if (process.env.TEST_STANDALONE) {
9+
if (TEST_STANDALONE) {
910
const root =
1011
typeof globalThis !== "undefined"
1112
? globalThis
@@ -19,7 +20,7 @@ if (process.env.TEST_STANDALONE) {
1920

2021
function getPluginsInternal() {
2122
return Promise.all(
22-
process.env.TEST_STANDALONE
23+
TEST_STANDALONE
2324
? [
2425
import("prettier/plugins/babel"),
2526
import("prettier/plugins/estree"),

tests/config/get-prettier.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { TEST_STANDALONE } from "./constants.js";
2+
13
function getPrettierInternal() {
2-
const entry = process.env.TEST_STANDALONE
3-
? "prettier/standalone"
4-
: "prettier";
4+
const entry = TEST_STANDALONE ? "prettier/standalone" : "prettier";
55

66
return import(entry).then((module) => module.default);
77
}

tests/config/get-variant-coverage.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { TEST_STANDALONE } from "./constants.js";
2+
13
function getVariantCoverageInternal() {
2-
const entry = process.env.TEST_STANDALONE
4+
const entry = TEST_STANDALONE
35
? "../../dist/variant-coverage.js"
46
: "../../variant-coverage/index.js";
57

tests/config/run-test.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,30 @@ async function testFixture(fixture) {
6969
test: { run: testBom.run },
7070
skip: (testCase) => !FULL_TEST || testCase !== testCaseForSnapshot,
7171
},
72+
// The following cases only need run if the parser is Slang
7273
{
7374
name: "ANTLR format",
7475
test: { run: testAntlrFormat.run },
75-
skip: (testCase) => !FULL_TEST || testCase !== testCaseForSnapshot,
76+
skip: (testCase) =>
77+
!FULL_TEST ||
78+
testCase !== testCaseForSnapshot ||
79+
testCase.parser !== "slang",
7680
},
7781
{
7882
name: "bytecode comparison",
7983
test: { run: testBytecodeCompare.run },
80-
skip: (testCase) => !FULL_TEST || testCase !== testCaseForSnapshot,
84+
skip: (testCase) =>
85+
!FULL_TEST ||
86+
testCase !== testCaseForSnapshot ||
87+
testCase.parser !== "slang",
8188
},
8289
{
8390
name: "variant coverage",
8491
test: { run: testVariantCoverage.run },
85-
skip: (testCase) => !FULL_TEST || testCase !== testCaseForSnapshot,
92+
skip: (testCase) =>
93+
!FULL_TEST ||
94+
testCase !== testCaseForSnapshot ||
95+
testCase.parser !== "slang",
8696
},
8797
]) {
8898
for (const testCase of testCases) {

0 commit comments

Comments
 (0)