Skip to content

Adding manual tests list #1446

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

Merged
merged 7 commits into from
Jul 29, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,4 @@ custom-gcl.hash
!NOTICE.txt

!internal/fourslash/_scripts/failingTests.txt
!internal/fourslash/_scripts/manualTests.txt
18 changes: 13 additions & 5 deletions internal/fourslash/_scripts/convertFourslash.mts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const stradaFourslashPath = path.resolve(import.meta.dirname, "../", "../", "../
let inputFileSet: Set<string> | undefined;

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

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

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

function getManualTests(): Set<string> {
if (!fs.existsSync(manualTestsPath)) {
return new Set();
}
const manualTestsList = fs.readFileSync(manualTestsPath, "utf-8").split("\n").map(line => line.trim()).filter(line => line.length > 0);
return new Set(manualTestsList);
}

export function main() {
const args = process.argv.slice(2);
const inputFilesPath = args[0];
Expand All @@ -35,13 +43,13 @@ export function main() {
fs.rmSync(outputDir, { recursive: true, force: true });
fs.mkdirSync(outputDir, { recursive: true });

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

function parseTypeScriptFiles(failingTests: Set<string>, folder: string): void {
function parseTypeScriptFiles(failingTests: Set<string>, manualTests: Set<string>, folder: string): void {
const files = fs.readdirSync(folder);

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

if (stat.isDirectory()) {
parseTypeScriptFiles(failingTests, filePath);
parseTypeScriptFiles(failingTests, manualTests, filePath);
}
else if (file.endsWith(".ts")) {
else if (file.endsWith(".ts") && !manualTests.has(file.slice(0, -3))) {
const content = fs.readFileSync(filePath, "utf-8");
const test = parseFileContent(file, content);
if (test) {
Expand Down
1 change: 0 additions & 1 deletion internal/fourslash/_scripts/failingTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ TestCompletionListFunctionMembers
TestCompletionListInArrowFunctionInUnclosedCallSite01
TestCompletionListInClassExpressionWithTypeParameter
TestCompletionListInClassStaticBlocks
TestCompletionListInClosedFunction05
TestCompletionListInComments
TestCompletionListInExtendsClause
TestCompletionListInImportClause01
Expand Down
52 changes: 52 additions & 0 deletions internal/fourslash/_scripts/makeManual.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import * as fs from "fs";
import * as path from "path";

const scriptsDir = import.meta.dirname;
const manualTestsPath = path.join(scriptsDir, "manualTests.txt");
const genDir = path.join(scriptsDir, "../", "tests", "gen");
const manualDir = path.join(scriptsDir, "../", "tests", "manual");

function main() {
const args = process.argv.slice(2);

if (args.length === 0) {
console.error("Please provide the name of the generated test file.");
process.exit(1);
}

const testName = args[0];
const testFileName = testName;
const genTestFile = path.join(genDir, testFileName + "_test.go");
if (!fs.existsSync(genTestFile)) {
console.error(`Test file not found: '${genTestFile}'. Make sure the test exists in the gen directory first.`);
process.exit(1);
}

if (!fs.existsSync(manualDir)) {
fs.mkdirSync(manualDir, { recursive: true });
}

const manualTestFile = path.join(manualDir, path.basename(genTestFile));
renameAndRemoveSkip(genTestFile, manualTestFile);

let manualTests: string[] = [];
if (fs.existsSync(manualTestsPath)) {
const content = fs.readFileSync(manualTestsPath, "utf-8");
manualTests = content.split("\n").map(line => line.trim()).filter(line => line.length > 0);
}

if (!manualTests.includes(testName)) {
manualTests.push(testName);
manualTests.sort();
fs.writeFileSync(manualTestsPath, [...manualTests, ""].join("\n"), "utf-8");
}
}

function renameAndRemoveSkip(genFilePath: string, manualFilePath: string) {
const content = fs.readFileSync(genFilePath, "utf-8");
const updatedContent = content.replace(/^\s*t\.Skip\(\)\s*$/m, "");
fs.writeFileSync(manualFilePath, updatedContent, "utf-8");
fs.rmSync(genFilePath);
}

main();
1 change: 1 addition & 0 deletions internal/fourslash/_scripts/manualTests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
completionListInClosedFunction05
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func TestCompletionListInClosedFunction05(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `function foo(x: string, y: number, z: boolean) {
function bar(a: number, b: string = "hello", c: typeof x = "hello") {
Expand All @@ -21,7 +21,7 @@ func TestCompletionListInClosedFunction05(t *testing.T) {
f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
CommitCharacters: &[]string{},
CommitCharacters: &DefaultCommitCharacters,
EditRange: Ignored,
},
Items: &fourslash.CompletionsExpectedItems{
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"extension:watch": "npm run -w _extension watch",
"node": "node --no-warnings --conditions @typescript/source",
"convertfourslash": "node --experimental-strip-types --no-warnings internal/fourslash/_scripts/convertFourslash.mts",
"updatefailing": "node --experimental-strip-types --no-warnings internal/fourslash/_scripts/updateFailing.mts"
"updatefailing": "node --experimental-strip-types --no-warnings internal/fourslash/_scripts/updateFailing.mts",
"makemanual": "node --experimental-strip-types --no-warnings internal/fourslash/_scripts/makeManual.mts"
},
"workspaces": [
"./_extension",
Expand Down
Loading