/
run_all_tests
executable file
·75 lines (57 loc) · 1.8 KB
/
run_all_tests
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python
#from subprocess import call
import subprocess
import os
tests_run = []
previous_line = ""
failed_tests = False
ignore_folders = ["board", "max8819", "elum", "c++allocate", "fullduplexserial", "quadrature_encoder", "unity_tools", "vnh2sp30"]
folders = [d for d in os.listdir(os.getcwd()) if os.path.isdir(d)]
tests = list(set(folders).difference(set(ignore_folders)))
"**************************************"
print "Testing folders:"
for test in tests:
print "--- " + test
for test in tests:
print "**************************************"
print "Testing folder " + test
print ""
os.chdir(test)
# call(["./run_all", "-t115200"])
p = subprocess.Popen(["./run_unit", "-m"], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
for line in iter(p.stdout.readline, ''):
print line.rstrip()
# if not all(c.isspace() for c in line):
if line.strip() == "OK":
tests_run.append((test + ": ").ljust(20) + previous_line)
p.stdin.write("\x1B[A") #Send up key
break
if line.strip() == "FAIL":
tests_run.append((test + ": ").ljust(20) + previous_line)
p.stdin.write("\x1B[A") #Send up key
failed_tests = True
break
if line.strip() == "error: load failed":
tests_run.append((test + ": ").ljust(20) + "error: load failed");
break
previous_line = line
print ""
for line in iter(p.stderr.readline, ''):
print line.rstrip()
os.chdir("..")
print ""
print "**************************************"
print "Folders ignored:"
for i_f in ignore_folders:
print "--- " + i_f
for test in tests_run:
print test.rstrip()
print "**************************************"
if failed_tests == False:
print "OK"
else:
print "FAIL"
print ""
print ""
print "To add all .elf files to git, run the following command: "
print "git ls-files | grep '\.elf$' | xargs git add"