aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/python/comment_verifier.py
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2019-10-08 15:48:26 -0700
committerHaibo Huang <hhb@google.com>2019-11-14 22:14:23 +0000
commit80b4251e302efb18c145a4786249d695397ed42a (patch)
tree12b9dec2513f7caa92e7835bc17ab16ae5635df6 /Examples/test-suite/python/comment_verifier.py
parent189852d8cdfd5863c52ec7aa73affd926c5a3f43 (diff)
parent1e36f51346d95f8b9848e682c2eb986e9cb9b4f4 (diff)
downloadswig-80b4251e302efb18c145a4786249d695397ed42a.tar.gz
Upgrade swig to 'rel-4.0.1'llvm-r383902b
Also run autogen.sh to generate configure files. Exempt-From-Owner-Approval: add myself to owners Change-Id: I391aa20428836ae74dab8c8427627ca4dbc8ecf4
Diffstat (limited to 'Examples/test-suite/python/comment_verifier.py')
-rw-r--r--Examples/test-suite/python/comment_verifier.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/Examples/test-suite/python/comment_verifier.py b/Examples/test-suite/python/comment_verifier.py
new file mode 100644
index 000000000..653cb4940
--- /dev/null
+++ b/Examples/test-suite/python/comment_verifier.py
@@ -0,0 +1,26 @@
+def check(got, expected, expected_builtin=None):
+ if got is None: # Absence of comment is equivalent to empty comment.
+ got = ""
+
+ if got != expected:
+ import re
+ p = re.compile(r"^[+-]([^+-].*\S)?(\s+)$", re.M)
+
+ def make_trailing_spaces_visible(str):
+ def replace_trailing_spaces(match):
+ res = match.group(0)
+ spaces = match.group(2)
+ if spaces is not None:
+ res = res + "{+%d trailing spaces}" % len(spaces)
+ return res
+ return re.sub(p, replace_trailing_spaces, str)
+
+ from difflib import unified_diff
+ diff = unified_diff(expected.splitlines(True),
+ got.splitlines(True), "expected", "got")
+ lines = []
+ for line in diff:
+ line = make_trailing_spaces_visible(line.strip("\r\n"))
+ lines.append(line + "\n")
+
+ raise RuntimeError("Comments don't match:\n" + "".join(lines))