forked from lix-project/nix-eval-jobs
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();
|
auto v = state.allocValue();
|
||||||
state.autoCallFunction(autoArgs, *vTmp, *v);
|
state.autoCallFunction(autoArgs, *vTmp, *v);
|
||||||
|
|
||||||
|
if (v->type() == nAttrs) {
|
||||||
if (auto drvInfo = getDerivation(state, *v, false)) {
|
if (auto drvInfo = getDerivation(state, *v, false)) {
|
||||||
|
|
||||||
auto drv = Drv(state, *drvInfo);
|
auto drv = Drv(state, *drvInfo);
|
||||||
reply.update(drv);
|
reply.update(drv);
|
||||||
|
|
||||||
|
@ -310,29 +310,29 @@ static void worker(EvalState &state, Bindings &autoArgs, AutoCloseFD &to,
|
||||||
std::string(baseNameOf(drv.drvPath));
|
std::string(baseNameOf(drv.drvPath));
|
||||||
if (!pathExists(root)) {
|
if (!pathExists(root)) {
|
||||||
auto localStore =
|
auto localStore =
|
||||||
state.store.dynamic_pointer_cast<LocalFSStore>();
|
state.store
|
||||||
|
.dynamic_pointer_cast<LocalFSStore>();
|
||||||
auto storePath =
|
auto storePath =
|
||||||
localStore->parseStorePath(drv.drvPath);
|
localStore->parseStorePath(drv.drvPath);
|
||||||
localStore->addPermRoot(storePath, root);
|
localStore->addPermRoot(storePath, root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
else if (v->type() == nAttrs) {
|
|
||||||
auto attrs = nlohmann::json::array();
|
auto attrs = nlohmann::json::array();
|
||||||
bool recurse =
|
bool recurse =
|
||||||
path.size() == 0; // Dont require `recurseForDerivations =
|
path.size() == 0; // Dont require `recurseForDerivations
|
||||||
// true;` for top-level attrset
|
// = 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];
|
const std::string &name = state.symbols[i->name];
|
||||||
attrs.push_back(name);
|
attrs.push_back(name);
|
||||||
|
|
||||||
if (name == "recurseForDerivations") {
|
if (name == "recurseForDerivations") {
|
||||||
auto attrv =
|
auto attrv =
|
||||||
v->attrs->get(state.sRecurseForDerivations);
|
v->attrs->get(state.sRecurseForDerivations);
|
||||||
recurse = state.forceBool(*attrv->value, attrv->pos);
|
recurse =
|
||||||
|
state.forceBool(*attrv->value, attrv->pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (recurse)
|
if (recurse)
|
||||||
|
@ -340,17 +340,12 @@ static void worker(EvalState &state, Bindings &autoArgs, AutoCloseFD &to,
|
||||||
else
|
else
|
||||||
reply["attrs"] = nlohmann::json::array();
|
reply["attrs"] = nlohmann::json::array();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
else if (v->type() == nNull)
|
// We ignore everything that cannot be build
|
||||||
;
|
reply["attrs"] = nlohmann::json::array();
|
||||||
|
}
|
||||||
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