summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildtool/profile/profile.cpp24
-rw-r--r--src/buildtool/profile/profile.hpp2
-rw-r--r--test/end-to-end/profile/basic.sh13
3 files changed, 38 insertions, 1 deletions
diff --git a/src/buildtool/profile/profile.cpp b/src/buildtool/profile/profile.cpp
index 66ea50d6..6d1cc34d 100644
--- a/src/buildtool/profile/profile.cpp
+++ b/src/buildtool/profile/profile.cpp
@@ -34,6 +34,12 @@ void Profile::Write(int exit_code) {
entry["duration"] = v.duration;
}
entry["artifacts"] = v.artifacts;
+ if (v.out) {
+ entry["stdout"] = *v.out;
+ }
+ if (v.err) {
+ entry["stderr"] = *v.err;
+ }
actions[k] = entry;
}
profile_["actions"] = actions;
@@ -57,16 +63,34 @@ void Profile::NoteActionCompleted(std::string const& id,
IExecutionResponse::Ptr const& response) {
std::unique_lock lock{mutex_};
auto artifacts = response->Artifacts();
+ std::optional<std::string> out = std::nullopt;
+ std::optional<std::string> err = std::nullopt;
+ if (response->HasStdOut()) {
+ auto action_out = response->StdOutDigest();
+ if (action_out) {
+ out = action_out->hash();
+ }
+ }
+ if (response->HasStdErr()) {
+ auto action_err = response->StdErrDigest();
+ if (action_err) {
+ err = action_err->hash();
+ }
+ }
if (not artifacts) {
actions_[id] = ActionData{
.cached = response->IsCached(),
.duration = response->ExecutionDuration(),
+ .out = out,
+ .err = err,
.artifacts = std::unordered_map<std::string, std::string>()};
}
else {
actions_[id] = ActionData{
.cached = response->IsCached(),
.duration = response->ExecutionDuration(),
+ .out = out,
+ .err = err,
.artifacts = std::unordered_map<std::string, std::string>(
(*artifacts)->size())};
for (auto const& [k, v] : **artifacts) {
diff --git a/src/buildtool/profile/profile.hpp b/src/buildtool/profile/profile.hpp
index 7e03b0ae..71511245 100644
--- a/src/buildtool/profile/profile.hpp
+++ b/src/buildtool/profile/profile.hpp
@@ -42,6 +42,8 @@ class Profile {
struct ActionData {
bool cached;
double duration;
+ std::optional<std::string> out;
+ std::optional<std::string> err;
std::unordered_map<std::string, std::string> artifacts;
};
diff --git a/test/end-to-end/profile/basic.sh b/test/end-to-end/profile/basic.sh
index 70ba2b5a..61e0ddf5 100644
--- a/test/end-to-end/profile/basic.sh
+++ b/test/end-to-end/profile/basic.sh
@@ -53,7 +53,11 @@ cat > TARGETS <<'EOF'
{ "type": "generic"
, "deps": ["data.txt"]
, "outs": ["upper.txt"]
- , "cmds": ["cat data.txt | tr a-z A-Z > upper.txt"]
+ , "cmds":
+ [ "cat data.txt | tr a-z A-Z > upper.txt"
+ , "echo StdOuT"
+ , "echo StdErR 1>&2"
+ ]
}
}
EOF
@@ -73,6 +77,13 @@ cat "${PROFILE}"
OUT_ARTIFACT=$(jq -r '.actions | .[] | .artifacts."upper.txt"' "${PROFILE}")
"${JUST_MR}" --rc "${RC}" install-cas -o "${OUT}/upper.txt" "${OUT_ARTIFACT}" 2>&1
grep BLABLABLA "${OUT}/upper.txt"
+
+STDOUT=$(jq -r '.actions | .[] | .stdout' "${PROFILE}")
+STDERR=$(jq -r '.actions | .[] | .stderr' "${PROFILE}")
+"${JUST_MR}" --rc "${RC}" install-cas -o "${OUT}/stdout" "${STDOUT}" 2>&1
+"${JUST_MR}" --rc "${RC}" install-cas -o "${OUT}/stderr" "${STDERR}" 2>&1
+grep StdOuT "${OUT}/stdout"
+grep StdErR "${OUT}/stderr"
echo
# Build again, this time the action should be cached;