From 2a70636b4da430932a6822f0fd8f7a83eb8fbaa6 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sun, 9 May 2021 13:49:17 -0600 Subject: [PATCH] [test] determine whether to run external plug in tests based on installed packages --- .github/workflows/testing.yaml | 2 +- .../workflows/testing_external_plugins.yaml | 2 +- features/environment.py | 24 +++++++++++++++++++ features/plugins.feature | 8 +++---- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index fc9975b0..c5015d5f 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -69,4 +69,4 @@ jobs: - name: Test with behave if: success() || failure() - run: poetry run behave --no-skipped --format progress2 --junit --junit-directory reports/behave --tags "~external_plugins" + run: poetry run behave --no-skipped --format progress2 --junit --junit-directory reports/behave diff --git a/.github/workflows/testing_external_plugins.yaml b/.github/workflows/testing_external_plugins.yaml index d7bd904c..c135ba4d 100644 --- a/.github/workflows/testing_external_plugins.yaml +++ b/.github/workflows/testing_external_plugins.yaml @@ -64,4 +64,4 @@ jobs: - name: Test with behave if: success() || failure() - run: poetry run behave --no-skipped --format progress2 --junit --junit-directory reports/behave --tags "external_plugins" + run: poetry run behave --no-skipped --format progress2 --junit --junit-directory reports/behave diff --git a/features/environment.py b/features/environment.py index f4baab34..949ba717 100644 --- a/features/environment.py +++ b/features/environment.py @@ -3,6 +3,11 @@ import shutil from jrnl.os_compat import on_windows +try: + from jrnl.contrib.exporter import testing as testing_exporter +except ImportError: + testing_exporter = None + CWD = os.getcwd() # @see https://behave.readthedocs.io/en/latest/tutorial.html#debug-on-error-in-case-of-step-failures @@ -46,6 +51,14 @@ def before_feature(context, feature): feature.skip("Skipping on Windows") return + if "skip_only_with_external_plugins" in feature.tags and testing_exporter is None: + feature.skip("Requires test external plugins installed") + return + + if "skip_no_external_plugins" in feature.tags and testing_exporter: + feature.skip("Skipping with external plugins installed") + return + def before_scenario(context, scenario): """Before each scenario, backup all config and journal test data.""" @@ -73,6 +86,17 @@ def before_scenario(context, scenario): scenario.skip("Skipping on Windows") return + if ( + "skip_only_with_external_plugins" in scenario.effective_tags + and testing_exporter is None + ): + scenario.skip("Requires test external plugins installed") + return + + if "skip_no_external_plugins" in scenario.effective_tags and testing_exporter: + scenario.skip("Skipping with external plugins installed") + return + def after_scenario(context, scenario): """After each scenario, restore all test data and remove working_dirs.""" diff --git a/features/plugins.feature b/features/plugins.feature index 8e7e08f2..a899aa9f 100644 --- a/features/plugins.feature +++ b/features/plugins.feature @@ -1,12 +1,12 @@ Feature: Functionality of Importer and Exporter Plugins - not @external_plugins + @skip_no_external_plugins Scenario Outline: List buildin plugin names in --version Given We use the config "basic_onefile.yaml" When We run "jrnl --version" Then the output should contain pyproject.toml version And The output should contain " : from jrnl..." - And the output should not contain "contrib" + And the output should not contain ".contrib." Examples: | plugin_name | version | source | type | filename | @@ -23,7 +23,7 @@ Feature: Functionality of Importer and Exporter Plugins | xml | v2.7.2-beta | plugins | exporter | xml | | yaml | v2.7.2-beta | plugins | exporter | yaml | - @external_plugins + @skip_only_with_external_plugins Scenario Outline: List external plugin names in --version Given We use the config "basic_onefile.yaml" When We run "jrnl --version" @@ -47,7 +47,7 @@ Feature: Functionality of Importer and Exporter Plugins | rot13 | v1.0.0 | contrib | exporter | rot13 | | testing | v0.0.1 | contrib | exporter | testing | - @external_plugins + @skip_only_with_external_plugins Scenario Outline: Do not list overridden plugin names in --version Given We use the config "basic_onefile.yaml" When We run "jrnl --version"