Skip to content

Commit 4803527

Browse files
committed
Simple test framework
Split out test cases which should pass, from those which should fail (one code per folder - hopefully we can continue to maintain separate examples like this - does not yet cater to a test case with multiple error codes expected.
1 parent b8ff037 commit 4803527

4 files changed

Lines changed: 45 additions & 7 deletions

File tree

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ script:
3434
- echo "On this machine \$LANG=$LANG"
3535
- echo "Checking our own docstrings are valid RST"
3636
- flake8 --select RST setup.py flake8_rst_docstrings.py
37-
- echo "Checking we can parse our valid test cases"
38-
- flake8 --select RST --ignore RST303,RST304 tests/test_cases/*.py
37+
- cd tests/
38+
- ./run_tests.sh
3939

4040
notifications:
4141
email: false
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Example reStructuredText from Sphinx-Needs project.
22
33
From http://sphinxcontrib-needs.readthedocs.io/en/latest/
4+
but cut down and may not work in isolation. Intended just
5+
to trigger RST303.
46
57
**Some data**
68
@@ -24,11 +26,6 @@
2426
2527
**Some text**
2628
27-
Wohooo, we have created :need:`req_001`,
28-
which is linked by :need_incoming:`req_001`.
29-
30-
**A filter**
31-
3229
.. needfilter::
3330
:tags: example
3431
:layout: table

tests/RST304/sphinx-roles.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Example reStructuredText from Sphinx-Needs project.
2+
3+
From http://sphinxcontrib-needs.readthedocs.io/en/latest/
4+
but will not work in isolation - cut down just to trigger
5+
RST304.
6+
7+
**Some text**
8+
9+
Wohooo, we have created :need:`req_001`,
10+
which is linked by :need_incoming:`req_001`.
11+
12+
"""
13+
14+
print("sphinx-needs defines its own reStructuredText roles.")

tests/run_tests.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
IFS=$'\n\t'
3+
set -eu
4+
# Note not using "set -o pipefile" until after check error message with grep
5+
6+
# Examples which should fail
7+
for code in RST??? ; do
8+
echo "======"
9+
echo $code
10+
echo "======"
11+
flake8 --select RST $code/ 2>&1 | grep $code
12+
echo "Return code $? from $code tests"
13+
done
14+
# echo "Positive tests passed (RST errors reported as expected)."
15+
16+
set -o pipefail
17+
18+
# Examples which should pass
19+
echo "========="
20+
echo "Negatives"
21+
echo "========="
22+
flake8 --select RST test_cases/
23+
#echo "Negative tests passed (no RST errors reported as expected)."
24+
25+
echo "============"
26+
echo "Tests passed"
27+
echo "============"

0 commit comments

Comments
 (0)