Skip to content

Commit

Permalink
Hoist coverage setup out of individual cram test files and into the C…
Browse files Browse the repository at this point in the history
…I workflow

This avoids baking in coverage to the tests and lets it remain a
separate concern (e.g. CI's concern).  In my experience it's better to
have coverage tracing happen outside of tests (i.e. the tests are
unaware) rather than as integrated into the tests themselves.

Partially reverts commit 723d609, which
added code for coverage to each cram test file.

I chose to use the github.workspace context var in the CI workflow so I
could use the "env:" block for the job step.  Alternatively, we could
use `realpath` to construct an `env AUGUR=… …` call chaining to the
`cram …` invocation, but that seemed slightly messier to me.
  • Loading branch information
tsibley committed Apr 28, 2022
1 parent ebcdfb8 commit 072404e
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 25 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ jobs:
- run: conda list
- run: pytest -c pytest.python3.ini --cov=augur
- run: cram --shell=/bin/bash tests/functional/*.t tests/builds/*.t
env:
AUGUR: coverage run -a ${{ github.workspace }}/bin/augur
COVERAGE_FILE: ${{ github.workspace }}/.coverage
COVERAGE_RCFILE: ${{ github.workspace }}/.coveragerc
- run: coverage xml
- run: bash tests/builds/runner.sh
- if: github.repository == 'nextstrain/augur' && matrix.python-version == '3.10' && matrix.biopython-version == ''
Expand Down
3 changes: 1 addition & 2 deletions tests/builds/zika.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ Running from the test data directory allows us to use relative paths that won't
$ TEST_DATA_DIR="$TESTDIR/zika"
$ mkdir -p "$TMP/out"
$ pushd "$TEST_DATA_DIR" > /dev/null
$ export COVERAGE_FILE="$TESTDIR/../../.coverage"
$ export AUGUR="coverage run -a --rcfile=$TESTDIR/../../.coveragerc ../../../bin/augur"
$ export AUGUR="${AUGUR:-../../../bin/augur}"

Parse a FASTA whose defline contains metadata into separate sequence and metadata files.

Expand Down
3 changes: 1 addition & 2 deletions tests/builds/zika_compressed.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ Running from the test data directory allows us to use relative paths that won't
$ TEST_DATA_DIR="$TESTDIR/zika"
$ mkdir -p "$TMP/out"
$ pushd "$TEST_DATA_DIR" > /dev/null
$ export COVERAGE_FILE="$TESTDIR/../../.coverage"
$ export AUGUR="coverage run -a --rcfile=$TESTDIR/../../.coveragerc ../../../bin/augur"
$ export AUGUR="${AUGUR:-../../../bin/augur}"

Parse a FASTA whose defline contains metadata into separate sequence and metadata files.

Expand Down
3 changes: 1 addition & 2 deletions tests/functional/ancestral.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Integration tests for augur ancestral.

$ pushd "$TESTDIR" > /dev/null
$ export COVERAGE_FILE="$TESTDIR/../../.coverage"
$ export AUGUR="coverage run -a --rcfile=$TESTDIR/../../.coveragerc ../../bin/augur"
$ export AUGUR="${AUGUR:-../../bin/augur}"

Infer ancestral sequences for the given tree and alignment.
The default is to infer ambiguous bases, so there should not be N bases in the inferred output sequences.
Expand Down
5 changes: 2 additions & 3 deletions tests/functional/clades.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Integration tests for augur clades.

$ pushd "$TESTDIR" > /dev/null
$ export COVERAGE_FILE="$TESTDIR/../../.coverage"
$ export AUGUR="coverage run -a --rcfile=$TESTDIR/../../.coveragerc ../../bin/augur"
$ export AUGUR="${AUGUR:-../../bin/augur}"

Test augur clades with simple Zika input files and hierarchical clades.

Expand All @@ -14,4 +13,4 @@ Test augur clades with simple Zika input files and hierarchical clades.

$ python3 "$TESTDIR/../../scripts/diff_jsons.py" clades/clades.json "$TMP/clades.json" \
> --exclude-paths "root['generated_by']"
{}
{}
3 changes: 1 addition & 2 deletions tests/functional/export_v2.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Integration tests for augur export v2.

$ pushd "$TESTDIR" > /dev/null
$ export COVERAGE_FILE="$TESTDIR/../../.coverage"
$ export AUGUR="coverage run -a --rcfile=$TESTDIR/../../.coveragerc ../../bin/augur"
$ export AUGUR="${AUGUR:-../../bin/augur}"

Minimal export

Expand Down
3 changes: 1 addition & 2 deletions tests/functional/filter.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Integration tests for augur filter.

$ pushd "$TESTDIR" > /dev/null
$ export COVERAGE_FILE="$TESTDIR/../../.coverage"
$ export AUGUR="coverage run -a --rcfile=$TESTDIR/../../.coveragerc ../../bin/augur"
$ export AUGUR="${AUGUR:-../../bin/augur}"

Filter with exclude query for two regions that comprise all but one strain.
This filter should leave a single record from Oceania.
Expand Down
3 changes: 1 addition & 2 deletions tests/functional/frequencies.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Integration tests for augur frequencies.

$ pushd "$TESTDIR" > /dev/null
$ export COVERAGE_FILE="$TESTDIR/../../.coverage"
$ export AUGUR="coverage run -a --rcfile=$TESTDIR/../../.coveragerc ../../bin/augur"
$ export AUGUR="${AUGUR:-../../bin/augur}"

Calculate KDE-based tip frequencies from a refined tree.
Timepoints used to estimate frequencies (i.e., "pivots") get calculated from the range of dates in the given metadata.
Expand Down
3 changes: 1 addition & 2 deletions tests/functional/mask.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Integration tests for augur mask.

$ pushd "$TESTDIR" > /dev/null
$ export COVERAGE_FILE="$TESTDIR/../../.coverage"
$ export AUGUR="coverage run -a --rcfile=$TESTDIR/../../.coveragerc ../../bin/augur"
$ export AUGUR="${AUGUR:-../../bin/augur}"

Try masking a VCF without any specified mask.

Expand Down
3 changes: 1 addition & 2 deletions tests/functional/parse.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Integration tests for augur parse.

$ pushd "$TESTDIR" > /dev/null
$ export COVERAGE_FILE="$TESTDIR/../../.coverage"
$ export AUGUR="coverage run -a --rcfile=$TESTDIR/../../.coveragerc ../../bin/augur"
$ export AUGUR="${AUGUR:-../../bin/augur}"

Parse Zika sequences into sequences and metadata.

Expand Down
3 changes: 1 addition & 2 deletions tests/functional/refine.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Integration tests for augur refine.

$ pushd "$TESTDIR" > /dev/null
$ export COVERAGE_FILE="$TESTDIR/../../.coverage"
$ export AUGUR="coverage run -a --rcfile=$TESTDIR/../../.coveragerc ../../bin/augur"
$ export AUGUR="${AUGUR:-../../bin/augur}"

Try building a time tree.

Expand Down
3 changes: 1 addition & 2 deletions tests/functional/traits.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Integration tests for augur traits.

$ pushd "$TESTDIR" > /dev/null
$ export COVERAGE_FILE="$TESTDIR/../../.coverage"
$ export AUGUR="coverage run -a --rcfile=$TESTDIR/../../.coveragerc ../../bin/augur"
$ export AUGUR="${AUGUR:-../../bin/augur}"

Infer the ancestral region for a given tree and metadata.

Expand Down
3 changes: 1 addition & 2 deletions tests/functional/tree.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Integration tests for augur tree.

$ pushd "$TESTDIR" > /dev/null
$ export COVERAGE_FILE="$TESTDIR/../../.coverage"
$ export AUGUR="coverage run -a --rcfile=$TESTDIR/../../.coveragerc ../../bin/augur"
$ export AUGUR="${AUGUR:-../../bin/augur}"

Try building a tree with IQ-TREE.

Expand Down

0 comments on commit 072404e

Please sign in to comment.