Skip to content

Commit ab1e140

Browse files
committed
add quick mutation testing to travis
1 parent 424a838 commit ab1e140

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

.travis.yml

+31-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ addons:
1212
- libmpc-dev
1313
before_cache:
1414
- rm -f $HOME/.cache/pip/log/debug.log
15-
# place the slowest (instrumental and py2.6) first
15+
# place the slowest (instrumental, mutation and py2.6) first
1616
matrix:
1717
include:
18+
- python: 3.7
19+
dist: xenial
20+
sudo: true
21+
env: MUTATION=yes
1822
- python: 2.7
1923
env: INSTRUMENTAL=yes
2024
- python: 2.6
@@ -101,15 +105,16 @@ install:
101105
else
102106
travis_retry pip install -r build-requirements.txt;
103107
fi
104-
- if [[ $TOX_ENV =~ gmpy2 ]]; then travis_retry pip install gmpy2; fi
108+
- if [[ $TOX_ENV =~ gmpy2 ]] || [[ $MUTATION ]]; then travis_retry pip install gmpy2; fi
105109
- if [[ $TOX_ENV =~ gmpyp ]]; then travis_retry pip install gmpy; fi
106110
- if [[ $INSTRUMENTAL ]]; then travis_retry pip install instrumental; fi
111+
- if [[ $MUTATION ]]; then travis_retry pip install cosmic-ray gmpy2; fi
107112
- pip list
108113
script:
109114
- if [[ $TOX_ENV ]]; then tox -e $TOX_ENV; fi
110-
- if [[ $TOX_ENV =~ gmpy2 ]]; then tox -e speedgmpy2; fi
111-
- if [[ $TOX_ENV =~ gmpyp ]]; then tox -e speedgmpy; fi
112-
- if ! [[ $TOX_ENV =~ gmpy ]]; then tox -e speed; fi
115+
- if [[ $TOX_ENV =~ gmpy2 ]] && [[ -z $MUTATION ]]; then tox -e speedgmpy2; fi
116+
- if [[ $TOX_ENV =~ gmpyp ]] && [[ -z $MUTATION ]]; then tox -e speedgmpy; fi
117+
- if ! [[ $TOX_ENV =~ gmpy ]] && [[ -z $MUTATION ]]; then tox -e speed; fi
113118
- |
114119
if [[ $INSTRUMENTAL && $TRAVIS_PULL_REQUEST != "false" ]]; then
115120
git checkout $PR_FIRST^
@@ -133,6 +138,26 @@ script:
133138
if [[ $INSTRUMENTAL && $TRAVIS_PULL_REQUEST != "false" ]]; then
134139
instrumental -f .instrumental.cov -s | python diff-instrumental.py --read .diff-instrumental --fail-under 70 --max-difference -0.1
135140
fi
141+
# cosmic-ray (mutation testing) runs
142+
- if [[ $MUTATION ]]; then cosmic-ray init cosmic-ray.toml session.sqlite; fi
143+
- if [[ $MUTATION ]]; then cosmic-ray baseline --report session.sqlite; fi
144+
- if [[ $MUTATION ]]; then cr-report --show-output session.baseline.sqlite; fi
145+
- |
146+
if [[ $MUTATION ]]; then
147+
cosmic-ray exec session.sqlite &
148+
COSMIC_PID=$!
149+
# make sure that we output something every 5 minutes (otherwise travis will kill us)
150+
while kill -s 0 $COSMIC_PID; do
151+
sleep 300
152+
cr-report session.sqlite | tail -n 3;
153+
done &
154+
REPORT_PID=$!
155+
# kill exec after 25 minutes
156+
(sleep $((60*25)); kill $COSMIC_PID) &
157+
fi
158+
- if [[ $MUTATION ]]; then wait $COSMIC_PID ; kill $REPORT_PID ; true; fi
159+
- if [[ $MUTATION ]]; then cr-report --show-output session.sqlite | tail -n 40; fi
160+
- if [[ $MUTATION ]]; then cr-rate --estimate --fail-over 25 --confidence 99.9 session.sqlite; fi
136161
after_success:
137-
- if [[ -z $INSTRUMENTAL ]]; then coveralls; fi
162+
- if [[ -z $INSTRUMENTAL && -z $MUTATION ]]; then coveralls; fi
138163

cosmic-ray.sh

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ cr-report --show-output session.baseline.sqlite
77
cosmic-ray exec session.sqlite
88
cr-report session.sqlite
99
cr-html session.sqlite > session.html
10+
cr-rate --estimate --fail-over 25 --confidence 99.9 session.sqlite

cosmic-ray.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[cosmic-ray]
22
module-path = "src"
33
python-version = ""
4-
timeout = 120.0
4+
timeout = 30.0
55
exclude-modules = ['src/ecdsa/_version.py', 'src/ecdsa/test*']
66
test-command = "pytest -x src/"
77

0 commit comments

Comments
 (0)