diff --git a/tests/functional/export-graph.sh b/tests/functional/export-graph.sh deleted file mode 100644 index c1fb4d0a3..000000000 --- a/tests/functional/export-graph.sh +++ /dev/null @@ -1,30 +0,0 @@ -source common.sh - -clearStore -clearProfiles - -checkRef() { - nix-store -q --references $TEST_ROOT/result | grepQuiet "$1"'$' || fail "missing reference $1" -} - -# Test the export of the runtime dependency graph. - -outPath=$(nix-build ./export-graph.nix -A 'foo."bar.runtimeGraph"' -o $TEST_ROOT/result) - -test $(nix-store -q --references $TEST_ROOT/result | wc -l) = 4 || fail "bad nr of references" - -checkRef input-2 -for i in $(cat $outPath); do checkRef $i; done - -# Test the export of the build-time dependency graph. - -nix-store --gc # should force rebuild of input-1 - -outPath=$(nix-build ./export-graph.nix -A 'foo."bar.buildGraph"' -o $TEST_ROOT/result) - -checkRef input-1 -checkRef input-1.drv -checkRef input-2 -checkRef input-2.drv - -for i in $(cat $outPath); do checkRef $i; done diff --git a/tests/functional/meson.build b/tests/functional/meson.build index b33e4d3a7..052e3d66f 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -48,7 +48,6 @@ functional_tests_scripts = [ 'repair.sh', 'repair-chroot.sh', 'fixed.sh', - 'export-graph.sh', 'fetchGitRefs.sh', 'gc-runtime.sh', 'fetchers.sh', diff --git a/tests/functional/export-graph.nix b/tests/functional2/store/assets/export-graph.nix similarity index 100% rename from tests/functional/export-graph.nix rename to tests/functional2/store/assets/export-graph.nix diff --git a/tests/functional2/store/test_export_graph.py b/tests/functional2/store/test_export_graph.py new file mode 100644 index 000000000..5b1f4ccc1 --- /dev/null +++ b/tests/functional2/store/test_export_graph.py @@ -0,0 +1,46 @@ +from testlib.utils import get_global_asset_pack +from pathlib import Path +from testlib.fixtures.file_helper import with_files +from testlib.fixtures.file_helper import CopyFile +from testlib.fixtures.nix import Nix + +export_files = {"export-graph.nix": CopyFile("assets/export-graph.nix")} | get_global_asset_pack( + "dependencies" +) + + +def check_ref(nix: Nix, file: str): + res = nix.nix_store(["-q", "--references", nix.env.dirs.home / "result"]).run().ok() + assert file in res.stdout_plain + + +def check_out_path_refs(nix: Nix, out_path: str): + for file in Path(out_path).read_text().splitlines(): + check_ref(nix, file) + + +@with_files(export_files) +def test_export_runtime(nix: Nix, files: Path): + result = files / "result" + out_path = ( + nix.nix_build(["./export-graph.nix", "-A", 'foo."bar.runtimeGraph"', "-o", result]) + .run() + .ok() + ) + references = nix.nix_store(["-q", "--references", result]).run().ok().stdout_plain + assert len(references.splitlines()) == 4 + + check_ref(nix, "input-2") + check_out_path_refs(nix, out_path.stdout_plain) + + +@with_files(export_files) +def test_built_time(nix: Nix, files: Path): + result = files / "result" + out_path = ( + nix.nix_build(["./export-graph.nix", "-A", 'foo."bar.buildGraph"', "-o", result]).run().ok() + ) + + for file in ["input-1", "input-1.drv", "input-2", "input-2.drv"]: + check_ref(nix, file) + check_out_path_refs(nix, out_path.stdout_plain)