[test] determine whether to run external plug in tests based on installed packages

This commit is contained in:
MinchinWeb 2021-05-09 13:49:17 -06:00
parent b9c9ce4606
commit 2a70636b4d
4 changed files with 30 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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."""

View file

@ -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 "<plugin_name> : <version> from jrnl.<source>.<type>.<filename>"
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"