aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/isolate_tests.py39
-rwxr-xr-xtest/cmdlineTests.sh10
2 files changed, 25 insertions, 24 deletions
diff --git a/scripts/isolate_tests.py b/scripts/isolate_tests.py
index 57fc7ff0..de2a4438 100755
--- a/scripts/isolate_tests.py
+++ b/scripts/isolate_tests.py
@@ -35,33 +35,26 @@ def extract_test_cases(path):
return tests
# Contract sources are indented by 4 spaces.
-# Look for `pragma solidity` and abort a line not indented properly.
-# If the comment `// This will not compile` is above the pragma,
-# the code is skipped.
+# Look for `pragma solidity`, `contract`, `library` or `interface`
+# and abort a line not indented properly.
def extract_docs_cases(path):
- # Note: this code works, because splitlines() removes empty new lines
- # and thus even if the empty new lines are missing indentation
- lines = open(path, 'rb').read().splitlines()
-
- ignore = False
inside = False
tests = []
- for l in lines:
- if inside:
- # Abort if indentation is missing
- m = re.search(r'^[^ ]+', l)
- if m:
- inside = False
- else:
- tests[-1] += l + '\n'
- else:
- m = re.search(r'^ pragma solidity .*[0-9]+\.[0-9]+\.[0-9]+;$', l)
- if m:
- inside = True
- tests += [l]
-
- return tests
+ # Collect all snippets of indented blocks
+ for l in open(path, 'rb').read().splitlines():
+ if l != '':
+ if not inside and l.startswith(' '):
+ # start new test
+ tests += ['']
+ inside = l.startswith(' ')
+ if inside:
+ tests[-1] += l + '\n'
+ # Filter all tests that do not contain Solidity
+ return [
+ test for test in tests
+ if re.search(r'^ [ ]*(pragma solidity|contract |library |interface )', test, re.MULTILINE)
+ ]
def write_cases(tests):
for test in tests:
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index e0ef4461..c9acb99a 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -181,9 +181,17 @@ TMPDIR=$(mktemp -d)
"$REPO_ROOT"/scripts/isolate_tests.py "$REPO_ROOT"/docs/ docs
for f in *.sol
do
+ # The contributors guide uses syntax tests, but we cannot
+ # really handle them here.
+ if grep -E 'DeclarationError:|// ----' "$f" >/dev/null
+ then
+ continue
+ fi
echo "$f"
opts=''
- if grep "This will not compile" "$f" >/dev/null
+ # We expect errors if explicitly stated, or if imports
+ # are used (in the style guide)
+ if grep -E "This will not compile|import \"" "$f" >/dev/null
then
opts="-e"
fi