1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 15:48:00 +02:00
This commit is contained in:
Shahar "Dawn" Or 2025-06-13 05:06:44 +00:00 committed by GitHub
commit 8647f73d3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 54 additions and 0 deletions

View file

@ -4710,6 +4710,16 @@ static RegisterPrimOp primop_splitVersion({
.fun = prim_splitVersion,
});
static void prim_testThrowErrorMaybe(EvalState & state, const PosIdx pos, Value * * args, Value & v)
{
if (getEnv("_NIX_TEST_DO_THROW_ERROR") == "1") {
state.error<EvalError>("this is a dummy error").atPos(pos).debugThrow();
} else {
state.forceValue(*args[0], pos);
v = *args[0];
}
}
/*************************************************************
* Primop registration
@ -4933,6 +4943,16 @@ void EvalState::createBaseEnv(const EvalSettings & evalSettings)
.fun = settings.traceVerbose ? prim_trace : prim_second,
});
if (getEnv("_NIX_TEST_PRIMOPS") == "1") {
addPrimOp({
.name = "__testThrowErrorMaybe",
.args = { "e" },
.arity = 1,
.doc = "throw dummy error if _NIX_TEST_DO_THROW_ERROR == 1, return arg otherwise",
.fun = prim_testThrowErrorMaybe
});
}
/* Add a value containing the current Nix expression search path. */
auto list = buildList(lookupPath.elements.size());
for (const auto & [n, i] : enumerate(lookupPath.elements)) {