diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1a2234184e379cb57afd1d15b95d44b1311fd366..abc50b24075ff92f18832462441b969f54908035 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,11 +17,6 @@ install_py37: - eossr-codemeta2zenodo --help - eossr-codemeta2zenodo --input_codemeta_file ./codemeta.json - cat .zenodo.json - - echo "testing all entry points and bash scripts" - - eossr-upload-new-deposit -h - - eossr-upload-new-version-deposit -h - - eossr-check-connection-zenodo -h - - which parse_last_release_git.sh only: - branches diff --git a/eossr/scripts/tests/test_scripts.py b/eossr/scripts/tests/test_scripts.py index 316b254cbbc7b28e7c75244c75f9c3b231146208..ead140b080a9fab2035590d0dc3b019f0dce3778 100644 --- a/eossr/scripts/tests/test_scripts.py +++ b/eossr/scripts/tests/test_scripts.py @@ -1,9 +1,27 @@ +# Various tests taken/based from +# https://github.com/cta-observatory/cta-lstchain/blob/master/lstchain/scripts/tests/test_lstchain_scripts.py + +import pytest import subprocess +import pkg_resources from os.path import dirname, realpath, join ROOT_DIR = dirname(realpath("codemeta.json")) +def find_entry_points(package_name): + """from: https://stackoverflow.com/a/47383763/3838691""" + entrypoints = [ + ep.name + for ep in pkg_resources.iter_entry_points("console_scripts") + if ep.module_name.startswith(package_name) + ] + return entrypoints + + +ALL_SCRIPTS = find_entry_points("eossr") + + def run_script(*args): result = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf-8') @@ -16,3 +34,13 @@ def run_script(*args): def test_codemeta2zenodo(): run_script("eossr-codemeta2zenodo", "-i", join(ROOT_DIR, "codemeta.json")) + + +def test_parse_last_release_git_bash(): + run_script("which", "parse_last_release_git.sh") + + +@pytest.mark.parametrize("script", ALL_SCRIPTS) +def test_help_all_scripts(script): + """Test for all scripts if at least the help works""" + run_script(script, "--help")