Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
19 changes: 9 additions & 10 deletions src/core/precompile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export async function precompile(
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 @@ export async function precompile(
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,13 @@ export function getRelatedFiles(includes: string[], excludes: string[], filter:
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 = [sourceCodePath, "--noEmit", "--disableWarning", "--transform", transformFunction, "-O0"];
if (flags) {
const argv = flags.split(" ");
ascArgv = ascArgv.concat(argv);
}
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