Skip to content

Commit

Permalink
resolved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
darkeris345 committed Jan 16, 2025
1 parent 5f5db92 commit 4b675e5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ node_modules
.vscode-test/
*.vsix
resources/ade
src/testResults
resources/testResults
5 changes: 0 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,4 @@
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
}
38 changes: 21 additions & 17 deletions src/stability-test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { DebugManagerMock } from "./DebugManagerMock";
let parserHelper: AblParserHelper;

const extensionDevelopmentPath = path.resolve(__dirname, "../../../");
const testResultsDir = join(extensionDevelopmentPath, "src/testResults");
const testResultsDir = join(extensionDevelopmentPath, "resources/testResults");

const stabilityTestDir = join(extensionDevelopmentPath, "resources/ade");
const extensionsToFind = [".p", ".w", ".cls", ".i"];
Expand All @@ -28,8 +28,10 @@ const stabilityTestCases = getFilesWithExtensions(

console.log("Parser initialized", stabilityTestCases);


const testRunTimestamp = new Date().toISOString().replace(/[:.T-]/g, "_").substr(0, 19);
const testRunTimestamp = new Date()
.toISOString()
.replace(/[:.T-]/g, "_")
.substring(0, 19);
const testRunDir = join(testResultsDir, testRunTimestamp);

suite("Extension Test Suite", () => {
Expand Down Expand Up @@ -65,10 +67,6 @@ suite("Extension Test Suite", () => {
test(`Symbol test: ${cases}`, () => {
stabilityTest(cases);
}).timeout(10000);

// test(`Parser error test: ${cases}`, () => {
// treeSitterTest(cases, fileId.toString);
// });
});
});

Expand All @@ -82,10 +80,15 @@ function stabilityTest(name: string): void {
const afterCount = countActualSymbols(afterText);

if (beforeCount !== afterCount) {

const fileName = path.basename(name, path.extname(name));
const beforeFilePath = join(testRunDir, `${fileName}_before${path.extname(name)}`);
const afterFilePath = join(testRunDir, `${fileName}_after${path.extname(name)}`);
const beforeFilePath = join(
testRunDir,
`${fileName}_before${path.extname(name)}`
);
const afterFilePath = join(
testRunDir,
`${fileName}_after${path.extname(name)}`
);

fs.writeFileSync(beforeFilePath, beforeText);
fs.writeFileSync(afterFilePath, afterText);
Expand All @@ -94,7 +97,6 @@ function stabilityTest(name: string): void {
Before: ${beforeFilePath}
After: ${afterFilePath}
`);

}
// assert.strictEqual(beforeCount, afterCount);
}
Expand Down Expand Up @@ -171,7 +173,7 @@ function countActualSymbols(text: string): number {
for (const element of text) {
const char = element;
// Exclude spaces, newlines, carriage returns, and tabs
if (char !== ' ' && char !== '\n' && char !== '\r' && char !== '\t') {
if (char !== " " && char !== "\n" && char !== "\r" && char !== "\t") {
count++;
}
}
Expand Down Expand Up @@ -227,13 +229,15 @@ function formatErrorMessage(errors: Parser.SyntaxNode[], name: string): string {
errors.forEach((errorNode, index) => {
errorMessage += `Error ${index + 1}:\n`;
errorMessage += `- Type : ${errorNode.type}\n`;
errorMessage += `- Start Position : Line ${errorNode.startPosition.row + 1
}, Column ${errorNode.startPosition.column + 1}\n`;
errorMessage += `- End Position : Line ${errorNode.endPosition.row + 1
}, Column ${errorNode.endPosition.column + 1}\n`;
errorMessage += `- Start Position : Line ${
errorNode.startPosition.row + 1
}, Column ${errorNode.startPosition.column + 1}\n`;
errorMessage += `- End Position : Line ${
errorNode.endPosition.row + 1
}, Column ${errorNode.endPosition.column + 1}\n`;
errorMessage += `- Code Snippet :\n\n${errorNode.text}\n`;
errorMessage += `--------------------------------------------------------------------------------\n`;
});

return errorMessage;
}
}

0 comments on commit 4b675e5

Please sign in to comment.