This repository has been archived by the owner on Oct 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·113 lines (88 loc) · 2.25 KB
/
test
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env python
import testparser, results
from getch import getch
import sys, os
#import webbrowser
#SROBOWIKI = "https://www.studentrobotics.org/trac/wiki/%s"
BOLD = "\033[1m"
BOLD_RESET = "\033[0;0m"
RED = "\033[1;31m"
GREEN = "\033[1;32m"
BLUE = "\033[1;34m"
COLOUR_RESET = "\033[0;0m"
def bold(s):
return BOLD + s + BOLD_RESET
def warn(s):
print RED + s + COLOUR_RESET
def info(s):
print BLUE + s + COLOUR_RESET
def success(s):
print GREEN + s + COLOUR_RESET
def openURL(url):
webbrowser.open(url)
if len(sys.argv) < 2:
print "Usage: %s BOARD_NAME" % os.path.basename( sys.argv[0] )
sys.exit(1)
board_name = sys.argv[1]
try:
tests = testparser.parse_file("tests/%s_tests.xml" % board_name)
except IOError:
warn("Could not find test file for board '%s'" % board_name)
sys.exit(1)
# Get the board number
board_num = None
while True:
try:
ns = raw_input("Enter board number: " + BLUE)
except KeyboardInterrupt:
print COLOUR_RESET
sys.exit(1)
sys.stdout.write(COLOUR_RESET)
sys.stdout.flush()
try:
board_num = int(ns)
break
except:
warn("Not a number... try again.")
pass
test_n = 0
while test_n < len(tests):
test = tests[test_n]
num_str = "[%s/%i]." % ( bold(str(test_n+1)), len(tests) )
num_str_no_fmt = "[%i/%i]" % ( test_n+1, len(tests) )
print num_str, test.text
print " " * (len(num_str_no_fmt) + 1), "Pass? [y/n/q/b/?]",
c = getch()
if c in "yY":
success("yes")
test.passed = True
test_n += 1
elif c in "nN":
warn("no")
test.passed = False
break
elif c in "b":
info("back")
test_n -= 1
if test_n < 0:
test_n = 0
#elif c in "w":
# info("wiki")
# if test.name != "":
# openURL(SROBOWIKI % ("Tests/" + board_name + "/" + test.name))
# else:
# warn("no name exists for this test")
elif c in "qQ\003":
warn("quit")
sys.exit(1)
else:
info("help")
print """ y -- Yes, it passed.
n -- No, it failed.
q -- Quit.
b -- Back one test.
? -- Show this help.
"""
print "-" * 80
results.save_results( board_name, board_num, tests )
sys.exit(0)