tests.nixpkgs-check-by-name: Improve non-syntactic callPackage error more
This commit is contained in:
parent
a53b07e252
commit
7258d472bc
30
pkgs/test/nixpkgs-check-by-name/Cargo.lock
generated
30
pkgs/test/nixpkgs-check-by-name/Cargo.lock
generated
|
@ -306,6 +306,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"temp-env",
|
"temp-env",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
"textwrap",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -489,6 +490,12 @@ version = "1.11.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
|
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "smawk"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
|
@ -534,12 +541,35 @@ version = "1.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233"
|
checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "textwrap"
|
||||||
|
version = "0.16.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9"
|
||||||
|
dependencies = [
|
||||||
|
"smawk",
|
||||||
|
"unicode-linebreak",
|
||||||
|
"unicode-width",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.11"
|
version = "1.0.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
|
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-linebreak"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-width"
|
||||||
|
version = "0.1.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf8parse"
|
name = "utf8parse"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
|
|
@ -17,6 +17,7 @@ itertools = "0.11.0"
|
||||||
rowan = "0.15.11"
|
rowan = "0.15.11"
|
||||||
indoc = "2.0.4"
|
indoc = "2.0.4"
|
||||||
relative-path = "1.9.2"
|
relative-path = "1.9.2"
|
||||||
|
textwrap = "0.16.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
temp-env = "0.3.5"
|
temp-env = "0.3.5"
|
||||||
|
|
|
@ -188,28 +188,50 @@ impl fmt::Display for NixpkgsProblem {
|
||||||
"
|
"
|
||||||
- Because {} exists, the attribute `pkgs.{package_name}` must be defined like
|
- Because {} exists, the attribute `pkgs.{package_name}` must be defined like
|
||||||
|
|
||||||
{package_name} = callPackage {} {{ /* ... */ }}
|
{package_name} = callPackage {} {{ /* ... */ }};
|
||||||
|
|
||||||
This is however not the case: The first `callPackage` argument is the wrong path.
|
This is however not the case: The first `callPackage` argument is the wrong path.
|
||||||
It is defined in {}:{}:{} as
|
It is defined in {}:{}:{} as
|
||||||
|
|
||||||
{package_name} = callPackage {} {{ /* ... */ }}",
|
{package_name} = callPackage {} {{ /* ... */ }};",
|
||||||
structure::relative_dir_for_package(package_name).display(),
|
structure::relative_dir_for_package(package_name).display(),
|
||||||
create_path_expr(file, expected_path),
|
create_path_expr(file, expected_path),
|
||||||
file.display(), line, column,
|
file.display(), line, column,
|
||||||
create_path_expr(file, actual_path),
|
create_path_expr(file, actual_path),
|
||||||
},
|
},
|
||||||
NixpkgsProblem::NonSyntacticCallPackage { package_name, file, line, column, definition } =>
|
NixpkgsProblem::NonSyntacticCallPackage { package_name, file, line, column, definition } => {
|
||||||
write!(
|
// This is needed such multi-line definitions don't look odd
|
||||||
|
// A bit round-about, but it works and we might not need anything more complicated
|
||||||
|
let definition_indented =
|
||||||
|
// The entire code should be indented 4 spaces
|
||||||
|
textwrap::indent(
|
||||||
|
// But first we want to strip the code's natural indentation
|
||||||
|
&textwrap::dedent(
|
||||||
|
// The definition _doesn't_ include the leading spaces, but we can
|
||||||
|
// recover those from the column
|
||||||
|
&format!("{}{definition}",
|
||||||
|
" ".repeat(column - 1)),
|
||||||
|
),
|
||||||
|
" ",
|
||||||
|
);
|
||||||
|
writedoc!(
|
||||||
f,
|
f,
|
||||||
"Because {} exists, the attribute `pkgs.{package_name}` must be defined as `callPackage {} {{ ... }}`. This is however not the case: The attribute is defined in {}:{}:{} as\n\t{}",
|
"
|
||||||
|
- Because {} exists, the attribute `pkgs.{package_name}` must be defined like
|
||||||
|
|
||||||
|
{package_name} = callPackage {} {{ /* ... */ }};
|
||||||
|
|
||||||
|
This is however not the case.
|
||||||
|
It is defined in {}:{} as
|
||||||
|
|
||||||
|
{}",
|
||||||
structure::relative_dir_for_package(package_name).display(),
|
structure::relative_dir_for_package(package_name).display(),
|
||||||
structure::relative_file_for_package(package_name).display(),
|
structure::relative_file_for_package(package_name).display(),
|
||||||
file.display(),
|
file.display(),
|
||||||
line,
|
line,
|
||||||
column,
|
definition_indented,
|
||||||
definition,
|
)
|
||||||
),
|
}
|
||||||
NixpkgsProblem::NonDerivation { relative_package_file, package_name } =>
|
NixpkgsProblem::NonDerivation { relative_package_file, package_name } =>
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
|
|
|
@ -1,2 +1,8 @@
|
||||||
Because pkgs/by-name/fo/foo exists, the attribute `pkgs.foo` must be defined as `callPackage pkgs/by-name/fo/foo/package.nix { ... }`. This is however not the case: The attribute is defined in all-packages.nix:4:3 as
|
- Because pkgs/by-name/fo/foo exists, the attribute `pkgs.foo` must be defined like
|
||||||
|
|
||||||
|
foo = callPackage pkgs/by-name/fo/foo/package.nix { /* ... */ };
|
||||||
|
|
||||||
|
This is however not the case.
|
||||||
|
It is defined in all-packages.nix:4 as
|
||||||
|
|
||||||
foo = self.bar;
|
foo = self.bar;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
- Because pkgs/by-name/no/nonDerivation exists, the attribute `pkgs.nonDerivation` must be defined like
|
- Because pkgs/by-name/no/nonDerivation exists, the attribute `pkgs.nonDerivation` must be defined like
|
||||||
|
|
||||||
nonDerivation = callPackage ./pkgs/by-name/no/nonDerivation/package.nix { /* ... */ }
|
nonDerivation = callPackage ./pkgs/by-name/no/nonDerivation/package.nix { /* ... */ };
|
||||||
|
|
||||||
This is however not the case: The first `callPackage` argument is the wrong path.
|
This is however not the case: The first `callPackage` argument is the wrong path.
|
||||||
It is defined in all-packages.nix:2:3 as
|
It is defined in all-packages.nix:2:3 as
|
||||||
|
|
||||||
nonDerivation = callPackage ./someDrv.nix { /* ... */ }
|
nonDerivation = callPackage ./someDrv.nix { /* ... */ };
|
||||||
|
|
|
@ -1,2 +1,8 @@
|
||||||
Because pkgs/by-name/no/nonDerivation exists, the attribute `pkgs.nonDerivation` must be defined as `callPackage pkgs/by-name/no/nonDerivation/package.nix { ... }`. This is however not the case: The attribute is defined in all-packages.nix:2:3 as
|
- Because pkgs/by-name/no/nonDerivation exists, the attribute `pkgs.nonDerivation` must be defined like
|
||||||
|
|
||||||
|
nonDerivation = callPackage pkgs/by-name/no/nonDerivation/package.nix { /* ... */ };
|
||||||
|
|
||||||
|
This is however not the case.
|
||||||
|
It is defined in all-packages.nix:2 as
|
||||||
|
|
||||||
nonDerivation = self.someDrv;
|
nonDerivation = self.someDrv;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user