Skip to content

Commit 01db9a4

Browse files
committed
Move compile-fail tests that are rejected by the parser to parse-fail
1 parent f3573aa commit 01db9a4

File tree

132 files changed

+22
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+22
-13
lines changed

mk/tests.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ RPASS_FULL_RS := $(wildcard $(S)src/test/run-pass-fulldeps/*.rs)
452452
CFAIL_FULL_RS := $(wildcard $(S)src/test/compile-fail-fulldeps/*.rs)
453453
RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
454454
CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
455+
PFAIL_RS := $(wildcard $(S)src/test/parse-fail/*.rs)
455456
BENCH_RS := $(wildcard $(S)src/test/bench/*.rs)
456457
PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
457458
DEBUGINFO_GDB_RS := $(wildcard $(S)src/test/debuginfo/*.rs)
@@ -468,7 +469,7 @@ RPASS_VALGRIND_TESTS := $(RPASS_VALGRIND_RS)
468469
RPASS_FULL_TESTS := $(RPASS_FULL_RS)
469470
CFAIL_FULL_TESTS := $(CFAIL_FULL_RS)
470471
RFAIL_TESTS := $(RFAIL_RS)
471-
CFAIL_TESTS := $(CFAIL_RS)
472+
CFAIL_TESTS := $(CFAIL_RS) $(PFAIL_RS)
472473
BENCH_TESTS := $(BENCH_RS)
473474
PERF_TESTS := $(PERF_RS)
474475
PRETTY_TESTS := $(PRETTY_RS)

src/grammar/testparser.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,42 @@
3535
ok[parser] = 0
3636
bad[parser] = []
3737
devnull = open(os.devnull, 'w')
38-
print "\n"
38+
print("\n")
3939

4040
for base, dirs, files in os.walk(args.source_dir[0]):
4141
for f in filter(lambda p: p.endswith('.rs'), files):
4242
p = os.path.join(base, f)
43-
compile_fail = 'compile-fail' in p
44-
ignore = any('ignore-test' in line or 'ignore-lexer-test' in line
45-
for line in open(p).readlines())
46-
if compile_fail or ignore:
43+
parse_fail = 'parse-fail' in p
44+
if sys.version_info.major == 3:
45+
lines = open(p, encoding='utf-8').readlines()
46+
else:
47+
lines = open(p).readlines()
48+
if any('ignore-test' in line or 'ignore-lexer-test' in line for line in lines):
4749
continue
4850
total += 1
4951
for parser in args.parser:
5052
if subprocess.call(parser, stdin=open(p), stderr=subprocess.STDOUT, stdout=devnull) == 0:
51-
ok[parser] += 1
53+
if parse_fail:
54+
bad[parser].append(p)
55+
else:
56+
ok[parser] += 1
5257
else:
53-
bad[parser].append(p)
58+
if parse_fail:
59+
ok[parser] += 1
60+
else:
61+
bad[parser].append(p)
5462
parser_stats = ', '.join(['{}: {}'.format(parser, ok[parser]) for parser in args.parser])
5563
sys.stdout.write("\033[K\r total: {}, {}, scanned {}"
5664
.format(total, os.path.relpath(parser_stats), os.path.relpath(p)))
5765

5866
devnull.close()
5967

60-
print "\n"
68+
print("\n")
6169

6270
for parser in args.parser:
6371
filename = os.path.basename(parser) + '.bad'
64-
print("writing {} files that failed to parse with {} to {}".format(len(bad[parser]), parser, filename))
72+
print("writing {} files that did not yield the correct result with {} to {}".format(len(bad[parser]), parser, filename))
6573
with open(filename, "w") as f:
66-
for p in bad[parser]:
67-
f.write(p)
68-
f.write("\n")
74+
for p in bad[parser]:
75+
f.write(p)
76+
f.write("\n")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)