From 25e302f78c4c5e2ffb39e41425fd7a71694e5306 Mon Sep 17 00:00:00 2001 From: Gregory Ashton <gregory.ashton@ligo.org> Date: Tue, 18 Sep 2018 09:31:44 +1000 Subject: [PATCH] Several changes to the CI/testing 1) Rename all tests to the pytest standard naming convention 2) Update to use pytest to run the tests and collect coverage 3) Simplify gitlab CI script using above changes --- .coveragerc | 6 ++++++ .gitlab-ci.yml | 21 ++++--------------- setup.cfg | 4 ++++ ...libration_tests.py => calibration_test.py} | 0 ...conversion_tests.py => conversion_test.py} | 0 test/{detector_tests.py => detector_test.py} | 0 test/{example_tests.py => example_test.py} | 0 ...gw_example_tests.py => gw_example_test.py} | 0 ...elihood_tests.py => gw_likelihood_test.py} | 0 ...likelihood_tests.py => likelihood_test.py} | 0 ...ion_tests.py => noise_realisation_test.py} | 0 test/{other_tests.py => other_test.py} | 0 test/{prior_tests.py => prior_test.py} | 0 test/{utils_tests.py => utils_test.py} | 0 ...or_tests.py => waveform_generator_test.py} | 0 15 files changed, 14 insertions(+), 17 deletions(-) create mode 100644 .coveragerc rename test/{calibration_tests.py => calibration_test.py} (100%) rename test/{conversion_tests.py => conversion_test.py} (100%) rename test/{detector_tests.py => detector_test.py} (100%) rename test/{example_tests.py => example_test.py} (100%) rename test/{gw_example_tests.py => gw_example_test.py} (100%) rename test/{gw_likelihood_tests.py => gw_likelihood_test.py} (100%) rename test/{likelihood_tests.py => likelihood_test.py} (100%) rename test/{noise_realisation_tests.py => noise_realisation_test.py} (100%) rename test/{other_tests.py => other_test.py} (100%) rename test/{prior_tests.py => prior_test.py} (100%) rename test/{utils_tests.py => utils_test.py} (100%) rename test/{waveform_generator_tests.py => waveform_generator_test.py} (100%) diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..aa0939e4 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,6 @@ +[run] +omit = + test/example_test.py + test/gw_example_test.py + test/noise_realisation_test.py + test/other_test.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 786fca95..9376bae2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,11 +21,11 @@ python-2: - apt install -y libgl1-mesa-glx - pip install -r requirements.txt - pip install -r optional_requirements.txt - - pip install lalsuite enum gwpy + - pip install enum script: - python setup.py install # Run tests without finding coverage - - for test in test/*tests.py; do python $test; done + - pytest # test example on python 3 python-3: @@ -39,6 +39,7 @@ python-3: - pip install 'coverage>=4.5' - pip install coverage-badge - pip install flake8 + - pip install pytest-cov script: - python setup.py install @@ -46,23 +47,9 @@ python-3: - flake8 . # Run tests and collect coverage data - - coverage --version - - coverage erase - - coverage run --debug=trace --include=/opt/conda/lib/python3.6/site-packages/tupak* -a test/conversion_tests.py - - coverage run --include=/opt/conda/lib/python3.6/site-packages/tupak* -a test/calibration_tests.py - - coverage run --include=/opt/conda/lib/python3.6/site-packages/tupak* -a test/detector_tests.py - - coverage run --include=/opt/conda/lib/python3.6/site-packages/tupak* -a test/gw_likelihood_tests.py - - coverage run --include=/opt/conda/lib/python3.6/site-packages/tupak* -a test/likelihood_tests.py - - coverage run --include=/opt/conda/lib/python3.6/site-packages/tupak* -a test/prior_tests.py - - coverage run --include=/opt/conda/lib/python3.6/site-packages/tupak* -a test/sampler_tests.py - - coverage run --include=/opt/conda/lib/python3.6/site-packages/tupak* -a test/utils_tests.py - - coverage run --include=/opt/conda/lib/python3.6/site-packages/tupak* -a test/waveform_generator_tests.py + - pytest --cov=tupak - coverage html - coverage-badge -o coverage_badge.svg -f - # Run all other tests (no coverage data collected) - - python test/example_tests.py - - python test/gw_example_tests.py - - python test/noise_realisation_tests.py # Make the documentation - pip install -r docs/requirements.txt diff --git a/setup.cfg b/setup.cfg index b3193025..b1e3bbe8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,3 +2,7 @@ exclude = .git,docs,build,dist,test,examples,*__init__.py max-line-length = 160 ignore = E129 + +[tool:pytest] +addopts = + --ignore test/other_test.py diff --git a/test/calibration_tests.py b/test/calibration_test.py similarity index 100% rename from test/calibration_tests.py rename to test/calibration_test.py diff --git a/test/conversion_tests.py b/test/conversion_test.py similarity index 100% rename from test/conversion_tests.py rename to test/conversion_test.py diff --git a/test/detector_tests.py b/test/detector_test.py similarity index 100% rename from test/detector_tests.py rename to test/detector_test.py diff --git a/test/example_tests.py b/test/example_test.py similarity index 100% rename from test/example_tests.py rename to test/example_test.py diff --git a/test/gw_example_tests.py b/test/gw_example_test.py similarity index 100% rename from test/gw_example_tests.py rename to test/gw_example_test.py diff --git a/test/gw_likelihood_tests.py b/test/gw_likelihood_test.py similarity index 100% rename from test/gw_likelihood_tests.py rename to test/gw_likelihood_test.py diff --git a/test/likelihood_tests.py b/test/likelihood_test.py similarity index 100% rename from test/likelihood_tests.py rename to test/likelihood_test.py diff --git a/test/noise_realisation_tests.py b/test/noise_realisation_test.py similarity index 100% rename from test/noise_realisation_tests.py rename to test/noise_realisation_test.py diff --git a/test/other_tests.py b/test/other_test.py similarity index 100% rename from test/other_tests.py rename to test/other_test.py diff --git a/test/prior_tests.py b/test/prior_test.py similarity index 100% rename from test/prior_tests.py rename to test/prior_test.py diff --git a/test/utils_tests.py b/test/utils_test.py similarity index 100% rename from test/utils_tests.py rename to test/utils_test.py diff --git a/test/waveform_generator_tests.py b/test/waveform_generator_test.py similarity index 100% rename from test/waveform_generator_tests.py rename to test/waveform_generator_test.py -- GitLab