From 4c92586dad14eba9b9ea64cc8c6f68d6c59eed86 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Thu, 11 Apr 2024 15:31:09 +0200 Subject: Error reporting on action failure: give short target name ... as this is the only thing the user cares about when trying to investigate why that action failed. --- .../execution_engine/executor/executor.hpp | 2 +- test/end-to-end/actions/error-reporting.sh | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp index 53a0f6da..046a6a4c 100644 --- a/src/buildtool/execution_engine/executor/executor.hpp +++ b/src/buildtool/execution_engine/executor/executor.hpp @@ -618,7 +618,7 @@ class ExecutorImpl { msg << "\nrequested by"; for (auto const& origin : origins->second) { msg << "\n - "; - msg << origin.first.ToString(); + msg << origin.first.ToShortString(); msg << "#"; msg << origin.second; } diff --git a/test/end-to-end/actions/error-reporting.sh b/test/end-to-end/actions/error-reporting.sh index 7518fe53..8705e6ec 100644 --- a/test/end-to-end/actions/error-reporting.sh +++ b/test/end-to-end/actions/error-reporting.sh @@ -22,12 +22,22 @@ readonly JUST="${ROOT}/bin/tool-under-test" readonly LOCAL_TOOLS="${TMPDIR}/tools" touch ROOT -cat > TARGETS < TARGETS <<'EOF' { "theTargetCausingTheFailure": { "type": "generic" + , "arguments_config": ["foo", "bar"] , "outs": ["a.txt"] , "cmds": - ["echo -n stdout-of-; echo failing-target", "touch a.txt", "exit 42"] + [ { "type": "join" + , "$1": + [ "echo -n stdout-of-; echo failing-target-" + , {"type": "var", "name": "foo", "default": ""} + , {"type": "var", "name": "bar", "default": ""} + ] + } + , "touch a.txt" + , "exit 42" + ] } } EOF @@ -39,6 +49,7 @@ echo mkdir -p "${OUT}" "${JUST}" build --local-build-root "${LBR}" \ -f "${OUT}/log" --log-limit 0 \ + -D '{"foo": "FOO", "irrelevant": "abc"}' \ 2>&1 && exit 1 || : # The exit code should be reported @@ -47,12 +58,17 @@ grep 42 "${OUT}/log" # The target name should be reported grep theTargetCausingTheFailure "${OUT}/log" +# The pruned effective configuration should be reported in canonical +# compact form. +grep '{"foo":"FOO"}' "${OUT}/log" + # At default level we should also find stdout of the target echo "${JUST}" build --local-build-root "${LBR}" \ -f "${OUT}/log.default" \ + -D '{"foo": "FOO", "irrelevant": "abc"}' \ 2>&1 && exit 1 || : -grep stdout-of-failing-target "${OUT}/log.default" +grep stdout-of-failing-target-FOO "${OUT}/log.default" echo OK -- cgit v1.2.3