diff --git a/flake.nix b/flake.nix index 21cdde3a..a011ca18 100644 --- a/flake.nix +++ b/flake.nix @@ -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} diff --git a/tests/integration/default.nix b/tests/integration/default.nix new file mode 100644 index 00000000..fbbab6cd --- /dev/null +++ b/tests/integration/default.nix @@ -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" + '' diff --git a/tests/integration/tests/.gitignore b/tests/integration/tests/.gitignore new file mode 100644 index 00000000..301d47e1 --- /dev/null +++ b/tests/integration/tests/.gitignore @@ -0,0 +1 @@ +flake.lock diff --git a/tests/integration/tests/nodejs_built-binary/flake.nix b/tests/integration/tests/nodejs_built-binary/flake.nix new file mode 100644 index 00000000..391c2a74 --- /dev/null +++ b/tests/integration/tests/nodejs_built-binary/flake.nix @@ -0,0 +1,14 @@ +{ + inputs = { + dream2nix.url = "github:nix-community/dream2nix"; + }; + + outputs = { + self, + dream2nix, + }: (dream2nix.lib.makeFlakeOutputs { + systems = ["x86_64-linux"]; + config.projectRoot = ./.; + source = ./.; + }); +} diff --git a/tests/integration/tests/nodejs_built-binary/package.json b/tests/integration/tests/nodejs_built-binary/package.json new file mode 100644 index 00000000..dcd3860e --- /dev/null +++ b/tests/integration/tests/nodejs_built-binary/package.json @@ -0,0 +1,10 @@ +{ + "name": "test-built-binary", + "version": "1.0.0", + "bin": { + "main": "./main.js" + }, + "scripts": { + "build": "touch main.js" + } +}