Skip to content

Commit

Permalink
Add an initial integration test
Browse files Browse the repository at this point in the history
We are getting to the point where the current unit tests are not
sufficient enough to catch implementation errors as the plugins become
more complex - there is only so much dog fooding we can do.

Remove the `examples` folder, which was not hooked up anyway, and add an
`integration` folder with one example to test the `@ninjutsu-build/node`
plugin as I discovered an issue with the `dyndep` generation.  This is
not fixed in this commit but left as a `// FIX` comment.
  • Loading branch information
elliotgoodrich committed Mar 25, 2024
1 parent bdaca7f commit 89b70c6
Show file tree
Hide file tree
Showing 33 changed files with 240 additions and 434 deletions.
46 changes: 45 additions & 1 deletion configure.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ format({ in: "configure.mjs", cwd: "." });

const scope = "@ninjutsu-build/";
const graph = {};
toposort(
const tars = toposort(
globSync("*", { posix: true, cwd: "packages" }).flatMap((packageName) => {
const packageJSON = JSON.parse(
readFileSync(join("packages", packageName, "package.json")).toString(),
Expand Down Expand Up @@ -347,4 +347,48 @@ toposort(
});
}, {});

{
const cwd = "integration";

// If `packageJSON` is changed (and only after we have run `npm ci`)
// install our packages locally
const packageJSON = join(cwd, "package.json");
const dependenciesInstalled = ci({ in: packageJSON });
const linked = link({
in: packageJSON,
pkgs: Object.values(tars),
[orderOnlyDeps]: [dependenciesInstalled],
});

// Grab all TypeScript tests files and format them
const tests = globSync(join(cwd, "src", "*.test.ts"), {
posix: true,
}).map(formatAndLint);

const typechecked = typecheck({
in: tests,
out: join(cwd, "dist", "typechecked.stamp"),
compilerOptions,
cwd,
[implicitDeps]: [linked],
});

const integrationTests = typechecked.map((t) => {
const file = getInput(t);
const js = transpile({
in: t,
out: join(cwd, "dist", basename(file, extname(file)) + ".mjs"),
args: transpileArgs,
});

return test({
in: js,
out: js + ".result.txt",
[implicitDeps]: [linked],
});
});

phony({ out: "integration", in: integrationTests });
}

writeFileSync("build.ninja", ninja.output);
2 changes: 0 additions & 2 deletions examples/basic1/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions examples/basic1/README.md

This file was deleted.

48 changes: 0 additions & 48 deletions examples/basic1/configure.mjs

This file was deleted.

126 changes: 0 additions & 126 deletions examples/basic1/package-lock.json

This file was deleted.

15 changes: 0 additions & 15 deletions examples/basic1/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions examples/basic1/src/function.ts

This file was deleted.

3 changes: 0 additions & 3 deletions examples/basic1/src/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions examples/basic2/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions examples/basic2/README.md

This file was deleted.

42 changes: 0 additions & 42 deletions examples/basic2/configure.mjs

This file was deleted.

Loading

0 comments on commit 89b70c6

Please sign in to comment.