From f873389c6227d41dbba9ba4c23ed055f286ecb71 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 9 Aug 2018 14:58:28 +0200 Subject: Test that documentation does not contain any warnings. --- scripts/isolate_tests.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'scripts/isolate_tests.py') diff --git a/scripts/isolate_tests.py b/scripts/isolate_tests.py index 1f913504..57fc7ff0 100755 --- a/scripts/isolate_tests.py +++ b/scripts/isolate_tests.py @@ -56,20 +56,10 @@ def extract_docs_cases(path): else: tests[-1] += l + '\n' else: - m = re.search(r'^ // This will not compile', l) + m = re.search(r'^ pragma solidity .*[0-9]+\.[0-9]+\.[0-9]+;$', l) if m: - ignore = True - - if ignore: - # Abort if indentation is missing - m = re.search(r'^[^ ]+', l) - if m: - ignore = False - else: - m = re.search(r'^ pragma solidity .*[0-9]+\.[0-9]+\.[0-9]+;$', l) - if m: - inside = True - tests += [l] + inside = True + tests += [l] return tests -- cgit v1.2.3 From 6a5a187d83d97764fc6f77e392cdb2b9d8d6bb72 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 9 Aug 2018 20:48:41 +0200 Subject: Also extract tests that do not start with a pragma. --- scripts/isolate_tests.py | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) (limited to 'scripts/isolate_tests.py') 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: -- cgit v1.2.3