summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-01-13 12:00:26 +0000
committerJürg Billeter <j@bitron.ch>2020-01-13 12:00:26 +0000
commit97a86e4f94daa90badf4d5d304b8f05a303daf40 (patch)
tree9794dae93d76ac946317b0178c9af97d09200844
parent35bc43cda83b9c5638b361244575f6069ad2b544 (diff)
parentd3c3833141fcc21c05ac286b8b64c4592c1a0b7f (diff)
downloadbuildstream-97a86e4f94daa90badf4d5d304b8f05a303daf40.tar.gz
Merge branch 'juerg/batch-command-logging' into 'master'
_sandboxreapi.py: Improve batch command logging See merge request BuildStream/buildstream!1793
-rw-r--r--src/buildstream/sandbox/_sandboxreapi.py11
-rw-r--r--src/buildstream/sandbox/sandbox.py6
-rw-r--r--tests/integration/manual.py1
-rw-r--r--tests/integration/messages.py2
-rw-r--r--tests/integration/workspace.py4
5 files changed, 17 insertions, 7 deletions
diff --git a/src/buildstream/sandbox/_sandboxreapi.py b/src/buildstream/sandbox/_sandboxreapi.py
index ec31b97f1..2430fd372 100644
--- a/src/buildstream/sandbox/_sandboxreapi.py
+++ b/src/buildstream/sandbox/_sandboxreapi.py
@@ -171,8 +171,15 @@ class _SandboxREAPIBatch(_SandboxBatch):
self.main_group.execute(self)
first = self.first_command
- if first and self.sandbox.run(["sh", "-c", "-e", self.script], self.flags, cwd=first.cwd, env=first.env) != 0:
- raise SandboxCommandError("Command execution failed", collect=self.collect)
+ if first:
+ context = self.sandbox._get_context()
+ with context.messenger.timed_activity(
+ "Running commands",
+ detail=self.main_group.combined_label(),
+ element_name=self.sandbox._get_element_name(),
+ ):
+ if self.sandbox.run(["sh", "-c", "-e", self.script], self.flags, cwd=first.cwd, env=first.env) != 0:
+ raise SandboxCommandError("Command failed", collect=self.collect)
def execute_group(self, group):
group.execute_children(self)
diff --git a/src/buildstream/sandbox/sandbox.py b/src/buildstream/sandbox/sandbox.py
index f09aa03a0..e91e890bb 100644
--- a/src/buildstream/sandbox/sandbox.py
+++ b/src/buildstream/sandbox/sandbox.py
@@ -667,6 +667,9 @@ class _SandboxBatchItem:
def __init__(self, *, label=None):
self.label = label
+ def combined_label(self):
+ return self.label
+
# _SandboxBatchCommand()
#
@@ -704,6 +707,9 @@ class _SandboxBatchGroup(_SandboxBatchItem):
for item in self.children:
item.execute(batch)
+ def combined_label(self):
+ return "\n".join(item.combined_label() for item in self.children)
+
# _SandboxBatchCall()
#
diff --git a/tests/integration/manual.py b/tests/integration/manual.py
index 4e80d0dc0..c6a84b062 100644
--- a/tests/integration/manual.py
+++ b/tests/integration/manual.py
@@ -127,7 +127,6 @@ def test_manual_element_noparallel(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
-@pytest.mark.xfail(HAVE_SANDBOX == "buildbox-run", reason="Individual commands are not logged with command batching")
def test_manual_element_logging(cli, datafiles):
project = str(datafiles)
element_path = os.path.join(project, "elements")
diff --git a/tests/integration/messages.py b/tests/integration/messages.py
index 8bd56b82c..f35b778d6 100644
--- a/tests/integration/messages.py
+++ b/tests/integration/messages.py
@@ -38,7 +38,6 @@ DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
-@pytest.mark.xfail(HAVE_SANDBOX == "buildbox-run", reason="Individual commands are not logged with command batching")
def test_disable_message_lines(cli, datafiles):
project = str(datafiles)
element_path = os.path.join(project, "elements")
@@ -67,7 +66,6 @@ def test_disable_message_lines(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
-@pytest.mark.xfail(HAVE_SANDBOX == "buildbox-run", reason="Individual commands are not logged with command batching")
def test_disable_error_lines(cli, datafiles):
project = str(datafiles)
element_path = os.path.join(project, "elements")
diff --git a/tests/integration/workspace.py b/tests/integration/workspace.py
index 372db672a..776a1a1a6 100644
--- a/tests/integration/workspace.py
+++ b/tests/integration/workspace.py
@@ -342,7 +342,6 @@ def test_workspace_missing_last_successful(cli, datafiles):
# Check that we can still read failed workspace logs
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
-@pytest.mark.xfail(HAVE_SANDBOX == "buildbox-run", reason="Individual commands are not logged with command batching")
def test_workspace_failed_logs(cli, datafiles):
project = str(datafiles)
workspace = os.path.join(cli.directory, "failing_amhello")
@@ -364,4 +363,5 @@ def test_workspace_failed_logs(cli, datafiles):
# Assert that we can get the log
assert log != ""
fail_str = "FAILURE {}: Running build-commands".format(element_name)
- assert fail_str in log
+ batch_fail_str = "FAILURE {}: Running commands".format(element_name)
+ assert fail_str in log or batch_fail_str in log