diff options
author | Johan Dahlin <johan@gnome.org> | 2010-09-02 23:28:14 -0300 |
---|---|---|
committer | Johan Dahlin <johan@gnome.org> | 2010-09-02 23:28:54 -0300 |
commit | c3a180975772ba9943e27e1040d321534579810e (patch) | |
tree | c04cacee87b33c9ce0fd769581b6fb97fc2e2a97 /tests/warn | |
parent | 4a01ca43c976ba09c1647cbc56918f3b3e917ff4 (diff) | |
download | gobject-introspection-c3a180975772ba9943e27e1040d321534579810e.tar.gz |
[tests] Handle multiple errors per file better
Diffstat (limited to 'tests/warn')
-rw-r--r-- | tests/warn/warningtester.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/warn/warningtester.py b/tests/warn/warningtester.py index 757b1d52..7009e0ea 100644 --- a/tests/warn/warningtester.py +++ b/tests/warn/warningtester.py @@ -50,14 +50,15 @@ def _extract_expected(filename): data = fd.read() retval = [] - while data: - pos = data.find("EXPECT:") - data = data[pos+7:] - end = data.find('\n') - if end == -1: - break - retval.append(data[:end]) - data = data[end:] + for line in data.split('\n'): + if line.startswith('// EXPECT:'): + sort_key = None + if ":" in line: + try: + sort_key = int(line.split(":")[1]) + except ValueError: + pass + retval.append((sort_key, line[10:])) return sorted(retval) def check(args): @@ -102,9 +103,9 @@ def check(args): expected_warnings = _extract_expected(filename) if len(expected_warnings) != len(warnings): raise SystemExit( - "ERROR: expected %d warnings, but got %d: %s\n", - len(expected_warnings), len(warnings), warnings.join('\n')) - for warning, expected in zip(warnings, expected_warnings): + "ERROR: expected %d warnings, but got %d: %r\n" % ( + len(expected_warnings), len(warnings), warnings)) + for warning, (sort_key, expected) in zip(warnings, expected_warnings): actual = warning.split(":", 1)[1] if _diff(actual, expected, filename): raise SystemExit("ERROR: tests %r failed" % (filename, )) |