From 278fddc317cf0cf4d3602d0ec0f24d1dd281fadb Mon Sep 17 00:00:00 2001 From: piegames Date: Sat, 13 Jul 2024 07:55:17 +0200 Subject: libexpr: Deprecate URL literals Closes #437. Change-Id: I9f67fc965bb4a7e7fd849e5067ac1cb3bab064cd --- tests/functional/lang.sh | 7 ++++++- tests/functional/lang/parse-okay-regression-20041027.nix | 1 + tests/functional/lang/parse-okay-url.nix | 1 + tests/unit/libexpr/trivial.cc | 10 +++++----- 4 files changed, 13 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/functional/lang.sh b/tests/functional/lang.sh index 94c00bad0..aa41b41d8 100755 --- a/tests/functional/lang.sh +++ b/tests/functional/lang.sh @@ -53,8 +53,13 @@ done for i in lang/parse-okay-*.nix; do echo "parsing $i (should succeed)"; i=$(basename "$i" .nix) + # Hard-code that these two files are allowed to use url literals (because they test them) + if [[ "$i" == "parse-okay-url" || "$i" == "parse-okay-regression-20041027" ]] + then + extraArgs="--extra-deprecated-features url-literals" + fi if - expect 0 nix-instantiate --parse - < "lang/$i.nix" \ + expect 0 nix-instantiate --parse ${extraArgs-} - < "lang/$i.nix" \ 1> "lang/$i.out" \ 2> "lang/$i.err" then diff --git a/tests/functional/lang/parse-okay-regression-20041027.nix b/tests/functional/lang/parse-okay-regression-20041027.nix index ae2e256ee..541264b16 100644 --- a/tests/functional/lang/parse-okay-regression-20041027.nix +++ b/tests/functional/lang/parse-okay-regression-20041027.nix @@ -1,3 +1,4 @@ +# This test needs to be run with --extra-deprecated-features url-literals {stdenv, fetchurl /* pkgconfig, libX11 */ }: stdenv.mkDerivation { diff --git a/tests/functional/lang/parse-okay-url.nix b/tests/functional/lang/parse-okay-url.nix index 08de27d0a..f74a72bb1 100644 --- a/tests/functional/lang/parse-okay-url.nix +++ b/tests/functional/lang/parse-okay-url.nix @@ -1,3 +1,4 @@ +# This test needs to be run with --extra-deprecated-features url-literals [ x:x https://svn.cs.uu.nl:12443/repos/trace/trunk http://www2.mplayerhq.hu/MPlayer/releases/fonts/font-arial-iso-8859-1.tar.bz2 diff --git a/tests/unit/libexpr/trivial.cc b/tests/unit/libexpr/trivial.cc index 46f9b7499..905e258bc 100644 --- a/tests/unit/libexpr/trivial.cc +++ b/tests/unit/libexpr/trivial.cc @@ -87,15 +87,15 @@ namespace nix { } TEST_F(TrivialExpressionTest, urlLiteral) { - auto v = eval("https://nixos.org"); + FeatureSettings mockFeatureSettings; + mockFeatureSettings.set("deprecated-features", "url-literals"); + + auto v = eval("https://nixos.org", true, mockFeatureSettings); ASSERT_THAT(v, IsStringEq("https://nixos.org")); } TEST_F(TrivialExpressionTest, noUrlLiteral) { - ExperimentalFeatureSettings mockXpSettings; - mockXpSettings.set("experimental-features", "no-url-literals"); - - ASSERT_THROW(eval("https://nixos.org", true, mockXpSettings), Error); + ASSERT_THROW(eval("https://nixos.org"), Error); } TEST_F(TrivialExpressionTest, withFound) { -- cgit v1.2.3