fix recurseIntoAttrs handling
This commit is contained in:
parent
f6890b93e8
commit
cb8126538f
|
@ -297,60 +297,55 @@ static void worker(EvalState &state, Bindings &autoArgs, AutoCloseFD &to,
|
||||||
auto v = state.allocValue();
|
auto v = state.allocValue();
|
||||||
state.autoCallFunction(autoArgs, *vTmp, *v);
|
state.autoCallFunction(autoArgs, *vTmp, *v);
|
||||||
|
|
||||||
if (auto drvInfo = getDerivation(state, *v, false)) {
|
if (v->type() == nAttrs) {
|
||||||
|
if (auto drvInfo = getDerivation(state, *v, false)) {
|
||||||
|
auto drv = Drv(state, *drvInfo);
|
||||||
|
reply.update(drv);
|
||||||
|
|
||||||
auto drv = Drv(state, *drvInfo);
|
/* Register the derivation as a GC root. !!! This
|
||||||
reply.update(drv);
|
registers roots for jobs that we may have already
|
||||||
|
done. */
|
||||||
/* Register the derivation as a GC root. !!! This
|
if (myArgs.gcRootsDir != "") {
|
||||||
registers roots for jobs that we may have already
|
Path root = myArgs.gcRootsDir + "/" +
|
||||||
done. */
|
std::string(baseNameOf(drv.drvPath));
|
||||||
if (myArgs.gcRootsDir != "") {
|
if (!pathExists(root)) {
|
||||||
Path root = myArgs.gcRootsDir + "/" +
|
auto localStore =
|
||||||
std::string(baseNameOf(drv.drvPath));
|
state.store
|
||||||
if (!pathExists(root)) {
|
.dynamic_pointer_cast<LocalFSStore>();
|
||||||
auto localStore =
|
auto storePath =
|
||||||
state.store.dynamic_pointer_cast<LocalFSStore>();
|
localStore->parseStorePath(drv.drvPath);
|
||||||
auto storePath =
|
localStore->addPermRoot(storePath, root);
|
||||||
localStore->parseStorePath(drv.drvPath);
|
}
|
||||||
localStore->addPermRoot(storePath, root);
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
auto attrs = nlohmann::json::array();
|
||||||
|
bool recurse =
|
||||||
|
path.size() == 0; // Dont require `recurseForDerivations
|
||||||
|
// = true;` for top-level attrset
|
||||||
|
|
||||||
}
|
for (auto &i :
|
||||||
|
v->attrs->lexicographicOrder(state.symbols)) {
|
||||||
|
const std::string &name = state.symbols[i->name];
|
||||||
|
attrs.push_back(name);
|
||||||
|
|
||||||
else if (v->type() == nAttrs) {
|
if (name == "recurseForDerivations") {
|
||||||
auto attrs = nlohmann::json::array();
|
auto attrv =
|
||||||
bool recurse =
|
v->attrs->get(state.sRecurseForDerivations);
|
||||||
path.size() == 0; // Dont require `recurseForDerivations =
|
recurse =
|
||||||
// true;` for top-level attrset
|
state.forceBool(*attrv->value, attrv->pos);
|
||||||
|
}
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
if (recurse)
|
||||||
|
reply["attrs"] = std::move(attrs);
|
||||||
|
else
|
||||||
|
reply["attrs"] = nlohmann::json::array();
|
||||||
}
|
}
|
||||||
if (recurse)
|
} else {
|
||||||
reply["attrs"] = std::move(attrs);
|
// We ignore everything that cannot be build
|
||||||
else
|
reply["attrs"] = nlohmann::json::array();
|
||||||
reply["attrs"] = nlohmann::json::array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (v->type() == nNull)
|
|
||||||
;
|
|
||||||
|
|
||||||
else
|
|
||||||
throw TypeError("attribute '%s' is %s, which is not supported",
|
|
||||||
path, showType(*v));
|
|
||||||
|
|
||||||
} catch (EvalError &e) {
|
} catch (EvalError &e) {
|
||||||
auto err = e.info();
|
auto err = e.info();
|
||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
showErrorInfo(oss, err, loggerSettings.showTrace.get());
|
showErrorInfo(oss, err, loggerSettings.showTrace.get());
|
||||||
auto msg = oss.str();
|
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]
|
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]
|
built_job = results[0]
|
||||||
assert built_job["attr"] == "builtJob"
|
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["attr"] == "recurse.drvB"
|
||||||
assert recurse_drv["name"] == "drvB"
|
assert recurse_drv["name"] == "drvB"
|
||||||
|
|
||||||
recurse_recurse_bool = results[3]
|
substituted_job = results[3]
|
||||||
assert "error" in recurse_recurse_bool
|
|
||||||
|
|
||||||
substituted_job = results[4]
|
|
||||||
assert substituted_job["attr"] == "substitutedJob"
|
assert substituted_job["attr"] == "substitutedJob"
|
||||||
assert substituted_job["name"].startswith("hello-")
|
assert substituted_job["name"].startswith("hello-")
|
||||||
assert substituted_job["meta"]["broken"] is False
|
assert substituted_job["meta"]["broken"] is False
|
||||||
|
|
Loading…
Reference in a new issue