mirror of
https://github.com/NixOS/nix
synced 2025-07-07 06:01:48 +02:00
Fix tests
This commit is contained in:
parent
3621d0769d
commit
3522978772
2 changed files with 16 additions and 11 deletions
|
@ -2213,11 +2213,16 @@ StorePath EvalState::copyPathToStore(PathSet & context, const SourcePath & path)
|
|||
|
||||
SourcePath EvalState::coerceToPath(const PosIdx pos, Value & v, PathSet & context, std::string_view errorCtx)
|
||||
{
|
||||
forceValue(v, pos);
|
||||
try {
|
||||
forceValue(v, pos);
|
||||
|
||||
if (v.type() == nString) {
|
||||
copyContext(v, context);
|
||||
return decodePath(v.str(), pos);
|
||||
if (v.type() == nString) {
|
||||
copyContext(v, context);
|
||||
return decodePath(v.str(), pos);
|
||||
}
|
||||
} catch (Error & e) {
|
||||
e.addTrace(positions[pos], errorCtx);
|
||||
throw;
|
||||
}
|
||||
|
||||
if (v.type() == nPath)
|
||||
|
|
|
@ -295,7 +295,7 @@ namespace nix {
|
|||
TEST_F(ErrorTraceTest, toPath) {
|
||||
ASSERT_TRACE2("toPath []",
|
||||
TypeError,
|
||||
hintfmt("cannot coerce %s to a string", "a list"),
|
||||
hintfmt("cannot coerce %s to a path", "a list"),
|
||||
hintfmt("while evaluating the first argument passed to builtins.toPath"));
|
||||
|
||||
ASSERT_TRACE2("toPath \"foo\"",
|
||||
|
@ -309,8 +309,8 @@ namespace nix {
|
|||
TEST_F(ErrorTraceTest, storePath) {
|
||||
ASSERT_TRACE2("storePath true",
|
||||
TypeError,
|
||||
hintfmt("cannot coerce %s to a string", "a Boolean"),
|
||||
hintfmt("while evaluating the first argument passed to builtins.storePath"));
|
||||
hintfmt("cannot coerce %s to a path", "a Boolean"),
|
||||
hintfmt("while evaluating the first argument passed to 'builtins.storePath'"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ namespace nix {
|
|||
TEST_F(ErrorTraceTest, pathExists) {
|
||||
ASSERT_TRACE2("pathExists []",
|
||||
TypeError,
|
||||
hintfmt("cannot coerce %s to a string", "a list"),
|
||||
hintfmt("cannot coerce %s to a path", "a list"),
|
||||
hintfmt("while realising the context of a path"));
|
||||
|
||||
ASSERT_TRACE2("pathExists \"zorglub\"",
|
||||
|
@ -377,13 +377,13 @@ namespace nix {
|
|||
TEST_F(ErrorTraceTest, filterSource) {
|
||||
ASSERT_TRACE2("filterSource [] []",
|
||||
TypeError,
|
||||
hintfmt("cannot coerce %s to a string", "a list"),
|
||||
hintfmt("while evaluating the second argument (the path to filter) passed to builtins.filterSource"));
|
||||
hintfmt("cannot coerce %s to a path", "a list"),
|
||||
hintfmt("while evaluating the second argument (the path to filter) passed to 'builtins.filterSource'"));
|
||||
|
||||
ASSERT_TRACE2("filterSource [] \"foo\"",
|
||||
EvalError,
|
||||
hintfmt("string '%s' doesn't represent an absolute path", "foo"),
|
||||
hintfmt("while evaluating the second argument (the path to filter) passed to builtins.filterSource"));
|
||||
hintfmt("while evaluating the second argument (the path to filter) passed to 'builtins.filterSource'"));
|
||||
|
||||
ASSERT_TRACE2("filterSource [] ./.",
|
||||
TypeError,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue