Skip to content

Commit cda981c

Browse files
committed
Test: Bash script to run examples; run this in Travis CI.
1 parent 9e41ae7 commit cda981c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ install:
7575
script:
7676
- 'if [ $SLYCOT != "" ]; then python -c "import slycot"; fi'
7777
- coverage run setup.py test
78+
- '(cd examples && bash run_examples.sh)'
7879

7980
after_success:
8081
- coveralls

examples/run_examples.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# Run the examples. Doesn't run Jupyter notebooks.
3+
4+
# The examples must cooperate: they must have no operations that wait
5+
# on user action, like matplotlib.pyplot.show, or starting a GUI event
6+
# loop. Environment variable PYCONTROL_TEST_EXAMPLES is set when the
7+
# examples are being tested; existence of this variable should be used
8+
# to prevent such user-action-waiting operations.
9+
10+
export PYCONTROL_TEST_EXAMPLES=1
11+
12+
example_errors=""
13+
14+
for example in *.py; do
15+
echo "Running ${example}"
16+
if ! python ${example}; then
17+
example_errors="${example_errors} ${example}"
18+
fi
19+
done
20+
21+
if [ -n "${example_errors}" ]; then
22+
echo These examples had errors:
23+
echo "${example_errors}"
24+
exit 1
25+
else
26+
echo All examples ran successfully
27+
fi

0 commit comments

Comments
 (0)