Skip to content

Commit

Permalink
[Toolchain] Implement profile in ToolchainEnv (#1576)
Browse files Browse the repository at this point in the history
This commit implements profile function in ToolchainEnv.

ONE-vscode-DCO-1.0-Signed-off-by: Jiyoung Yun <[email protected]>
  • Loading branch information
jyoungyun authored Jun 2, 2023
1 parent 3b1a92f commit 9c69e81
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Tests/Toolchain/ToolchainEnv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,17 @@ suite("Toolchain", function () {
});
});
});

suite("#profile()", function () {
test("NEG: requests unimplemented profile", async function () {
let env = new ToolchainEnv(compiler);
const invalidToolchain = env.listInstalled();
assert.isAbove(invalidToolchain.length, 0);
const model = "model.bin";
await env.profile(invalidToolchain[0], model).catch(() => {
assert.isTrue(true);
});
});
});
});
});
16 changes: 16 additions & 0 deletions src/Toolchain/ToolchainEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,22 @@ class ToolchainEnv extends Env {
this.executeEnv(jobs);
});
}

public profile(
toolchain: Toolchain,
model: string,
options?: Map<string, string>
): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
const jobs: Array<Job> = [];
const job = new JobConfig(toolchain.runProfile(model, options));
job.workDir = path.dirname(model);
job.successCallback = () => resolve(true);
job.failureCallback = () => reject();
jobs.push(job);
this.executeEnv(jobs);
});
}
}

/**
Expand Down

0 comments on commit 9c69e81

Please sign in to comment.