You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/08/26 07:43:26 UTC

[buildstream] 05/05: tests/frontend/show.py: Test (fatal) warnings for unaliased URLs in sources

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/bst-1/unaliased-sources
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 51908a8b6d51d8127a595430fe2a77f359bfd60e
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Sun Aug 8 14:27:27 2021 +0900

    tests/frontend/show.py: Test (fatal) warnings for unaliased URLs in sources
---
 tests/frontend/project/elements/unaliased-tar.bst |  5 +++++
 tests/frontend/show.py                            | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/tests/frontend/project/elements/unaliased-tar.bst b/tests/frontend/project/elements/unaliased-tar.bst
new file mode 100644
index 0000000..8cd2bbd
--- /dev/null
+++ b/tests/frontend/project/elements/unaliased-tar.bst
@@ -0,0 +1,5 @@
+kind: import
+
+sources:
+- kind: tar
+  url: https://unaliased-url.org/tarball.tar
diff --git a/tests/frontend/show.py b/tests/frontend/show.py
index 92fa1f5..0f3145e 100644
--- a/tests/frontend/show.py
+++ b/tests/frontend/show.py
@@ -4,6 +4,8 @@ import shutil
 import itertools
 import pytest
 from tests.testutils import cli, generate_junction
+from buildstream.exceptions import ErrorDomain
+from buildstream.types import CoreWarnings
 
 from buildstream import _yaml
 from buildstream._exceptions import ErrorDomain, LoadErrorReason
@@ -423,3 +425,19 @@ def test_strict_dependencies(cli, datafiles, target, expected_state):
     states = cli.get_element_states(project, target)
     assert states['base.bst'] == 'buildable'
     assert states[target] == expected_state
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "project"))
+@pytest.mark.parametrize("fatal", [True, False], ids=["fatal", "non-fatal"])
+def test_unaliased_url(cli, tmpdir, datafiles, fatal):
+    project = str(datafiles)
+    if fatal:
+        configure_project(project, {"fatal-warnings": [CoreWarnings.UNALIASED_URL]})
+
+    result = cli.run(project=project, silent=True, args=["show", "unaliased-tar.bst"])
+
+    if fatal:
+        result.assert_main_error(ErrorDomain.PLUGIN, CoreWarnings.UNALIASED_URL)
+    else:
+        result.assert_success()
+        assert "WARNING [unaliased-url]" in result.stderr