Skip to content
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
2 changes: 1 addition & 1 deletion src/core/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function compile(testCodePaths: string[], outputFolder: string, com
const argv = compileFlags.split(" ");
ascArgv = ascArgv.concat(argv);
}
await ascMain(ascArgv);
await ascMain(ascArgv, false);
};

// Here, for-await is more efficient and less memory cost than Promise.all()
Expand Down
2 changes: 1 addition & 1 deletion src/core/precompile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async function transform(transformFunction: string, codePath: string, flags: str
const argv = flags.split(" ");
ascArgv = ascArgv.concat(argv);
}
await ascMain(ascArgv);
await ascMain(ascArgv, true);
collectCallback();
}

Expand Down
5 changes: 4 additions & 1 deletion src/utils/ascWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ export class CompilationError extends Error {
}
}

export async function ascMain(ascArgv: string[]) {
export async function ascMain(ascArgv: string[], isTransform: boolean) {
const stderr = createMemoryStream();
const { error } = await compiler.compile(ascArgv.concat("--noColors"), { stderr });
if (error) {
if (isTransform && error instanceof Error && error.message === "TransformDone") {
return;
}
throw new CompilationError(stderr.toString());
}
}
1 change: 1 addition & 0 deletions transform/listFunctions.mts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class SourceFunctionTransform extends Transform {
this.visitNode(entrySource);
this.functionInfos.reverse();
globalThis.functionInfos = this.functionInfos;
throw new Error("TransformDone");
}

visitNode(node: Node) {
Expand Down
7 changes: 4 additions & 3 deletions transform/listTestNames.mts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ import {
NamespaceDeclaration,
VariableDeclaration,
SwitchCase,
Program,
IdentifierExpression,
LiteralExpression,
LiteralKind,
StringLiteralExpression,
Parser,
} from "assemblyscript";
import assert from "node:assert";

Expand All @@ -55,14 +55,15 @@ class SourceFunctionTransform extends Transform {
currentTestDescriptions: string[] = [];
testFileName: string;

afterInitialize(program: Program) {
afterParse(parser: Parser) {
// There will be two sources with SourceKind.UserEntry, ~lib/rt/index-incremental.ts should be filtered
const entrySource = program.sources.find(
const entrySource = parser.sources.find(
(source) => source.sourceKind === SourceKind.UserEntry && !source.normalizedPath.startsWith("~lib/")
);
this.testFileName = entrySource.normalizedPath;
this.visitNode(entrySource);
globalThis.testNames = this.testNames;
throw new Error("TransformDone");
}

visitNode(node: Node) {
Expand Down