f2: migrate toString-path.sh

Change-Id: I862f532e94e385aa0f14c03e38e7e003c7bc83c3
This commit is contained in:
rootile
2026-02-09 15:37:41 +01:00
parent f761785099
commit a99b6f18c8
3 changed files with 40 additions and 9 deletions
-1
View File
@@ -141,7 +141,6 @@ functional_tests_scripts = [
'store-ping.sh',
'flakes/show.sh',
'path-from-hash-part.sh',
'toString-path.sh',
'read-only-store.sh',
'nested-sandboxing.sh',
'test-libstoreconsumer.sh',
-8
View File
@@ -1,8 +0,0 @@
source common.sh
mkdir -p $TEST_ROOT/foo
echo bla > $TEST_ROOT/foo/bar
[[ $(nix eval --raw --impure --expr "builtins.readFile (builtins.toString (builtins.fetchTree { type = \"path\"; path = \"$TEST_ROOT/foo\"; } + \"/bar\"))") = bla ]]
[[ $(nix eval --json --impure --expr "builtins.readDir (builtins.toString (builtins.fetchTree { type = \"path\"; path = \"$TEST_ROOT/foo\"; }))") = '{"bar":"regular"}' ]]
+40
View File
@@ -0,0 +1,40 @@
from testlib.fixtures.file_helper import with_files, File
from testlib.fixtures.nix import Nix
@with_files({"foo": {"bar": File("bla")}})
def test_path_read_file(nix: Nix):
nix.settings.add_xp_feature("nix-command", "flakes")
res = (
nix.nix(
[
"eval",
"--raw",
"--impure",
"--expr",
f'builtins.readFile (builtins.toString (builtins.fetchTree {{ type = "path"; path = "{nix.env.dirs.home / "foo"}"; }} + "/bar"))',
]
)
.run()
.ok()
)
assert res.stdout_plain == "bla"
@with_files({"foo": {"bar": File("bla")}})
def test_path_read_dir(nix: Nix):
nix.settings.add_xp_feature("nix-command", "flakes")
res = (
nix.nix(
[
"eval",
"--json",
"--impure",
"--expr",
f'builtins.readDir (builtins.toString (builtins.fetchTree {{ type = "path"; path = "{nix.env.dirs.home / "foo"}"; }}))',
]
)
.run()
.ok()
)
assert res.stdout_plain == '{"bar":"regular"}'