tests: migrate export-graph.sh
Change-Id: I0de67ba6b1f710434f504814dd9b5eb7d486e65a
This commit is contained in:
@@ -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
|
||||
@@ -48,7 +48,6 @@ functional_tests_scripts = [
|
||||
'repair.sh',
|
||||
'repair-chroot.sh',
|
||||
'fixed.sh',
|
||||
'export-graph.sh',
|
||||
'fetchGitRefs.sh',
|
||||
'gc-runtime.sh',
|
||||
'fetchers.sh',
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user