This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch tristan/source-info-fatal-warning in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit dcac0a1b656bc202c864ba976c98bd7b9d181eb6 Author: Tristan van Berkom <[email protected]> AuthorDate: Mon Jun 2 18:10:25 2025 +0900 tests/frontend/show.py: Test unimplemented collect_source_info() This elaborates on the unimplemented test case to check behavior of fatal vs non-fatal warnings. --- tests/frontend/show.py | 31 +++++++++++++++------- .../fatal}/elements/unimplemented.bst | 0 .../fatal}/plugins/unimplemented.py | 0 .../source-info-unimplemented/fatal/project.conf | 13 +++++++++ .../non-fatal}/elements/unimplemented.bst | 0 .../non-fatal}/plugins/unimplemented.py | 0 .../non-fatal/project.conf | 10 +++++++ 7 files changed, 44 insertions(+), 10 deletions(-) diff --git a/tests/frontend/show.py b/tests/frontend/show.py index f30b1cb88..833a7addf 100644 --- a/tests/frontend/show.py +++ b/tests/frontend/show.py @@ -695,17 +695,28 @@ def test_source_info_extra_data(cli, datafiles): # Test what happens when encountering a source that doesn't implement collect_source_info() # [email protected](os.path.join(DATA_DIR, "source-info")) -def test_source_info_unimplemented(cli, datafiles): - project = str(datafiles) [email protected](os.path.join(DATA_DIR, "source-info-unimplemented")) [email protected]( + "subdir, expect_fatal", + [ + ("non-fatal", False), + ("fatal", True), + ], + ids=["non-fatal", "fatal"], +) +def test_source_info_unimplemented(cli, datafiles, subdir, expect_fatal): + project = os.path.join(str(datafiles), subdir) result = cli.run(project=project, silent=True, args=["show", "--format", "%{source-info}", "unimplemented.bst"]) - result.assert_success() - - # Assert empty list but no errors for a source not implementing collect_source_info() - # - # Note that buildstream internal _yaml doesn't support loading a list as a toplevel element - # in the stream, so we just assert the string instead. - assert result.output == "[]\n\n" + if expect_fatal: + result.assert_main_error(ErrorDomain.PLUGIN, CoreWarnings.UNAVAILABLE_SOURCE_INFO) + else: + # Assert empty list but no errors for a source not implementing collect_source_info() + # + # Note that buildstream internal _yaml doesn't support loading a list as a toplevel element + # in the stream, so we just assert the string instead. + result.assert_success() + assert result.output == "[]\n\n" + assert "WARNING [unavailable-source-info]" in result.stderr # This checks how Source.collect_source_info() works on a workspace, diff --git a/tests/frontend/source-info/elements/unimplemented.bst b/tests/frontend/source-info-unimplemented/fatal/elements/unimplemented.bst similarity index 100% copy from tests/frontend/source-info/elements/unimplemented.bst copy to tests/frontend/source-info-unimplemented/fatal/elements/unimplemented.bst diff --git a/tests/frontend/source-info/plugins/unimplemented.py b/tests/frontend/source-info-unimplemented/fatal/plugins/unimplemented.py similarity index 100% copy from tests/frontend/source-info/plugins/unimplemented.py copy to tests/frontend/source-info-unimplemented/fatal/plugins/unimplemented.py diff --git a/tests/frontend/source-info-unimplemented/fatal/project.conf b/tests/frontend/source-info-unimplemented/fatal/project.conf new file mode 100644 index 000000000..04d6c3cf3 --- /dev/null +++ b/tests/frontend/source-info-unimplemented/fatal/project.conf @@ -0,0 +1,13 @@ +# Project config for bst show source-info test +name: test +min-version: 2.0 +element-path: elements + +plugins: +- origin: local + path: plugins + sources: + - unimplemented + +fatal-warnings: +- unavailable-source-info diff --git a/tests/frontend/source-info/elements/unimplemented.bst b/tests/frontend/source-info-unimplemented/non-fatal/elements/unimplemented.bst similarity index 100% rename from tests/frontend/source-info/elements/unimplemented.bst rename to tests/frontend/source-info-unimplemented/non-fatal/elements/unimplemented.bst diff --git a/tests/frontend/source-info/plugins/unimplemented.py b/tests/frontend/source-info-unimplemented/non-fatal/plugins/unimplemented.py similarity index 100% rename from tests/frontend/source-info/plugins/unimplemented.py rename to tests/frontend/source-info-unimplemented/non-fatal/plugins/unimplemented.py diff --git a/tests/frontend/source-info-unimplemented/non-fatal/project.conf b/tests/frontend/source-info-unimplemented/non-fatal/project.conf new file mode 100644 index 000000000..67ceb3f18 --- /dev/null +++ b/tests/frontend/source-info-unimplemented/non-fatal/project.conf @@ -0,0 +1,10 @@ +# Project config for bst show source-info test +name: test +min-version: 2.0 +element-path: elements + +plugins: +- origin: local + path: plugins + sources: + - unimplemented
