From cf90aa9a86e5edf4e8c991904ce04183fc10c99c Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Wed, 17 Jan 2024 15:23:52 +0100 Subject: tests.nixpkgs-check-by-name: Don't test invalid Nix files Since https://github.com/NixOS/nixpkgs/pull/279892, there's a separate check that makes sure all changed Nix files evaluate. To not trigger that, we need to remove all invalid Nix expressions from the tests. --- pkgs/test/nixpkgs-check-by-name/src/references.rs | 4 ++++ pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/expected | 1 - .../tests/multiple-failures/pkgs/by-name/ba/foo/invalid.nix | 1 - .../tests/multiple-failures/pkgs/by-name/ba/foo/package.nix | 4 ++-- pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/default.nix | 1 - pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/expected | 1 - .../tests/ref-parse-failure/pkgs/by-name/aa/aa/invalid.nix | 1 - .../tests/ref-parse-failure/pkgs/by-name/aa/aa/package.nix | 1 - 8 files changed, 6 insertions(+), 8 deletions(-) delete mode 100644 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/foo/invalid.nix delete mode 100644 pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/default.nix delete mode 100644 pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/expected delete mode 100644 pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/pkgs/by-name/aa/aa/invalid.nix delete mode 100644 pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/pkgs/by-name/aa/aa/package.nix (limited to 'pkgs/test') diff --git a/pkgs/test/nixpkgs-check-by-name/src/references.rs b/pkgs/test/nixpkgs-check-by-name/src/references.rs index 3b3b05419780a..ce7403afb32d6 100644 --- a/pkgs/test/nixpkgs-check-by-name/src/references.rs +++ b/pkgs/test/nixpkgs-check-by-name/src/references.rs @@ -106,6 +106,10 @@ fn check_nix_file( let root = Root::parse(&contents); if let Some(error) = root.errors().first() { + // NOTE: There's now another Nixpkgs CI check to make sure all changed Nix files parse + // correctly, though that uses mainline Nix instead of rnix, so it doesn't give the same + // errors. In the future we should unify these two checks, ideally moving the other CI + // check into this tool as well and checking for both mainline Nix and rnix. return Ok(NixpkgsProblem::CouldNotParseNix { relative_package_dir: relative_package_dir.to_path_buf(), subpath: subpath.to_path_buf(), diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/expected b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/expected index a05527312aa2f..0cfd3c185a867 100644 --- a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/expected +++ b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/expected @@ -6,7 +6,6 @@ pkgs/by-name/aa: This is a file, but it should be a directory. pkgs/by-name/ba/bar: This path is a file, but it should be a directory. pkgs/by-name/ba/baz: "package.nix" must be a file. pkgs/by-name/ba/foo: Incorrect directory location, should be pkgs/by-name/fo/foo instead. -pkgs/by-name/ba/foo: File invalid.nix could not be parsed by rnix: unexpected token at 28..29 pkgs/by-name/ba/foo: File package.nix at line 2 contains the path expression "/bar" which cannot be resolved: No such file or directory (os error 2). pkgs/by-name/ba/foo: File package.nix at line 3 contains the path expression "../." which may point outside the directory of that package. pkgs/by-name/ba/foo: File package.nix at line 4 contains the nix search path expression "" which may point outside the directory of that package. diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/foo/invalid.nix b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/foo/invalid.nix deleted file mode 100644 index ee6b002a529be..0000000000000 --- a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/foo/invalid.nix +++ /dev/null @@ -1 +0,0 @@ -this is not a valid nix file! diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/foo/package.nix b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/foo/package.nix index b552ce8c34c0e..31b4742f5914f 100644 --- a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/foo/package.nix +++ b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/foo/package.nix @@ -1,6 +1,6 @@ { someDrv }: someDrv // { - escape = /bar; - escape = ../.; + escapeAbsolute = /bar; + escapeRelative = ../.; nixPath = ; pathWithSubexpr = ./${"test"}; } diff --git a/pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/default.nix b/pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/default.nix deleted file mode 100644 index 861260cdca4b2..0000000000000 --- a/pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/default.nix +++ /dev/null @@ -1 +0,0 @@ -import { root = ./.; } diff --git a/pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/expected b/pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/expected deleted file mode 100644 index 281aba0092367..0000000000000 --- a/pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/expected +++ /dev/null @@ -1 +0,0 @@ -pkgs/by-name/aa/aa: File invalid.nix could not be parsed by rnix: unexpected token at 28..29 diff --git a/pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/pkgs/by-name/aa/aa/invalid.nix b/pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/pkgs/by-name/aa/aa/invalid.nix deleted file mode 100644 index ee6b002a529be..0000000000000 --- a/pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/pkgs/by-name/aa/aa/invalid.nix +++ /dev/null @@ -1 +0,0 @@ -this is not a valid nix file! diff --git a/pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/pkgs/by-name/aa/aa/package.nix b/pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/pkgs/by-name/aa/aa/package.nix deleted file mode 100644 index a1b92efbbadb9..0000000000000 --- a/pkgs/test/nixpkgs-check-by-name/tests/ref-parse-failure/pkgs/by-name/aa/aa/package.nix +++ /dev/null @@ -1 +0,0 @@ -{ someDrv }: someDrv -- cgit 1.4.1