testing: migrate flakes/unlocked-override.sh
Change-Id: I101c96860e0a025a066880d952d2f24f9b92571e
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
source ./common.sh
|
||||
|
||||
requireGit
|
||||
|
||||
flake1Dir=$TEST_ROOT/flake1
|
||||
flake2Dir=$TEST_ROOT/flake2
|
||||
|
||||
createGitRepo $flake1Dir
|
||||
cat > $flake1Dir/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self }: { x = import ./x.nix; };
|
||||
}
|
||||
EOF
|
||||
echo 123 > $flake1Dir/x.nix
|
||||
git -C $flake1Dir add flake.nix x.nix
|
||||
git -C $flake1Dir commit -m Initial
|
||||
|
||||
createGitRepo $flake2Dir
|
||||
cat > $flake2Dir/flake.nix <<EOF
|
||||
{
|
||||
outputs = { self, flake1 }: { x = flake1.x; };
|
||||
}
|
||||
EOF
|
||||
git -C $flake2Dir add flake.nix
|
||||
|
||||
[[ $(nix eval --json $flake2Dir#x --override-input flake1 $TEST_ROOT/flake1) = 123 ]]
|
||||
|
||||
echo 456 > $flake1Dir/x.nix
|
||||
|
||||
[[ $(nix eval --json $flake2Dir#x --override-input flake1 $TEST_ROOT/flake1) = 456 ]]
|
||||
@@ -40,7 +40,6 @@ functional_tests_scripts = [
|
||||
'flakes/inputs.sh',
|
||||
'flakes/follow-paths.sh',
|
||||
'flakes/bundle.sh',
|
||||
'flakes/unlocked-override.sh',
|
||||
'flakes/build-paths.sh',
|
||||
'flakes/flake-in-submodule.sh',
|
||||
'flakes/flake-metadata.sh',
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
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(
|
||||
{
|
||||
"flake1": get_global_asset_pack(".git")
|
||||
| {
|
||||
"flake.nix": File("""{
|
||||
outputs = { self }: { x = import ./x.nix; };
|
||||
}"""),
|
||||
"x.nix": File("123"),
|
||||
},
|
||||
"flake2": get_global_asset_pack(".git")
|
||||
| {
|
||||
"flake.nix": File("""{
|
||||
outputs = { self, flake1 }: { x = flake1.x; };
|
||||
}""")
|
||||
},
|
||||
}
|
||||
)
|
||||
def test_unlocked_override(nix: Nix, files: Path, git: Git):
|
||||
nix.settings.add_xp_feature("nix-command", "flakes")
|
||||
|
||||
git(files / "flake1", "add", "flake.nix", "x.nix")
|
||||
git(files / "flake1", "commit", "-m", "Initial")
|
||||
|
||||
git(files / "flake2", "add", "flake.nix")
|
||||
|
||||
assert (
|
||||
nix.nix(
|
||||
["eval", "--json", f"{files}/flake2#x", "--override-input", "flake1", files / "flake1"]
|
||||
)
|
||||
.run()
|
||||
.ok()
|
||||
.stdout_s
|
||||
== "123\n"
|
||||
)
|
||||
|
||||
(files / "flake1/x.nix").write_text("456")
|
||||
|
||||
assert (
|
||||
nix.nix(
|
||||
["eval", "--json", f"{files}/flake2#x", "--override-input", "flake1", files / "flake1"]
|
||||
)
|
||||
.run()
|
||||
.ok()
|
||||
.stdout_s
|
||||
== "456\n"
|
||||
)
|
||||
Reference in New Issue
Block a user