ci: Fix TypoError error when traces in traces.yml is an empty list
authorPablo Saavedra <psaavedra@igalia.com>
Wed, 13 May 2020 14:44:30 +0000 (16:44 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 18 May 2020 17:27:42 +0000 (17:27 +0000)
v2: Python's nitpick (Andres)

In case of an empty list of traces, the results.yml will contain an empty
curly braces. In YAML, an associative array can also be specified by text
enclosed in curly braces ({}),

This commit also adds the corresponding test to check the behavior of
tracie when no traces are added in the traces.yml file.

Signed-off-by: Pablo Saavedra <psaavedra@igalia.com>
Reviewed-by: Andres Gomez <agomez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4916>

.gitlab-ci/tracie/tests/test.py
.gitlab-ci/tracie/tracie.py

index 40b1a45..21264cc 100644 (file)
@@ -163,6 +163,17 @@ def test_tracie_only_traces_without_checksum():
     assert run_tracie()
 
 
+def test_tracie_with_no_traces():
+    filename = "./tests/traces.yml"
+    content = 'traces:'
+    write_to(content, filename)
+    assert run_tracie()
+    expectations = [
+        "{}",
+    ]
+    assert check_results_yaml_content(RESULTS_YAML, expectations)
+
+
 def test_tracie_fails_on_dump_image_error():
     # "invalid" should fail to parse as rgba and
     # cause an error
index d2c0d73..854ba8a 100644 (file)
@@ -149,7 +149,7 @@ def run(filename, device_name):
         project_url = None
         commit_id = None
 
-    traces = y['traces']
+    traces = y['traces'] or []
     all_ok = True
     results = {}
     for trace in traces: