Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 16 additions & 10 deletions src/core/precompile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
includes: string[],
excludes: string[],
testcases: string[] | undefined,
flags: string,
transformFunction = join(projectRoot, "transform", "listFunctions.mjs")
): Promise<UnittestPackage> {
// if specify testcases, use testcases for unittest
Expand All @@ -23,7 +24,7 @@
const sourceCodePaths = getRelatedFiles(includes, excludes, (path: string) => !path.endsWith(".test.ts"));
const sourceCodeTransforms: Promise<void>[] = [];
for (const sourceCodePath of sourceCodePaths.values()) {
sourceCodeTransforms.push(transform(sourceCodePath, transformFunction));
sourceCodeTransforms.push(transform(sourceCodePath, transformFunction, flags));
}
await Promise.all(sourceCodeTransforms);

Expand Down Expand Up @@ -55,15 +56,20 @@
return result;
}

async function transform(sourceCodePath: string, transformFunction: string) {
const { error, stderr } = await main([
sourceCodePath,
"--noEmit",
"--disableWarning",
"--transform",
transformFunction,
"-O0",
]);
async function transform(sourceCodePath: string, transformFunction: string, flags: string) {
let ascArgv = [

Check failure on line 60 in src/core/precompile.ts

View workflow job for this annotation

GitHub Actions / test

Replace `⏎······sourceCodePath,⏎······"--noEmit",⏎······"--disableWarning",⏎·····"--transform",⏎······transformFunction,⏎······"-O0",⏎··]` with `sourceCodePath,·"--noEmit",·"--disableWarning",·"--transform",·transformFunction,·"-O0"];`
sourceCodePath,
"--noEmit",
"--disableWarning",
"--transform",
transformFunction,
"-O0",
]
if (flags) {
const argv = flags.split(" ");

Check failure on line 69 in src/core/precompile.ts

View workflow job for this annotation

GitHub Actions / test

Delete `··`
ascArgv = ascArgv.concat(argv);

Check failure on line 70 in src/core/precompile.ts

View workflow job for this annotation

GitHub Actions / test

Delete `··`
}
const { error, stderr } = await main(ascArgv);
if (error) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
console.error(stderr.toString());
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export type OutputMode = "html" | "json" | "table";
export async function start_unit_test(fo: FileOption, to: TestOption, oo: OutputOption): Promise<boolean> {
emptydirSync(oo.outputFolder);
emptydirSync(oo.tempFolder);
const unittestPackage = await precompile(fo.includes, fo.excludes, fo.testcases);
const unittestPackage = await precompile(fo.includes, fo.excludes, fo.testcases, to.flags);
console.log(chalk.blueBright("code analysis: ") + chalk.bold.greenBright("OK"));
const wasmPaths = await compile(unittestPackage.testCodePaths, oo.tempFolder, to.flags);
console.log(chalk.blueBright("compile testcases: ") + chalk.bold.greenBright("OK"));
Expand Down
Loading