test: add integration test for #235

This commit is contained in:
Martin Toman 2022-08-11 12:27:21 -07:00
parent 98e0a1a0ad
commit 4dca0944ab
5 changed files with 87 additions and 0 deletions

View File

@ -174,6 +174,13 @@
inherit self;
});
tests-integration.type = "app";
tests-integration.program =
b.toString
(dream2nixFor."${system}".callPackageDream ./tests/integration {
inherit self;
});
tests-examples.type = "app";
tests-examples.program =
b.toString
@ -201,6 +208,9 @@
echo "running unit tests"
${self.apps.${system}.tests-unit.program}
echo "running integration tests"
${self.apps.${system}.tests-integration.program}
echo "checking flakes under ./examples"
${self.apps.${system}.tests-examples.program}

View File

@ -0,0 +1,52 @@
{
self,
lib,
async,
bash,
coreutils,
git,
parallel,
nix,
utils,
dream2nixWithExternals,
...
}: let
l = lib // builtins;
tests = ./tests;
testScript =
utils.writePureShellScript
[
async
bash
coreutils
git
nix
]
''
dir=$1
shift
echo -e "\nrunning test $dir"
cp -r ${tests}/$dir/* .
chmod -R +w .
nix flake lock --override-input dream2nix ${../../.}
nix run .#resolveImpure || echo "no resolveImpure probably?"
nix eval --read-only --no-allow-import-from-derivation .#default.name
nix build
nix flake check "$@"
'';
in
utils.writePureShellScript
[
coreutils
parallel
]
''
if [ -z ''${1+x} ]; then
parallel --halt now,fail=1 -j$(nproc) -a <(ls ${tests}) ${testScript}
else
arg1=$1
shift
${testScript} $arg1 "$@"
fi
echo "done running integration tests"
''

1
tests/integration/tests/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
flake.lock

View File

@ -0,0 +1,14 @@
{
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
};
outputs = {
self,
dream2nix,
}: (dream2nix.lib.makeFlakeOutputs {
systems = ["x86_64-linux"];
config.projectRoot = ./.;
source = ./.;
});
}

View File

@ -0,0 +1,10 @@
{
"name": "test-built-binary",
"version": "1.0.0",
"bin": {
"main": "./main.js"
},
"scripts": {
"build": "touch main.js"
}
}