fix recurseIntoAttrs handling
This commit is contained in:
parent
f6890b93e8
commit
cb8126538f
|
@ -297,8 +297,8 @@ static void worker(EvalState &state, Bindings &autoArgs, AutoCloseFD &to,
|
|||
auto v = state.allocValue();
|
||||
state.autoCallFunction(autoArgs, *vTmp, *v);
|
||||
|
||||
if (v->type() == nAttrs) {
|
||||
if (auto drvInfo = getDerivation(state, *v, false)) {
|
||||
|
||||
auto drv = Drv(state, *drvInfo);
|
||||
reply.update(drv);
|
||||
|
||||
|
@ -310,29 +310,29 @@ static void worker(EvalState &state, Bindings &autoArgs, AutoCloseFD &to,
|
|||
std::string(baseNameOf(drv.drvPath));
|
||||
if (!pathExists(root)) {
|
||||
auto localStore =
|
||||
state.store.dynamic_pointer_cast<LocalFSStore>();
|
||||
state.store
|
||||
.dynamic_pointer_cast<LocalFSStore>();
|
||||
auto storePath =
|
||||
localStore->parseStorePath(drv.drvPath);
|
||||
localStore->addPermRoot(storePath, root);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if (v->type() == nAttrs) {
|
||||
} else {
|
||||
auto attrs = nlohmann::json::array();
|
||||
bool recurse =
|
||||
path.size() == 0; // Dont require `recurseForDerivations =
|
||||
// true;` for top-level attrset
|
||||
path.size() == 0; // Dont require `recurseForDerivations
|
||||
// = true;` for top-level attrset
|
||||
|
||||
for (auto &i : v->attrs->lexicographicOrder(state.symbols)) {
|
||||
for (auto &i :
|
||||
v->attrs->lexicographicOrder(state.symbols)) {
|
||||
const std::string &name = state.symbols[i->name];
|
||||
attrs.push_back(name);
|
||||
|
||||
if (name == "recurseForDerivations") {
|
||||
auto attrv =
|
||||
v->attrs->get(state.sRecurseForDerivations);
|
||||
recurse = state.forceBool(*attrv->value, attrv->pos);
|
||||
recurse =
|
||||
state.forceBool(*attrv->value, attrv->pos);
|
||||
}
|
||||
}
|
||||
if (recurse)
|
||||
|
@ -340,17 +340,12 @@ static void worker(EvalState &state, Bindings &autoArgs, AutoCloseFD &to,
|
|||
else
|
||||
reply["attrs"] = nlohmann::json::array();
|
||||
}
|
||||
|
||||
else if (v->type() == nNull)
|
||||
;
|
||||
|
||||
else
|
||||
throw TypeError("attribute '%s' is %s, which is not supported",
|
||||
path, showType(*v));
|
||||
|
||||
} else {
|
||||
// We ignore everything that cannot be build
|
||||
reply["attrs"] = nlohmann::json::array();
|
||||
}
|
||||
} catch (EvalError &e) {
|
||||
auto err = e.info();
|
||||
|
||||
std::ostringstream oss;
|
||||
showErrorInfo(oss, err, loggerSettings.showTrace.get());
|
||||
auto msg = oss.str();
|
||||
|
|
|
@ -23,7 +23,7 @@ def common_test(extra_args: List[str]) -> List[Dict[str, Any]]:
|
|||
)
|
||||
|
||||
results = [json.loads(r) for r in res.stdout.split("\n") if r]
|
||||
assert len(results) == 5
|
||||
assert len(results) == 4
|
||||
|
||||
built_job = results[0]
|
||||
assert built_job["attr"] == "builtJob"
|
||||
|
@ -40,10 +40,7 @@ def common_test(extra_args: List[str]) -> List[Dict[str, Any]]:
|
|||
assert recurse_drv["attr"] == "recurse.drvB"
|
||||
assert recurse_drv["name"] == "drvB"
|
||||
|
||||
recurse_recurse_bool = results[3]
|
||||
assert "error" in recurse_recurse_bool
|
||||
|
||||
substituted_job = results[4]
|
||||
substituted_job = results[3]
|
||||
assert substituted_job["attr"] == "substitutedJob"
|
||||
assert substituted_job["name"].startswith("hello-")
|
||||
assert substituted_job["meta"]["broken"] is False
|
||||
|
|
Loading…
Reference in a new issue