Skip to content

Commit

Permalink
test 3
Browse files Browse the repository at this point in the history
  • Loading branch information
PauliusKu committed Jan 23, 2025
1 parent 36f6953 commit 4825edd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
"[typescript]" : {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

"editor.formatOnSave": true
}
25 changes: 18 additions & 7 deletions src/stability-test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,20 @@ const testRunTimestamp = new Date()
.substring(0, 19);
const testRunDir = join(testResultsDir, testRunTimestamp);

const knownFailures = getFailedTestCases(
join(extensionDevelopmentPath, "resources/stabilityTests")
);
const settingsOverride =
"/* formatterSettingsOverride */\n/*" +
readFile(
join(
extensionDevelopmentPath,
"resources/stabilityTests/.vscode/settings.json"
)
) +
"*/\n";

const knownFailures = getFailedTestCases(join(extensionDevelopmentPath, "resources/stabilityTests"));
console.log(settingsOverride);

suite("Extension Test Suite", () => {
console.log("Parser initialized", stabilityTestCases);
Expand Down Expand Up @@ -77,15 +89,15 @@ function stabilityTest(name: string): void {
ConfigurationManager2.getInstance();
enableFormatterDecorators();

const beforeText = getInput(name);
const beforeText = settingsOverride + getInput(name);
const beforeCount = countActualSymbols(beforeText);
const afterText = format(beforeText, name);
const afterCount = countActualSymbols(afterText);

if (beforeCount !== afterCount) {
const nameWithRelativePath = name.startsWith(stabilityTestDir)
? name.slice(stabilityTestDir.length + 1)
: name;
? name.slice(stabilityTestDir.length + 1)
: name;

const fileName = nameWithRelativePath.replace(/[\s\/\\:*?"<>|]+/g, "_");

Expand Down Expand Up @@ -268,17 +280,16 @@ function getFailedTestCases(filePath: string): string[] {

// Read the file and split lines into an array
const data = fs.readFileSync(failedFilePath, "utf8");
const failures = data.split("\n").filter(line => line.trim() !== "");
const failures = data.split("\n").filter((line) => line.trim() !== "");

console.log("Known failures list has ", failures.length, "cases");

return failures;
}


function addFailedTestCase(filePath: string, failedCase: string): void {
const failedFilePath = path.join(filePath, "_failures.txt");

// Append the failed test case to the file with a newline
fs.appendFileSync(failedFilePath, failedCase + "\n", "utf8");
}
}

0 comments on commit 4825edd

Please sign in to comment.