Skip to content

Commit

Permalink
fix(test): Don't run all detectors when blessing a single file
Browse files Browse the repository at this point in the history
  • Loading branch information
jubnzv committed Nov 29, 2024
1 parent b106ae0 commit db3d24a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
26 changes: 14 additions & 12 deletions test/builtinDetectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function processSingleDetectorFile(filePath: string) {
runTestForFile(contractPath, nameBase, detectorName, detectorName);
}

const filePathArg = getFilePathArg();
const filePathArg = getFilePathArg(DETECTORS_DIR);
if (filePathArg) {
// Run test for a single file
const fullPath = path.resolve(filePathArg);
Expand Down Expand Up @@ -105,16 +105,18 @@ if (filePathArg) {
});
}

describe("Built-in Detectors Tests", () => {
it("should have test contracts for all built-in detectors", () => {
const allDetectors = getAllDetectors();
const testFiles = fs
.readdirSync(DETECTORS_DIR)
.filter((file) => file.endsWith(".tact"));
const missingTests = allDetectors.filter((detector) => {
const expectedTestFile = `${detector}.tact`;
return !testFiles.includes(expectedTestFile);
if (!filePathArg) {
describe("Built-in Detectors Tests", () => {
it("should have test contracts for all built-in detectors", () => {
const allDetectors = getAllDetectors();
const testFiles = fs
.readdirSync(DETECTORS_DIR)
.filter((file) => file.endsWith(".tact"));
const missingTests = allDetectors.filter((detector) => {
const expectedTestFile = `${detector}.tact`;
return !testFiles.includes(expectedTestFile);
});
expect(missingTests).toEqual([]);
});
expect(missingTests).toEqual([]);
});
});
}
4 changes: 2 additions & 2 deletions test/testUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ export function resetIds(): void {
*
* Example usage: yarn test tactIR.spec.ts <filepath>
*/
export function getFilePathArg(): string | undefined {
return process.argv.find((arg) => path.resolve(arg).includes(ALL_DIR));
export function getFilePathArg(dir = ALL_DIR): string | undefined {
return process.argv.find((arg) => path.resolve(arg).includes(dir));
}

0 comments on commit db3d24a

Please sign in to comment.