f2: migrate build-delete.sh
Change-Id: I457620a33514477eccb449d4a6237a5ea43fe73d
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
# https://github.com/NixOS/nix/issues/6572
|
||||
issue_6572_independent_outputs() {
|
||||
nix build -f multiple-outputs.nix --json independent --no-link > $TEST_ROOT/independent.json
|
||||
|
||||
# Make sure that 'nix build' can build a derivation that depends on both outputs of another derivation.
|
||||
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
|
||||
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
|
||||
nix-store --delete "$(jq -r <$TEST_ROOT/independent.json .[0].outputs.first)"
|
||||
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
|
||||
cmp $p <<EOF
|
||||
first
|
||||
second
|
||||
EOF
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
|
||||
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
|
||||
nix-store --delete "$(jq -r <$TEST_ROOT/independent.json .[0].outputs.second)"
|
||||
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
|
||||
cmp $p <<EOF
|
||||
first
|
||||
second
|
||||
EOF
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
}
|
||||
issue_6572_independent_outputs
|
||||
|
||||
|
||||
# https://github.com/NixOS/nix/issues/6572
|
||||
issue_6572_dependent_outputs() {
|
||||
|
||||
nix build -f multiple-outputs.nix --json a --no-link > $TEST_ROOT/a.json
|
||||
|
||||
# # Make sure that 'nix build' can build a derivation that depends on both outputs of another derivation.
|
||||
p=$(nix build -f multiple-outputs.nix use-a --no-link --print-out-paths)
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
|
||||
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
|
||||
nix-store --delete "$(jq -r <$TEST_ROOT/a.json .[0].outputs.second)"
|
||||
p=$(nix build -f multiple-outputs.nix use-a --no-link --print-out-paths)
|
||||
cmp $p <<EOF
|
||||
first
|
||||
second
|
||||
EOF
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
}
|
||||
issue_6572_dependent_outputs
|
||||
@@ -130,7 +130,6 @@ functional_tests_scripts = [
|
||||
'placeholders.sh',
|
||||
'ssh-relay.sh',
|
||||
'build.sh',
|
||||
'build-delete.sh',
|
||||
'output-normalization.sh',
|
||||
'selfref-gc.sh',
|
||||
'db-migration.sh',
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.file_helper import with_files
|
||||
from testlib.utils import get_global_asset
|
||||
|
||||
import json
|
||||
from textwrap import dedent
|
||||
|
||||
|
||||
@with_files(
|
||||
{
|
||||
"multiple-outputs.nix": get_global_asset("multiple-outputs.nix"),
|
||||
"config.nix": get_global_asset("config.nix"),
|
||||
}
|
||||
)
|
||||
def test_regression_6572_independent(nix: Nix):
|
||||
"""
|
||||
https://github.com/NixOS/nix/issues/6572
|
||||
"""
|
||||
nix.settings.add_xp_feature("nix-command")
|
||||
independent_text = (
|
||||
nix.nix(["build", "-f", "multiple-outputs.nix", "--json", "independent", "--no-link"])
|
||||
.run()
|
||||
.ok()
|
||||
)
|
||||
independent_json = json.loads(independent_text.stdout_plain)
|
||||
|
||||
# Make sure that 'nix build' can build a derivation that depends on both outputs of another derivation.
|
||||
res = (
|
||||
nix.nix(
|
||||
[
|
||||
"build",
|
||||
"-f",
|
||||
"multiple-outputs.nix",
|
||||
"use-independent",
|
||||
"--no-link",
|
||||
"--print-out-paths",
|
||||
]
|
||||
)
|
||||
.run()
|
||||
.ok()
|
||||
)
|
||||
path = res.stdout_plain
|
||||
|
||||
res = nix.nix_store(["--delete", path]).run().ok()
|
||||
assert "1 store paths deleted" in res.stderr_plain
|
||||
|
||||
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
|
||||
res = nix.nix_store(["--delete", independent_json[0]["outputs"]["first"]]).run().ok()
|
||||
assert "1 store paths deleted" in res.stderr_plain
|
||||
|
||||
res = (
|
||||
nix.nix(
|
||||
[
|
||||
"build",
|
||||
"-f",
|
||||
"multiple-outputs.nix",
|
||||
"use-independent",
|
||||
"--no-link",
|
||||
"--print-out-paths",
|
||||
]
|
||||
)
|
||||
.run()
|
||||
.ok()
|
||||
)
|
||||
assert nix.physical_store_path_for(res.stdout_plain).read_text() == dedent("""\
|
||||
first
|
||||
second
|
||||
""")
|
||||
|
||||
res = nix.nix_store(["--delete", path]).run().ok()
|
||||
assert "1 store paths deleted" in res.stderr_plain
|
||||
|
||||
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
|
||||
res = nix.nix_store(["--delete", independent_json[0]["outputs"]["second"]]).run().ok()
|
||||
assert "1 store paths deleted" in res.stderr_plain
|
||||
|
||||
res = (
|
||||
nix.nix(
|
||||
[
|
||||
"build",
|
||||
"-f",
|
||||
"multiple-outputs.nix",
|
||||
"use-independent",
|
||||
"--no-link",
|
||||
"--print-out-paths",
|
||||
]
|
||||
)
|
||||
.run()
|
||||
.ok()
|
||||
)
|
||||
assert nix.physical_store_path_for(res.stdout_plain).read_text() == dedent("""\
|
||||
first
|
||||
second
|
||||
""")
|
||||
|
||||
|
||||
@with_files(
|
||||
{
|
||||
"multiple-outputs.nix": get_global_asset("multiple-outputs.nix"),
|
||||
"config.nix": get_global_asset("config.nix"),
|
||||
}
|
||||
)
|
||||
def test_regression_6572_dependent(nix: Nix):
|
||||
"""
|
||||
https://github.com/NixOS/nix/issues/6572
|
||||
"""
|
||||
nix.settings.add_xp_feature("nix-command")
|
||||
res = nix.nix(["build", "-f", "multiple-outputs.nix", "--json", "a", "--no-link"]).run().ok()
|
||||
second_path = json.loads(res.stdout_plain)[0]["outputs"]["second"]
|
||||
|
||||
path = (
|
||||
nix.nix(["build", "-f", "multiple-outputs.nix", "use-a", "--no-link", "--print-out-paths"])
|
||||
.run()
|
||||
.ok()
|
||||
.stdout_plain
|
||||
)
|
||||
res = nix.nix_store(["--delete", path]).run().ok()
|
||||
assert "1 store paths deleted" in res.stderr_plain
|
||||
|
||||
res = nix.nix_store(["--delete", second_path]).run().ok()
|
||||
assert "1 store paths deleted" in res.stderr_plain
|
||||
|
||||
res = (
|
||||
nix.nix(["build", "-f", "multiple-outputs.nix", "use-a", "--no-link", "--print-out-paths"])
|
||||
.run()
|
||||
.ok()
|
||||
)
|
||||
assert nix.physical_store_path_for(res.stdout_plain).read_text() == dedent("""\
|
||||
first
|
||||
second
|
||||
""")
|
||||
Reference in New Issue
Block a user