Skip to content

Commit

Permalink
chore(code-gen): speed up examples test by running them in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkdev98 committed May 9, 2023
1 parent 6a61e7c commit 69cfb6a
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions test/examples.test.js
Expand Up @@ -31,36 +31,38 @@ test("compas/examples", async (t) => {
)
).filter((it) => !!it);

for (const config of configs) {
t.test(config.exampleMetadata.path, (t) => {
await Promise.all(
configs.map(async (config) => {
for (const cmd of config.exampleMetadata.testing) {
t.test(cmd, async (t) => {
const parts = cmd.split(" ");
if (parts[0] === "compas") {
parts[0] = "../../node_modules/.bin/compas";
}
const parts = cmd.split(" ");
if (parts[0] === "compas") {
parts[0] = "../../node_modules/.bin/compas";
}

const { exitCode, stdout, stderr } = await exec(parts.join(" "), {
cwd: config.exampleMetadata.path,
env: {
PATH: environment.PATH,
CI: environment.CI,
GITHUB_ACTIONS: environment.GITHUB_ACTIONS,
},
});
const { exitCode, stdout, stderr } = await exec(parts.join(" "), {
cwd: config.exampleMetadata.path,
env: {
PATH: environment.PATH,
CI: environment.CI,
GITHUB_ACTIONS: environment.GITHUB_ACTIONS,
},
});

t.equal(exitCode, 0);
t.equal(
exitCode,
0,
`Path: ${config.exampleMetadata.path}, Command: ${cmd}, Exitcode: ${exitCode}`,
);

if (exitCode !== 0) {
t.log.error({
config,
cmd,
stdout,
stderr,
});
}
});
if (exitCode !== 0) {
t.log.error({
config,
cmd,
stdout,
stderr,
});
}
}
});
}
}),
);
});

0 comments on commit 69cfb6a

Please sign in to comment.