Skip to content

Commit 6d19ac2

Browse files
Adding manual tests list (#1446)
Co-authored-by: Gabriela Araujo Britto <[email protected]> Co-authored-by: Gabriela Araujo Britto <[email protected]>
1 parent a9efe52 commit 6d19ac2

File tree

7 files changed

+71
-9
lines changed

7 files changed

+71
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,4 @@ custom-gcl.hash
198198
!NOTICE.txt
199199

200200
!internal/fourslash/_scripts/failingTests.txt
201+
!internal/fourslash/_scripts/manualTests.txt

internal/fourslash/_scripts/convertFourslash.mts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const stradaFourslashPath = path.resolve(import.meta.dirname, "../", "../", "../
1010
let inputFileSet: Set<string> | undefined;
1111

1212
const failingTestsPath = path.join(import.meta.dirname, "failingTests.txt");
13-
const helperFilePath = path.join(import.meta.dirname, "../", "tests", "util_test.go");
13+
const manualTestsPath = path.join(import.meta.dirname, "manualTests.txt");
1414

1515
const outputDir = path.join(import.meta.dirname, "../", "tests", "gen");
1616

@@ -21,6 +21,14 @@ function getFailingTests(): Set<string> {
2121
return new Set(failingTestsList);
2222
}
2323

24+
function getManualTests(): Set<string> {
25+
if (!fs.existsSync(manualTestsPath)) {
26+
return new Set();
27+
}
28+
const manualTestsList = fs.readFileSync(manualTestsPath, "utf-8").split("\n").map(line => line.trim()).filter(line => line.length > 0);
29+
return new Set(manualTestsList);
30+
}
31+
2432
export function main() {
2533
const args = process.argv.slice(2);
2634
const inputFilesPath = args[0];
@@ -35,13 +43,13 @@ export function main() {
3543
fs.rmSync(outputDir, { recursive: true, force: true });
3644
fs.mkdirSync(outputDir, { recursive: true });
3745

38-
parseTypeScriptFiles(getFailingTests(), stradaFourslashPath);
46+
parseTypeScriptFiles(getFailingTests(), getManualTests(), stradaFourslashPath);
3947
console.log(unparsedFiles.join("\n"));
4048
const gofmt = which.sync("go");
4149
cp.execFileSync(gofmt, ["tool", "mvdan.cc/gofumpt", "-lang=go1.24", "-w", outputDir]);
4250
}
4351

44-
function parseTypeScriptFiles(failingTests: Set<string>, folder: string): void {
52+
function parseTypeScriptFiles(failingTests: Set<string>, manualTests: Set<string>, folder: string): void {
4553
const files = fs.readdirSync(folder);
4654

4755
files.forEach(file => {
@@ -52,9 +60,9 @@ function parseTypeScriptFiles(failingTests: Set<string>, folder: string): void {
5260
}
5361

5462
if (stat.isDirectory()) {
55-
parseTypeScriptFiles(failingTests, filePath);
63+
parseTypeScriptFiles(failingTests, manualTests, filePath);
5664
}
57-
else if (file.endsWith(".ts")) {
65+
else if (file.endsWith(".ts") && !manualTests.has(file.slice(0, -3))) {
5866
const content = fs.readFileSync(filePath, "utf-8");
5967
const test = parseFileContent(file, content);
6068
if (test) {

internal/fourslash/_scripts/failingTests.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ TestCompletionListFunctionMembers
7979
TestCompletionListInArrowFunctionInUnclosedCallSite01
8080
TestCompletionListInClassExpressionWithTypeParameter
8181
TestCompletionListInClassStaticBlocks
82-
TestCompletionListInClosedFunction05
8382
TestCompletionListInComments
8483
TestCompletionListInExtendsClause
8584
TestCompletionListInImportClause01
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import * as fs from "fs";
2+
import * as path from "path";
3+
4+
const scriptsDir = import.meta.dirname;
5+
const manualTestsPath = path.join(scriptsDir, "manualTests.txt");
6+
const genDir = path.join(scriptsDir, "../", "tests", "gen");
7+
const manualDir = path.join(scriptsDir, "../", "tests", "manual");
8+
9+
function main() {
10+
const args = process.argv.slice(2);
11+
12+
if (args.length === 0) {
13+
console.error("Please provide the name of the generated test file.");
14+
process.exit(1);
15+
}
16+
17+
const testName = args[0];
18+
const testFileName = testName;
19+
const genTestFile = path.join(genDir, testFileName + "_test.go");
20+
if (!fs.existsSync(genTestFile)) {
21+
console.error(`Test file not found: '${genTestFile}'. Make sure the test exists in the gen directory first.`);
22+
process.exit(1);
23+
}
24+
25+
if (!fs.existsSync(manualDir)) {
26+
fs.mkdirSync(manualDir, { recursive: true });
27+
}
28+
29+
const manualTestFile = path.join(manualDir, path.basename(genTestFile));
30+
renameAndRemoveSkip(genTestFile, manualTestFile);
31+
32+
let manualTests: string[] = [];
33+
if (fs.existsSync(manualTestsPath)) {
34+
const content = fs.readFileSync(manualTestsPath, "utf-8");
35+
manualTests = content.split("\n").map(line => line.trim()).filter(line => line.length > 0);
36+
}
37+
38+
if (!manualTests.includes(testName)) {
39+
manualTests.push(testName);
40+
manualTests.sort();
41+
fs.writeFileSync(manualTestsPath, [...manualTests, ""].join("\n"), "utf-8");
42+
}
43+
}
44+
45+
function renameAndRemoveSkip(genFilePath: string, manualFilePath: string) {
46+
const content = fs.readFileSync(genFilePath, "utf-8");
47+
const updatedContent = content.replace(/^\s*t\.Skip\(\)\s*$/m, "");
48+
fs.writeFileSync(manualFilePath, updatedContent, "utf-8");
49+
fs.rmSync(genFilePath);
50+
}
51+
52+
main();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
completionListInClosedFunction05

internal/fourslash/tests/gen/completionListInClosedFunction05_test.go renamed to internal/fourslash/tests/manual/completionListInClosedFunction05_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
func TestCompletionListInClosedFunction05(t *testing.T) {
1212
t.Parallel()
13-
t.Skip()
13+
1414
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
1515
const content = `function foo(x: string, y: number, z: boolean) {
1616
function bar(a: number, b: string = "hello", c: typeof x = "hello") {
@@ -21,7 +21,7 @@ func TestCompletionListInClosedFunction05(t *testing.T) {
2121
f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{
2222
IsIncomplete: false,
2323
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
24-
CommitCharacters: &[]string{},
24+
CommitCharacters: &DefaultCommitCharacters,
2525
EditRange: Ignored,
2626
},
2727
Items: &fourslash.CompletionsExpectedItems{

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"extension:watch": "npm run -w _extension watch",
3030
"node": "node --no-warnings --conditions @typescript/source",
3131
"convertfourslash": "node --experimental-strip-types --no-warnings internal/fourslash/_scripts/convertFourslash.mts",
32-
"updatefailing": "node --experimental-strip-types --no-warnings internal/fourslash/_scripts/updateFailing.mts"
32+
"updatefailing": "node --experimental-strip-types --no-warnings internal/fourslash/_scripts/updateFailing.mts",
33+
"makemanual": "node --experimental-strip-types --no-warnings internal/fourslash/_scripts/makeManual.mts"
3334
},
3435
"workspaces": [
3536
"./_extension",

0 commit comments

Comments
 (0)