diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-05-26 18:31:35 +0200 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-06-01 18:07:33 +0200 |
commit | 0b6021ee53eb4677e96f28a260db9157b4f19c7a (patch) | |
tree | 07c7a83cc212cadd3af88fb36c24db5ad51835d1 /lib | |
parent | de0c11241f8a2e72c2cd02b86fedaaeb30292e97 (diff) | |
download | nixlib-0b6021ee53eb4677e96f28a260db9157b4f19c7a.tar nixlib-0b6021ee53eb4677e96f28a260db9157b4f19c7a.tar.gz nixlib-0b6021ee53eb4677e96f28a260db9157b4f19c7a.tar.bz2 nixlib-0b6021ee53eb4677e96f28a260db9157b4f19c7a.tar.lz nixlib-0b6021ee53eb4677e96f28a260db9157b4f19c7a.tar.xz nixlib-0b6021ee53eb4677e96f28a260db9157b4f19c7a.tar.zst nixlib-0b6021ee53eb4677e96f28a260db9157b4f19c7a.zip |
lib/tests: Fix when run with Nix 2.3
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/tests/modules.sh | 2 | ||||
-rwxr-xr-x | lib/tests/sources.sh | 23 |
2 files changed, 15 insertions, 10 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 7fdc3d3d81aa..7aebba6b589e 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -378,7 +378,7 @@ checkConfigOutput '^{ }$' config.sub.nixosOk ./class-check.nix checkConfigError 'The module .*/module-class-is-darwin.nix was imported into nixos instead of darwin.' config.sub.nixosFail.config ./class-check.nix # submoduleWith type merge with different class -checkConfigError 'error: A submoduleWith option is declared multiple times with conflicting class values "darwin" and "nixos".' config.sub.mergeFail.config ./class-check.nix +checkConfigError 'A submoduleWith option is declared multiple times with conflicting class values "darwin" and "nixos".' config.sub.mergeFail.config ./class-check.nix # _type check checkConfigError 'Could not load a value as a module, because it is of type "flake", in file .*/module-imports-_type-check.nix' config.ok.config ./module-imports-_type-check.nix diff --git a/lib/tests/sources.sh b/lib/tests/sources.sh index a7f490a79d74..cda77aa96b28 100755 --- a/lib/tests/sources.sh +++ b/lib/tests/sources.sh @@ -23,14 +23,19 @@ clean_up() { trap clean_up EXIT cd "$work" -touch {README.md,module.o,foo.bar} +# Crudely unquotes a JSON string by just taking everything between the first and the second quote. +# We're only using this for resulting /nix/store paths, which can't contain " anyways, +# nor can they contain any other characters that would need to be escaped specially in JSON +# This way we don't need to add a dependency on e.g. jq +crudeUnquoteJSON() { + cut -d \" -f2 +} -# nix-instantiate doesn't write out the source, only computing the hash, so -# this uses the experimental nix command instead. +touch {README.md,module.o,foo.bar} -dir="$(nix eval --impure --raw --expr '(with import <nixpkgs/lib>; "${ +dir="$(nix-instantiate --eval --strict --read-write-mode --json --expr '(with import <nixpkgs/lib>; "${ cleanSource ./. -}")')" +}")' | crudeUnquoteJSON)" (cd "$dir"; find) | sort -f | diff -U10 - <(cat <<EOF . ./foo.bar @@ -39,9 +44,9 @@ EOF ) || die "cleanSource 1" -dir="$(nix eval --impure --raw --expr '(with import <nixpkgs/lib>; "${ +dir="$(nix-instantiate --eval --strict --read-write-mode --json --expr '(with import <nixpkgs/lib>; "${ cleanSourceWith { src = '"$work"'; filter = path: type: ! hasSuffix ".bar" path; } -}")')" +}")' | crudeUnquoteJSON)" (cd "$dir"; find) | sort -f | diff -U10 - <(cat <<EOF . ./module.o @@ -49,9 +54,9 @@ dir="$(nix eval --impure --raw --expr '(with import <nixpkgs/lib>; "${ EOF ) || die "cleanSourceWith 1" -dir="$(nix eval --impure --raw --expr '(with import <nixpkgs/lib>; "${ +dir="$(nix-instantiate --eval --strict --read-write-mode --json --expr '(with import <nixpkgs/lib>; "${ cleanSourceWith { src = cleanSource '"$work"'; filter = path: type: ! hasSuffix ".bar" path; } -}")')" +}")' | crudeUnquoteJSON)" (cd "$dir"; find) | sort -f | diff -U10 - <(cat <<EOF . ./README.md |