summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRebecca Grayson <becky.grayson1@hotmail.co.uk>2019-08-20 09:55:54 +0100
committerRebecca Grayson <becky.grayson1@hotmail.co.uk>2019-08-29 14:54:37 +0100
commit20a8f9e812c9f7dc2ad9c44325afcc1732c1de52 (patch)
treebba12beb9853522b0eb6c98000e84c5570b342af /tests
parentb794f058c0ff2709ae6a382fff5744a98da97c76 (diff)
downloadbuildstream-20a8f9e812c9f7dc2ad9c44325afcc1732c1de52.tar.gz
Addition of --out option to bst artifact log:becky/artifact_log_file_option
A --out option has been added, allowing an artifact log to be written to a logfile. This is particularly useful when more than one artifact's log is wanting to be read; It will write a file for each log. A test and NEWS entry have also been added.
Diffstat (limited to 'tests')
-rw-r--r--tests/frontend/artifact.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/tests/frontend/artifact.py b/tests/frontend/artifact.py
index cbc9ab022..9ad03909e 100644
--- a/tests/frontend/artifact.py
+++ b/tests/frontend/artifact.py
@@ -69,8 +69,7 @@ def test_artifact_log(cli, datafiles):
# Read the log via glob
result = cli.run(project=project, args=['artifact', 'log', 'test/target/*'])
assert result.exit_code == 0
- # The artifact is cached under both a strong key and a weak key
- assert (log + log) == result.output
+ assert log == result.output
@pytest.mark.datafiles(DATA_DIR)
@@ -140,6 +139,38 @@ def test_artifact_list_exact_contents_glob(cli, datafiles):
assert artifact in result.output
+@pytest.mark.datafiles(DATA_DIR)
+def test_artifact_log_files(cli, datafiles):
+ project = str(datafiles)
+
+ # Ensure we have an artifact to read
+ result = cli.run(project=project, args=['build', 'target.bst'])
+ assert result.exit_code == 0
+
+ logfiles = os.path.join(project, "logfiles")
+ target = os.path.join(project, logfiles, "target.log")
+ import_bin = os.path.join(project, logfiles, "import-bin.log")
+ # Ensure the logfile doesn't exist before the command is run
+ assert not os.path.exists(logfiles)
+ assert not os.path.exists(target)
+ assert not os.path.exists(import_bin)
+
+ # Run the command and ensure the file now exists
+ result = cli.run(project=project, args=['artifact', 'log', '--out', logfiles, 'target.bst', 'import-bin.bst'])
+ assert result.exit_code == 0
+ assert os.path.exists(logfiles)
+ assert os.path.exists(target)
+ assert os.path.exists(import_bin)
+
+ # Ensure the file contains the logs by checking for the LOG line
+ with open(target, 'r') as f:
+ data = f.read()
+ assert "LOG target.bst" in data
+ with open(import_bin, 'r') as f:
+ data = f.read()
+ assert "LOG import-bin.bst" in data
+
+
# Test that we can delete the artifact of the element which corresponds
# to the current project state
@pytest.mark.datafiles(DATA_DIR)