diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 860ed8f27..c8d04736f 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -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', diff --git a/tests/functional/toString-path.sh b/tests/functional/toString-path.sh deleted file mode 100644 index 07eb87465..000000000 --- a/tests/functional/toString-path.sh +++ /dev/null @@ -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"}' ]] diff --git a/tests/functional2/eval/test_to_string.py b/tests/functional2/eval/test_to_string.py new file mode 100644 index 000000000..096add1e0 --- /dev/null +++ b/tests/functional2/eval/test_to_string.py @@ -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"}'