tests.nixpkgs-check-by-name: More inline format! arguments
Now that the previous commit removed all the .display()'s that were previously necessary for PathBuf's, but now aren't for RelativePathBuf, we can also inline the format! arguments
This commit is contained in:
parent
5981aff212
commit
fb0a07229f
1 changed files with 76 additions and 112 deletions
|
@ -151,217 +151,184 @@ impl fmt::Display for NixpkgsProblem {
|
|||
NixpkgsProblem::ShardNonDir { relative_shard_path } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: This is a file, but it should be a directory.",
|
||||
relative_shard_path,
|
||||
"{relative_shard_path}: This is a file, but it should be a directory.",
|
||||
),
|
||||
NixpkgsProblem::InvalidShardName { relative_shard_path, shard_name } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: Invalid directory name \"{shard_name}\", must be at most 2 ASCII characters consisting of a-z, 0-9, \"-\" or \"_\".",
|
||||
relative_shard_path,
|
||||
"{relative_shard_path}: Invalid directory name \"{shard_name}\", must be at most 2 ASCII characters consisting of a-z, 0-9, \"-\" or \"_\".",
|
||||
),
|
||||
NixpkgsProblem::PackageNonDir { relative_package_dir } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: This path is a file, but it should be a directory.",
|
||||
relative_package_dir,
|
||||
"{relative_package_dir}: This path is a file, but it should be a directory.",
|
||||
),
|
||||
NixpkgsProblem::CaseSensitiveDuplicate { relative_shard_path, first, second } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: Duplicate case-sensitive package directories {first:?} and {second:?}.",
|
||||
relative_shard_path,
|
||||
"{relative_shard_path}: Duplicate case-sensitive package directories {first:?} and {second:?}.",
|
||||
),
|
||||
NixpkgsProblem::InvalidPackageName { relative_package_dir, package_name } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: Invalid package directory name \"{package_name}\", must be ASCII characters consisting of a-z, A-Z, 0-9, \"-\" or \"_\".",
|
||||
relative_package_dir,
|
||||
"{relative_package_dir}: Invalid package directory name \"{package_name}\", must be ASCII characters consisting of a-z, A-Z, 0-9, \"-\" or \"_\".",
|
||||
),
|
||||
NixpkgsProblem::IncorrectShard { relative_package_dir, correct_relative_package_dir } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: Incorrect directory location, should be {} instead.",
|
||||
relative_package_dir,
|
||||
correct_relative_package_dir,
|
||||
"{relative_package_dir}: Incorrect directory location, should be {correct_relative_package_dir} instead.",
|
||||
),
|
||||
NixpkgsProblem::PackageNixNonExistent { relative_package_dir } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: Missing required \"{PACKAGE_NIX_FILENAME}\" file.",
|
||||
relative_package_dir,
|
||||
"{relative_package_dir}: Missing required \"{PACKAGE_NIX_FILENAME}\" file.",
|
||||
),
|
||||
NixpkgsProblem::PackageNixDir { relative_package_dir } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: \"{PACKAGE_NIX_FILENAME}\" must be a file.",
|
||||
relative_package_dir,
|
||||
"{relative_package_dir}: \"{PACKAGE_NIX_FILENAME}\" must be a file.",
|
||||
),
|
||||
NixpkgsProblem::UndefinedAttr { relative_package_file, package_name } =>
|
||||
write!(
|
||||
f,
|
||||
"pkgs.{package_name}: This attribute is not defined but it should be defined automatically as {}",
|
||||
relative_package_file,
|
||||
"pkgs.{package_name}: This attribute is not defined but it should be defined automatically as {relative_package_file}",
|
||||
),
|
||||
NixpkgsProblem::EmptyArgument { package_name, file, line, column, definition } =>
|
||||
NixpkgsProblem::EmptyArgument { package_name, file, line, column, definition } => {
|
||||
let relative_package_dir = structure::relative_dir_for_package(package_name);
|
||||
let relative_package_file = structure::relative_file_for_package(package_name);
|
||||
let indented_definition = indent_definition(*column, definition.clone());
|
||||
writedoc!(
|
||||
f,
|
||||
"
|
||||
- Because {} exists, the attribute `pkgs.{package_name}` must be defined like
|
||||
- Because {relative_package_dir} exists, the attribute `pkgs.{package_name}` must be defined like
|
||||
|
||||
{package_name} = callPackage ./{} {{ /* ... */ }};
|
||||
{package_name} = callPackage ./{relative_package_file} {{ /* ... */ }};
|
||||
|
||||
However, in this PR, the second argument is empty. See the definition in {}:{}:
|
||||
However, in this PR, the second argument is empty. See the definition in {file}:{line}:
|
||||
|
||||
{}
|
||||
{indented_definition}
|
||||
|
||||
Such a definition is provided automatically and therefore not necessary. Please remove it.
|
||||
",
|
||||
structure::relative_dir_for_package(package_name),
|
||||
structure::relative_file_for_package(package_name),
|
||||
file,
|
||||
line,
|
||||
indent_definition(*column, definition.clone()),
|
||||
),
|
||||
NixpkgsProblem::NonToplevelCallPackage { package_name, file, line, column, definition } =>
|
||||
)
|
||||
}
|
||||
NixpkgsProblem::NonToplevelCallPackage { package_name, file, line, column, definition } => {
|
||||
let relative_package_dir = structure::relative_dir_for_package(package_name);
|
||||
let relative_package_file = structure::relative_file_for_package(package_name);
|
||||
let indented_definition = indent_definition(*column, definition.clone());
|
||||
writedoc!(
|
||||
f,
|
||||
"
|
||||
- Because {} exists, the attribute `pkgs.{package_name}` must be defined like
|
||||
- Because {relative_package_dir} exists, the attribute `pkgs.{package_name}` must be defined like
|
||||
|
||||
{package_name} = callPackage ./{} {{ /* ... */ }};
|
||||
{package_name} = callPackage ./{relative_package_file} {{ /* ... */ }};
|
||||
|
||||
However, in this PR, a different `callPackage` is used. See the definition in {}:{}:
|
||||
However, in this PR, a different `callPackage` is used. See the definition in {file}:{line}:
|
||||
|
||||
{}
|
||||
{indented_definition}
|
||||
",
|
||||
structure::relative_dir_for_package(package_name),
|
||||
structure::relative_file_for_package(package_name),
|
||||
file,
|
||||
line,
|
||||
indent_definition(*column, definition.clone()),
|
||||
),
|
||||
NixpkgsProblem::NonPath { package_name, file, line, column, definition } =>
|
||||
)
|
||||
}
|
||||
NixpkgsProblem::NonPath { package_name, file, line, column, definition } => {
|
||||
let relative_package_dir = structure::relative_dir_for_package(package_name);
|
||||
let relative_package_file = structure::relative_file_for_package(package_name);
|
||||
let indented_definition = indent_definition(*column, definition.clone());
|
||||
writedoc!(
|
||||
f,
|
||||
"
|
||||
- Because {} exists, the attribute `pkgs.{package_name}` must be defined like
|
||||
- Because {relative_package_dir} exists, the attribute `pkgs.{package_name}` must be defined like
|
||||
|
||||
{package_name} = callPackage ./{} {{ /* ... */ }};
|
||||
{package_name} = callPackage ./{relative_package_file} {{ /* ... */ }};
|
||||
|
||||
However, in this PR, the first `callPackage` argument is not a path. See the definition in {}:{}:
|
||||
However, in this PR, the first `callPackage` argument is not a path. See the definition in {file}:{line}:
|
||||
|
||||
{}
|
||||
{indented_definition}
|
||||
",
|
||||
structure::relative_dir_for_package(package_name),
|
||||
structure::relative_file_for_package(package_name),
|
||||
file,
|
||||
line,
|
||||
indent_definition(*column, definition.clone()),
|
||||
),
|
||||
NixpkgsProblem::WrongCallPackagePath { package_name, file, line, actual_path, expected_path } =>
|
||||
)
|
||||
}
|
||||
NixpkgsProblem::WrongCallPackagePath { package_name, file, line, actual_path, expected_path } => {
|
||||
let relative_package_dir = structure::relative_dir_for_package(package_name);
|
||||
let expected_path_expr = create_path_expr(file, expected_path);
|
||||
let actual_path_expr = create_path_expr(file, actual_path);
|
||||
writedoc! {
|
||||
f,
|
||||
"
|
||||
- Because {} exists, the attribute `pkgs.{package_name}` must be defined like
|
||||
- Because {relative_package_dir} exists, the attribute `pkgs.{package_name}` must be defined like
|
||||
|
||||
{package_name} = callPackage {} {{ /* ... */ }};
|
||||
{package_name} = callPackage {expected_path_expr} {{ /* ... */ }};
|
||||
|
||||
However, in this PR, the first `callPackage` argument is the wrong path. See the definition in {}:{}:
|
||||
However, in this PR, the first `callPackage` argument is the wrong path. See the definition in {file}:{line}:
|
||||
|
||||
{package_name} = callPackage {} {{ /* ... */ }};
|
||||
{package_name} = callPackage {actual_path_expr} {{ /* ... */ }};
|
||||
",
|
||||
structure::relative_dir_for_package(package_name),
|
||||
create_path_expr(file, expected_path),
|
||||
file, line,
|
||||
create_path_expr(file, actual_path),
|
||||
},
|
||||
}
|
||||
}
|
||||
NixpkgsProblem::NonSyntacticCallPackage { package_name, file, line, column, definition } => {
|
||||
let relative_package_dir = structure::relative_dir_for_package(package_name);
|
||||
let relative_package_file = structure::relative_file_for_package(package_name);
|
||||
let indented_definition = indent_definition(*column, definition.clone());
|
||||
writedoc!(
|
||||
f,
|
||||
"
|
||||
- Because {} exists, the attribute `pkgs.{package_name}` must be defined like
|
||||
- Because {relative_package_dir} exists, the attribute `pkgs.{package_name}` must be defined like
|
||||
|
||||
{package_name} = callPackage ./{} {{ /* ... */ }};
|
||||
{package_name} = callPackage ./{relative_package_file} {{ /* ... */ }};
|
||||
|
||||
However, in this PR, it isn't defined that way. See the definition in {}:{}
|
||||
However, in this PR, it isn't defined that way. See the definition in {file}:{line}
|
||||
|
||||
{}
|
||||
{indented_definition}
|
||||
",
|
||||
structure::relative_dir_for_package(package_name),
|
||||
structure::relative_file_for_package(package_name),
|
||||
file,
|
||||
line,
|
||||
indent_definition(*column, definition.clone()),
|
||||
)
|
||||
}
|
||||
NixpkgsProblem::NonDerivation { relative_package_file, package_name } =>
|
||||
write!(
|
||||
f,
|
||||
"pkgs.{package_name}: This attribute defined by {} is not a derivation",
|
||||
relative_package_file,
|
||||
"pkgs.{package_name}: This attribute defined by {relative_package_file} is not a derivation",
|
||||
),
|
||||
NixpkgsProblem::OutsideSymlink { relative_package_dir, subpath } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: Path {} is a symlink pointing to a path outside the directory of that package.",
|
||||
relative_package_dir,
|
||||
subpath,
|
||||
"{relative_package_dir}: Path {subpath} is a symlink pointing to a path outside the directory of that package.",
|
||||
),
|
||||
NixpkgsProblem::UnresolvableSymlink { relative_package_dir, subpath, io_error } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: Path {} is a symlink which cannot be resolved: {io_error}.",
|
||||
relative_package_dir,
|
||||
subpath,
|
||||
"{relative_package_dir}: Path {subpath} is a symlink which cannot be resolved: {io_error}.",
|
||||
),
|
||||
NixpkgsProblem::PathInterpolation { relative_package_dir, subpath, line, text } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: File {} at line {line} contains the path expression \"{}\", which is not yet supported and may point outside the directory of that package.",
|
||||
relative_package_dir,
|
||||
subpath,
|
||||
text
|
||||
"{relative_package_dir}: File {subpath} at line {line} contains the path expression \"{text}\", which is not yet supported and may point outside the directory of that package.",
|
||||
),
|
||||
NixpkgsProblem::SearchPath { relative_package_dir, subpath, line, text } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: File {} at line {line} contains the nix search path expression \"{}\" which may point outside the directory of that package.",
|
||||
relative_package_dir,
|
||||
subpath,
|
||||
text
|
||||
"{relative_package_dir}: File {subpath} at line {line} contains the nix search path expression \"{text}\" which may point outside the directory of that package.",
|
||||
),
|
||||
NixpkgsProblem::OutsidePathReference { relative_package_dir, subpath, line, text } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: File {} at line {line} contains the path expression \"{}\" which may point outside the directory of that package.",
|
||||
relative_package_dir,
|
||||
subpath,
|
||||
text,
|
||||
"{relative_package_dir}: File {subpath} at line {line} contains the path expression \"{text}\" which may point outside the directory of that package.",
|
||||
),
|
||||
NixpkgsProblem::UnresolvablePathReference { relative_package_dir, subpath, line, text, io_error } =>
|
||||
write!(
|
||||
f,
|
||||
"{}: File {} at line {line} contains the path expression \"{}\" which cannot be resolved: {io_error}.",
|
||||
relative_package_dir,
|
||||
subpath,
|
||||
text,
|
||||
"{relative_package_dir}: File {subpath} at line {line} contains the path expression \"{text}\" which cannot be resolved: {io_error}.",
|
||||
),
|
||||
NixpkgsProblem::MovedOutOfByNameEmptyArg { package_name, call_package_path, file } => {
|
||||
let call_package_arg =
|
||||
if let Some(path) = &call_package_path {
|
||||
format!("./{}", path)
|
||||
format!("./{path}")
|
||||
} else {
|
||||
"...".into()
|
||||
};
|
||||
let relative_package_file = structure::relative_file_for_package(package_name);
|
||||
writedoc!(
|
||||
f,
|
||||
"
|
||||
- Attribute `pkgs.{package_name}` was previously defined in {}, but is now manually defined as `callPackage {call_package_arg} {{ /* ... */ }}` in {}.
|
||||
- Attribute `pkgs.{package_name}` was previously defined in {relative_package_file}, but is now manually defined as `callPackage {call_package_arg} {{ /* ... */ }}` in {file}.
|
||||
Please move the package back and remove the manual `callPackage`.
|
||||
",
|
||||
structure::relative_file_for_package(package_name),
|
||||
file,
|
||||
)
|
||||
},
|
||||
NixpkgsProblem::MovedOutOfByNameNonEmptyArg { package_name, call_package_path, file } => {
|
||||
|
@ -371,16 +338,15 @@ impl fmt::Display for NixpkgsProblem {
|
|||
} else {
|
||||
"...".into()
|
||||
};
|
||||
let relative_package_file = structure::relative_file_for_package(package_name);
|
||||
// This can happen if users mistakenly assume that for custom arguments,
|
||||
// pkgs/by-name can't be used.
|
||||
writedoc!(
|
||||
f,
|
||||
"
|
||||
- Attribute `pkgs.{package_name}` was previously defined in {}, but is now manually defined as `callPackage {call_package_arg} {{ ... }}` in {}.
|
||||
- Attribute `pkgs.{package_name}` was previously defined in {relative_package_file}, but is now manually defined as `callPackage {call_package_arg} {{ ... }}` in {file}.
|
||||
While the manual `callPackage` is still needed, it's not necessary to move the package files.
|
||||
",
|
||||
structure::relative_file_for_package(package_name),
|
||||
file,
|
||||
)
|
||||
},
|
||||
NixpkgsProblem::NewPackageNotUsingByNameEmptyArg { package_name, call_package_path, file } => {
|
||||
|
@ -390,16 +356,15 @@ impl fmt::Display for NixpkgsProblem {
|
|||
} else {
|
||||
"...".into()
|
||||
};
|
||||
let relative_package_file = structure::relative_file_for_package(package_name);
|
||||
writedoc!(
|
||||
f,
|
||||
"
|
||||
- Attribute `pkgs.{package_name}` is a new top-level package using `pkgs.callPackage {call_package_arg} {{ /* ... */ }}`.
|
||||
Please define it in {} instead.
|
||||
Please define it in {relative_package_file} instead.
|
||||
See `pkgs/by-name/README.md` for more details.
|
||||
Since the second `callPackage` argument is `{{ }}`, no manual `callPackage` in {} is needed anymore.
|
||||
Since the second `callPackage` argument is `{{ }}`, no manual `callPackage` in {file} is needed anymore.
|
||||
",
|
||||
structure::relative_file_for_package(package_name),
|
||||
file,
|
||||
)
|
||||
},
|
||||
NixpkgsProblem::NewPackageNotUsingByNameNonEmptyArg { package_name, call_package_path, file } => {
|
||||
|
@ -409,16 +374,15 @@ impl fmt::Display for NixpkgsProblem {
|
|||
} else {
|
||||
"...".into()
|
||||
};
|
||||
let relative_package_file = structure::relative_file_for_package(package_name);
|
||||
writedoc!(
|
||||
f,
|
||||
"
|
||||
- Attribute `pkgs.{package_name}` is a new top-level package using `pkgs.callPackage {call_package_arg} {{ /* ... */ }}`.
|
||||
Please define it in {} instead.
|
||||
Please define it in {relative_package_file} instead.
|
||||
See `pkgs/by-name/README.md` for more details.
|
||||
Since the second `callPackage` argument is not `{{ }}`, the manual `callPackage` in {} is still needed.
|
||||
Since the second `callPackage` argument is not `{{ }}`, the manual `callPackage` in {file} is still needed.
|
||||
",
|
||||
structure::relative_file_for_package(package_name),
|
||||
file,
|
||||
)
|
||||
},
|
||||
NixpkgsProblem::InternalCallPackageUsed { attr_name } =>
|
||||
|
|
Loading…
Reference in a new issue