apply treefmt

This commit is contained in:
Jörg Thalheim 2023-12-16 11:44:02 +01:00
parent b4f7eb3c77
commit 093b8ce5cc
2 changed files with 16 additions and 14 deletions

View file

@ -113,13 +113,14 @@ void handleBrokenWorkerPipe(Proc &proc, std::string_view msg) {
int rc = waitpid(pid, &status, WNOHANG);
if (rc == 0) {
kill(pid, SIGKILL);
throw Error(
"BUG: while %s, worker pipe got closed but evaluation worker still running?",
throw Error("BUG: while %s, worker pipe got closed but evaluation "
"worker still running?",
msg);
} else if (rc == -1) {
kill(pid, SIGKILL);
throw Error("BUG: while %s, waitpid for evaluation worker failed: %s",
msg, strerror(errno));
throw Error(
"BUG: while %s, waitpid for evaluation worker failed: %s", msg,
strerror(errno));
} else {
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) == 1) {
@ -128,12 +129,12 @@ void handleBrokenWorkerPipe(Proc &proc, std::string_view msg) {
"(possibly an infinite recursion)",
msg);
}
throw Error("while %s, evaluation worker exited with %d",
msg, WEXITSTATUS(status));
throw Error("while %s, evaluation worker exited with %d", msg,
WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
if (WTERMSIG(status) == SIGKILL) {
throw Error(
"while %s, evaluation worker got killed by SIGKILL, maybe "
throw Error("while %s, evaluation worker got killed by "
"SIGKILL, maybe "
"memory limit reached?",
msg);
}
@ -147,7 +148,7 @@ void handleBrokenWorkerPipe(Proc &proc, std::string_view msg) {
std::string joinAttrPath(json &attrPath) {
std::string joined;
for (auto& element : attrPath) {
for (auto &element : attrPath) {
if (!joined.empty()) {
joined += '.';
}
@ -220,7 +221,8 @@ void collector(Sync<State> &state_, std::condition_variable &wakeup) {
/* Wait for the response. */
auto respString = fromReader->readLine();
if (respString.empty()) {
auto msg = "reading result for attrPath '" + joinAttrPath(attrPath) + "'";
auto msg = "reading result for attrPath '" +
joinAttrPath(attrPath) + "'";
handleBrokenWorkerPipe(*proc.get(), msg);
}
json response;

View file

@ -116,5 +116,5 @@ def test_recursion_error() -> None:
)
assert res.returncode == 1
print(res.stderr)
assert 'packageWithInfiniteRecursion' in res.stderr
assert "packageWithInfiniteRecursion" in res.stderr
assert "possible infinite recursion" in res.stderr