Skip to content

Commit 7cd7ba0

Browse files
committed
Run examples generation on Travis
This will work as a quick-and-dirty test that the output generated by the script is readable by dot, at least for the few examples that are in the tree. Additionally, make generate-examples.sh find a Python interpreter (instead of relying on "python") and fail if any step fails. FIxes #20.
1 parent 3e4b0ee commit 7cd7ba0

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
language: python
2+
addons:
3+
apt:
4+
packages:
5+
- graphviz
26
python:
37
- "2.7"
48
- "3.3"
59
- "3.4"
610
- "3.5"
711
- "3.6"
812
script:
9-
- python -m unittest discover
13+
- python -m unittest discover
14+
- bash scripts/generate-examples.sh

scripts/generate-examples.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
#!/bin/bash
22

3+
# Ugly way to get any python interpreter. This is necessary because the script will run
4+
# both with Python 2.7 and Python 3.x under Travis.
5+
PYTHONS=$(which python3 python2.7 python)
6+
PYTHON=$(echo $PYTHONS | cut -d" " -f1)
7+
8+
if [ -z "${PYTHON}" ]; then
9+
echo "ERROR: no Python interpreter found."
10+
exit 1
11+
fi
12+
echo "Using Python interpreter ${PYTHON}"
13+
14+
# Return an error if any of the following commands fails.
15+
set -e
316
echo "example1.cmd, --show-all-calls"
4-
python3 cmd-call-graph.py --show-all-calls < examples/example1.cmd > examples/example1.dot
17+
${PYTHON} cmd-call-graph.py --show-all-calls < examples/example1.cmd > examples/example1.dot
518
echo
619
echo "example1.cmd, --show-all-calls --show-node-stats"
7-
python3 cmd-call-graph.py --show-all-calls --show-node-stats < examples/example1.cmd > examples/example1-nodestats.dot
20+
${PYTHON} cmd-call-graph.py --show-all-calls --show-node-stats < examples/example1.cmd > examples/example1-nodestats.dot
821
echo
922
echo "example1.cmd, without --show-all-calls"
10-
python3 cmd-call-graph.py < examples/example1.cmd > examples/example1-noshowall.dot
23+
${PYTHON} cmd-call-graph.py < examples/example1.cmd > examples/example1-noshowall.dot
1124
echo
1225
echo "loc.cmd, with --show-node-status and without --show-all-calls"
13-
python3 cmd-call-graph.py --show-node-stats < examples/loc.cmd > examples/loc.dot
26+
${PYTHON} cmd-call-graph.py --show-node-stats < examples/loc.cmd > examples/loc.dot
1427

1528
dot -Tpng examples/example1.dot > examples/example1.png
1629
dot -Tpng examples/example1-nodestats.dot > examples/example1-nodestats.png

0 commit comments

Comments
 (0)