From 28c4666e8b94ad87c8bc1801b7bf2441fca95e0c Mon Sep 17 00:00:00 2001 From: Keanu Kerr Date: Wed, 3 Jan 2024 22:35:12 +0100 Subject: tests.nixpkgs-check-by-name: added test that fails multiple validity checks --- .../tests/multiple-failures/default.nix | 1 + .../nixpkgs-check-by-name/tests/multiple-failures/expected | 14 ++++++++++++++ .../tests/multiple-failures/pkgs/by-name/A/fo@/foo.nix | 1 + .../tests/multiple-failures/pkgs/by-name/A/fo@/package.nix | 1 + .../tests/multiple-failures/pkgs/by-name/aa | 0 .../tests/multiple-failures/pkgs/by-name/ba/bar | 0 .../pkgs/by-name/ba/baz/package.nix/default.nix | 1 + .../multiple-failures/pkgs/by-name/ba/foo/invalid.nix | 1 + .../multiple-failures/pkgs/by-name/ba/foo/package.nix | 6 ++++++ .../tests/multiple-failures/pkgs/by-name/fo/foo/.git-keep | 0 .../tests/multiple-failures/someDrv.nix | 1 + 11 files changed, 26 insertions(+) create mode 100644 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/default.nix create mode 100644 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/expected create mode 120000 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo.nix create mode 120000 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/package.nix create mode 100644 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/aa create mode 100644 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/bar create mode 100644 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/baz/package.nix/default.nix create mode 100644 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/foo/invalid.nix create mode 100644 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/foo/package.nix create mode 100644 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/fo/foo/.git-keep create mode 100644 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/someDrv.nix (limited to 'pkgs/test') diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/default.nix b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/default.nix new file mode 100644 index 000000000000..861260cdca4b --- /dev/null +++ b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/default.nix @@ -0,0 +1 @@ +import { root = ./.; } diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/expected b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/expected new file mode 100644 index 000000000000..a05527312aa2 --- /dev/null +++ b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/expected @@ -0,0 +1,14 @@ +pkgs/by-name/A: Invalid directory name "A", must be at most 2 ASCII characters consisting of a-z, 0-9, "-" or "_". +pkgs/by-name/A/fo@: Invalid package directory name "fo@", must be ASCII characters consisting of a-z, A-Z, 0-9, "-" or "_". +pkgs/by-name/A/fo@: Path foo.nix is a symlink which cannot be resolved: No such file or directory (os error 2). +pkgs/by-name/A/fo@: Path package.nix is a symlink pointing to a path outside the directory of that package. +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. +pkgs/by-name/ba/foo: File package.nix at line 5 contains the path expression "./${"test"}", which is not yet supported and may point outside the directory of that package. +pkgs/by-name/fo/foo: Missing required "package.nix" file. diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo.nix b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo.nix new file mode 120000 index 000000000000..5b25acea3f25 --- /dev/null +++ b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo.nix @@ -0,0 +1 @@ +../../../../foo.nix \ No newline at end of file diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/package.nix b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/package.nix new file mode 120000 index 000000000000..f079163d158a --- /dev/null +++ b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/package.nix @@ -0,0 +1 @@ +../../../../someDrv.nix \ No newline at end of file diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/aa b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/aa new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/bar b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/bar new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/baz/package.nix/default.nix b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/baz/package.nix/default.nix new file mode 100644 index 000000000000..a1b92efbbadb --- /dev/null +++ b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/baz/package.nix/default.nix @@ -0,0 +1 @@ +{ someDrv }: someDrv 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 new file mode 100644 index 000000000000..ee6b002a529b --- /dev/null +++ b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/foo/invalid.nix @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000000..b552ce8c34c0 --- /dev/null +++ b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/ba/foo/package.nix @@ -0,0 +1,6 @@ +{ someDrv }: someDrv // { + escape = /bar; + escape = ../.; + nixPath = ; + pathWithSubexpr = ./${"test"}; +} diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/fo/foo/.git-keep b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/fo/foo/.git-keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/someDrv.nix b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/someDrv.nix new file mode 100644 index 000000000000..a1b92efbbadb --- /dev/null +++ b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/someDrv.nix @@ -0,0 +1 @@ +{ someDrv }: someDrv -- cgit 1.4.1 From aba7e02e1c504760e95e760939ec4995822c18b7 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Wed, 17 Jan 2024 11:10:54 +0100 Subject: tests.nixpkgs-check-by-name: Minor README.md update --- pkgs/test/nixpkgs-check-by-name/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkgs/test') diff --git a/pkgs/test/nixpkgs-check-by-name/README.md b/pkgs/test/nixpkgs-check-by-name/README.md index d779529c7baf..0ed898f14565 100644 --- a/pkgs/test/nixpkgs-check-by-name/README.md +++ b/pkgs/test/nixpkgs-check-by-name/README.md @@ -69,7 +69,7 @@ Tests are declared in [`./tests`](./tests) as subdirectories imitating Nixpkgs w - `default.nix`: Always contains ```nix - import ../mock-nixpkgs.nix { root = ./.; } + import { root = ./.; } ``` which makes ``` -- cgit 1.4.1 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 3b3b05419780..ce7403afb32d 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 a05527312aa2..0cfd3c185a86 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 ee6b002a529b..000000000000 --- 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 b552ce8c34c0..31b4742f5914 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 861260cdca4b..000000000000 --- 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 281aba009236..000000000000 --- 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 ee6b002a529b..000000000000 --- 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 a1b92efbbadb..000000000000 --- 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 From 30af0cdab6de6a0b12f4ab35b2539fe9773db307 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Wed, 17 Jan 2024 15:25:53 +0100 Subject: tests.nixpkgs-check-by-name: Test non-Nix invalid symlinks instead Nix symlinks that are invalid don't pass the new CI check from https://github.com/NixOS/nixpkgs/pull/279892, so let's instead use non-Nix symlinks. --- pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/expected | 2 +- .../tests/multiple-failures/pkgs/by-name/A/fo@/foo | 1 + .../tests/multiple-failures/pkgs/by-name/A/fo@/foo.nix | 1 - pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/expected | 2 +- .../nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo | 1 + .../tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix | 1 - 6 files changed, 4 insertions(+), 4 deletions(-) create mode 120000 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo delete mode 120000 pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo.nix create mode 120000 pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo delete mode 120000 pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix (limited to 'pkgs/test') 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 0cfd3c185a86..ff5d18556ef0 100644 --- a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/expected +++ b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/expected @@ -1,6 +1,6 @@ pkgs/by-name/A: Invalid directory name "A", must be at most 2 ASCII characters consisting of a-z, 0-9, "-" or "_". pkgs/by-name/A/fo@: Invalid package directory name "fo@", must be ASCII characters consisting of a-z, A-Z, 0-9, "-" or "_". -pkgs/by-name/A/fo@: Path foo.nix is a symlink which cannot be resolved: No such file or directory (os error 2). +pkgs/by-name/A/fo@: Path foo is a symlink which cannot be resolved: No such file or directory (os error 2). pkgs/by-name/A/fo@: Path package.nix is a symlink pointing to a path outside the directory of that package. 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. diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo new file mode 120000 index 000000000000..c86c3f3551ec --- /dev/null +++ b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo @@ -0,0 +1 @@ +none \ No newline at end of file diff --git a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo.nix b/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo.nix deleted file mode 120000 index 5b25acea3f25..000000000000 --- a/pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo.nix +++ /dev/null @@ -1 +0,0 @@ -../../../../foo.nix \ No newline at end of file diff --git a/pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/expected b/pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/expected index f622f3e7fd6d..c1e7a28205a7 100644 --- a/pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/expected +++ b/pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/expected @@ -1 +1 @@ -pkgs/by-name/fo/foo: Path foo.nix is a symlink which cannot be resolved: No such file or directory (os error 2). +pkgs/by-name/fo/foo: Path foo is a symlink which cannot be resolved: No such file or directory (os error 2). diff --git a/pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo b/pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo new file mode 120000 index 000000000000..c86c3f3551ec --- /dev/null +++ b/pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo @@ -0,0 +1 @@ +none \ No newline at end of file diff --git a/pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix b/pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix deleted file mode 120000 index 49cd425a8cdb..000000000000 --- a/pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix +++ /dev/null @@ -1 +0,0 @@ -none.nix \ No newline at end of file -- cgit 1.4.1