summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-01-17 13:46:04 -0500
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-04-14 15:39:20 +0900
commit9d01815b194097fb2fc56122653f06a6572cffa1 (patch)
tree92f984fb06af53ce6f63432dade5de1611938e82
parentcba95c80a09f6589eb1b7f9c2000844884576364 (diff)
downloadbuildstream-9d01815b194097fb2fc56122653f06a6572cffa1.tar.gz
testutils/runcli.py: Added cli.get_element_states()
With get_element_state(), you need to invoke BuildStream once for every element state you want to observe in a pipeline. The new get_element_states() reports a dictionary with the element state hashed by element name and is better to use if you have more than one element to observe the state of.
-rw-r--r--tests/testutils/runcli.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/testutils/runcli.py b/tests/testutils/runcli.py
index 3535e94ea..805b1192d 100644
--- a/tests/testutils/runcli.py
+++ b/tests/testutils/runcli.py
@@ -343,6 +343,9 @@ class Cli():
# Fetch an element state by name by
# invoking bst show on the project with the CLI
#
+ # If you need to get the states of multiple elements,
+ # then use get_element_states(s) instead.
+ #
def get_element_state(self, project, element_name):
result = self.run(project=project, silent=True, args=[
'show',
@@ -353,6 +356,25 @@ class Cli():
result.assert_success()
return result.output.strip()
+ # Fetch the states of elements for a given target / deps
+ #
+ # Returns a dictionary with the element names as keys
+ #
+ def get_element_states(self, project, target, deps='all'):
+ result = self.run(project=project, silent=True, args=[
+ 'show',
+ '--deps', deps,
+ '--format', '%{name}||%{state}',
+ target
+ ])
+ result.assert_success()
+ lines = result.output.splitlines()
+ states = {}
+ for line in lines:
+ split = line.split(sep='||')
+ states[split[0]] = split[1]
+ return states
+
# Fetch an element's cache key by invoking bst show
# on the project with the CLI
#