testing: migrate flakes/circular.sh
Change-Id: Ia9eb3631278957c449dd8791e9cf02cb47705a63
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
# Test circular flake dependencies.
|
||||
source ./common.sh
|
||||
|
||||
requireGit
|
||||
|
||||
flakeA=$TEST_ROOT/flakeA
|
||||
flakeB=$TEST_ROOT/flakeB
|
||||
|
||||
createGitRepo $flakeA
|
||||
createGitRepo $flakeB
|
||||
|
||||
cat > $flakeA/flake.nix <<EOF
|
||||
{
|
||||
inputs.b.url = "git+file://$flakeB";
|
||||
inputs.b.inputs.a.follows = "/";
|
||||
|
||||
outputs = { self, b }: {
|
||||
foo = 123 + b.bar;
|
||||
xyzzy = 1000;
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
git -C $flakeA add flake.nix
|
||||
|
||||
cat > $flakeB/flake.nix <<EOF
|
||||
{
|
||||
inputs.a.url = "git+file://$flakeA";
|
||||
|
||||
outputs = { self, a }: {
|
||||
bar = 456 + a.xyzzy;
|
||||
};
|
||||
}
|
||||
EOF
|
||||
|
||||
git -C $flakeB add flake.nix
|
||||
git -C $flakeB commit -a -m 'Foo'
|
||||
|
||||
[[ $(nix eval $flakeA#foo) = 1579 ]]
|
||||
[[ $(nix eval $flakeA#foo) = 1579 ]]
|
||||
|
||||
sed -i $flakeB/flake.nix -e 's/456/789/'
|
||||
git -C $flakeB commit -a -m 'Foo'
|
||||
|
||||
nix flake update b --flake $flakeA
|
||||
[[ $(nix eval $flakeA#foo) = 1912 ]]
|
||||
|
||||
# Test list-inputs with circular dependencies
|
||||
nix flake metadata $flakeA
|
||||
@@ -36,7 +36,6 @@ functional_tests_scripts = [
|
||||
'flakes/develop.sh',
|
||||
'flakes/develop-r8854.sh',
|
||||
'flakes/mercurial.sh',
|
||||
'flakes/circular.sh',
|
||||
'flakes/init.sh',
|
||||
'flakes/inputs.sh',
|
||||
'flakes/follow-paths.sh',
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.git import Git
|
||||
from testlib.fixtures.file_helper import with_files, File
|
||||
from testlib.utils import get_global_asset_pack
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@with_files(
|
||||
{
|
||||
"flakeA": get_global_asset_pack(".git")
|
||||
| {
|
||||
"flake.nix": File("""{
|
||||
inputs.b.url = "git+file://$flakeB";
|
||||
inputs.b.inputs.a.follows = "/";
|
||||
|
||||
outputs = { self, b }: {
|
||||
foo = 123 + b.bar;
|
||||
xyzzy = 1000;
|
||||
};
|
||||
}""")
|
||||
},
|
||||
"flakeB": get_global_asset_pack(".git")
|
||||
| {
|
||||
"flake.nix": File("""{
|
||||
inputs.a.url = "git+file://$flakeA";
|
||||
|
||||
outputs = { self, a }: {
|
||||
bar = 456 + a.xyzzy;
|
||||
};
|
||||
}""")
|
||||
},
|
||||
}
|
||||
)
|
||||
def test_circular(nix: Nix, files: Path, git: Git):
|
||||
nix.settings.add_xp_feature("nix-command", "flakes")
|
||||
|
||||
path = files / "flakeA/flake.nix"
|
||||
path.write_text(path.read_text().replace("$flakeB", str(files / "flakeB")))
|
||||
git(files / "flakeA", "add", "flake.nix")
|
||||
|
||||
path = files / "flakeB/flake.nix"
|
||||
path.write_text(path.read_text().replace("$flakeA", str(files / "flakeA")))
|
||||
git(files / "flakeB", "add", "flake.nix")
|
||||
git(files / "flakeB", "commit", "-a", "-m", "Foo")
|
||||
|
||||
assert nix.nix(["eval", f"{files}/flakeA#foo"]).run().ok().stdout_s == "1579\n"
|
||||
|
||||
path = files / "flakeB/flake.nix"
|
||||
path.write_text(path.read_text().replace("456", "789"))
|
||||
git(files / "flakeB", "commit", "-a", "-m", "Foo")
|
||||
nix.nix(["flake", "update", "b", "--flake", f"{files}/flakeA"]).run().ok()
|
||||
assert nix.nix(["eval", f"{files}/flakeA#foo"]).run().ok().stdout_s == "1912\n"
|
||||
|
||||
# Test list-inputs with circular dependencies
|
||||
nix.nix(["flake", "metadata", f"{files}/flakeA"]).run().ok()
|
||||
Reference in New Issue
Block a user