Skip to content

Commit

Permalink
move some tests inside proper test suite to help with coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
joezuntz committed Nov 9, 2022
1 parent 5b1d4dc commit 9027b67
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@ jobs:
- name: Tests
run: |
ceci tests/test.yml
ceci --dry-run tests/test.yml
ceci --flow-chart test-flow.png tests/test.yml
test -f test-flow.png
pytest --cov=ceci
# add a test with the memory monitor and profiling switched on
python3 -m ceci_example PZEstimationPipe --DM=./tests/inputs/dm.txt --fiducial_cosmology=./tests/inputs/fiducial_cosmology.txt --config=./tests/config.yml --photoz_pdfs=./tests/outputs/photoz_pdfs.txt --memmon=1 --cprofile=profile.stats
- name: Upload coverage to Codecov
Expand Down
1 change: 1 addition & 0 deletions ceci_example/example_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class PZEstimationPipe(PipelineStage):
name = "PZEstimationPipe"
inputs = [("DM", TextFile), ("fiducial_cosmology", TextFile)]
outputs = [("photoz_pdfs", TextFile)]
parallel = False

def run(self):
for inp, _ in self.inputs:
Expand Down
22 changes: 22 additions & 0 deletions tests/test_executables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
import subprocess
import os

def test_executable():
subprocess.check_call(["ceci", "tests/test.yml"])

def test_dry_run():
subprocess.check_call(["ceci", "--dry-run", "tests/test.yml",])

def test_flow_chart_run():
subprocess.check_call(["ceci", "--flow-chart", "test-flow.png", "tests/test.yml",])
assert os.path.exists("test-flow.png")

def test_profiling_and_memmon_flags():
cmd = "python3 -m ceci_example PZEstimationPipe --DM=./tests/inputs/dm.txt --fiducial_cosmology=./tests/inputs/fiducial_cosmology.txt --config=./tests/config.yml --photoz_pdfs=./tests/outputs/photoz_pdfs.txt --memmon=1 --cprofile=profile.stats"
subprocess.check_call(cmd.split())

def test_misuse_mpi():
cmd = "python3 -m ceci_example PZEstimationPipe --mpi"
with pytest.raises(subprocess.CalledProcessError):
subprocess.check_call(cmd.split())

0 comments on commit 9027b67

Please sign in to comment.