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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
22 changes: 19 additions & 3 deletions internal/fourslash/_scripts/convertFourslash.mts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ const stradaFourslashPath = path.resolve(import.meta.dirname, "../", "../", "../
let inputFileSet: Set<string> | undefined;

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

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

const unparsedFiles: string[] = [];

Expand All @@ -21,6 +23,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 @@ -34,15 +44,16 @@ export function main() {

fs.rmSync(outputDir, { recursive: true, force: true });
fs.mkdirSync(outputDir, { recursive: true });
fs.mkdirSync(manualOutputDir, { recursive: true });

generateHelperFile();
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 @@ -53,12 +64,17 @@ function parseTypeScriptFiles(failingTests: Set<string>, folder: string): void {
}

if (stat.isDirectory()) {
parseTypeScriptFiles(failingTests, filePath);
parseTypeScriptFiles(failingTests, manualTests, filePath);
}
else if (file.endsWith(".ts")) {
const content = fs.readFileSync(filePath, "utf-8");
const test = parseFileContent(file, content);
if (test) {
const testName = test.name[0].toUpperCase() + test.name.substring(1);
// Skip generation if test is in manual tests list
if (manualTests.has(testName)) {
return;
}
const testContent = generateGoTest(failingTests, test);
const testPath = path.join(outputDir, `${test.name}_test.go`);
fs.writeFileSync(testPath, testContent, "utf-8");
Expand Down
45 changes: 45 additions & 0 deletions internal/fourslash/_scripts/makeManual.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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) {
process.exit(1);
}
Comment on lines +12 to +14
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script exits with code 1 when no arguments are provided, but doesn't provide any error message to explain what went wrong or how to use the script correctly.

Suggested change
if (args.length === 0) {
process.exit(1);
}
if (args.length === 0) {
console.error("Error: No arguments provided.");
console.error("Usage: node makeManual.mts <testName>");
console.error("Provide the name of the test to move from the 'gen' directory to the 'manual' directory.");
process.exit(1);
}

Copilot uses AI. Check for mistakes.


const testName = args[0];
const testFileName = testName;
const genTestFile = path.join(genDir, `${testFileName}`);
if (!fs.existsSync(genTestFile)) {
console.error(`Test file not found: ${genTestFile}`);
console.error("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));
fs.renameSync(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");
}
}

main();
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