-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-suite.py
executable file
·54 lines (43 loc) · 1.59 KB
/
test-suite.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import subprocess
import sys
from os import listdir
from os.path import isfile, join
def test_syntax_only():
mypath = "testsuite/syntaxonly"
onlyfiles = [join(mypath, f)
for f in listdir(mypath) if isfile(join(mypath, f))]
print(onlyfiles)
for f in onlyfiles:
try:
return subprocess.run(["tools/rustc/rustc", "--fsyntax-only", "--crate-name=foo",
f"--path={f}"], check=True, encoding="utf-8",
stdout=subprocess.PIPE).stdout.strip()
except subprocess.CalledProcessError as error:
print("rustc --fsyntax-only failed")
print("Is this really a rust file?")
print(error)
sys.exit(-1)
def test_with_sema():
mypath = "testsuite/withsema"
onlyfiles = [join(mypath, f)
for f in listdir(mypath) if isfile(join(mypath, f))]
print(onlyfiles)
for f in onlyfiles:
try:
return subprocess.run(["tools/rustc/rustc", "--fwith-sema", "--crate-name=foo",
f"--path={f}"], check=True, encoding="utf-8",
stdout=subprocess.PIPE).stdout.strip()
except subprocess.CalledProcessError as error:
print("rustc --fwith-sema failed")
print("Is this really a rust file?")
print(error)
sys.exit(-1)
def main() -> int:
"""The main function."""
test_syntax_only()
test_with_sema()
return 0
if __name__ == '__main__':
sys.exit(main())