Make test.py work with Python 3
This commit is contained in:
parent
ffdc96a06a
commit
e61a7da35b
1 changed files with 35 additions and 34 deletions
59
test.py
59
test.py
|
@ -25,6 +25,7 @@ class Command(object):
|
|||
def target():
|
||||
self.process = subprocess.Popen(self.cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
self.output, _ = self.process.communicate()
|
||||
self.output = self.output.decode("utf-8")
|
||||
|
||||
thread = threading.Thread(target=target)
|
||||
thread.start()
|
||||
|
@ -138,12 +139,12 @@ tests_ignored = [
|
|||
def init():
|
||||
global PPSSPP_EXE
|
||||
if not os.path.exists("pspautotests"):
|
||||
print "Please run git submodule init; git submodule update;"
|
||||
print("Please run git submodule init; git submodule update;")
|
||||
sys.exit(1)
|
||||
|
||||
if not os.path.exists(TEST_ROOT + "cpu/cpu_alu/cpu_alu.prx"):
|
||||
print "Please install the pspsdk and run make in common/ and in all the tests"
|
||||
print "(checked for existence of cpu/cpu_alu/cpu_alu.prx)"
|
||||
print("Please install the pspsdk and run make in common/ and in all the tests")
|
||||
print("(checked for existence of cpu/cpu_alu/cpu_alu.prx)")
|
||||
sys.exit(1)
|
||||
|
||||
for p in PPSSPP_EXECUTABLES:
|
||||
|
@ -152,13 +153,13 @@ def init():
|
|||
break
|
||||
|
||||
if not PPSSPP_EXE:
|
||||
print "PPSSPP executable missing, please build one."
|
||||
print("PPSSPP executable missing, please build one.")
|
||||
sys.exit(1)
|
||||
|
||||
def tcprint(arg):
|
||||
global teamcity_mode
|
||||
if teamcity_mode:
|
||||
print arg
|
||||
print(arg)
|
||||
|
||||
def run_tests(test_list, args):
|
||||
global PPSSPP_EXE, TIMEOUT
|
||||
|
@ -170,10 +171,10 @@ def run_tests(test_list, args):
|
|||
expected_filename = TEST_ROOT + test + ".expected"
|
||||
|
||||
elf_filename = TEST_ROOT + test + ".prx"
|
||||
print elf_filename
|
||||
print(elf_filename)
|
||||
|
||||
if not os.path.exists(elf_filename):
|
||||
print "WARNING: no prx, trying elf"
|
||||
print("WARNING: no prx, trying elf")
|
||||
elf_filename = TEST_ROOT + test + ".elf"
|
||||
|
||||
if not os.path.exists(elf_filename):
|
||||
|
@ -201,14 +202,14 @@ def run_tests(test_list, args):
|
|||
output = c.output.strip()
|
||||
|
||||
if c.timeout:
|
||||
print output
|
||||
print "Test exceded limit of %d seconds." % TIMEOUT
|
||||
print(output)
|
||||
print("Test exceded limit of %d seconds." % TIMEOUT)
|
||||
tcprint("##teamcity[testFailed name='%s' message='Test timeout']" % test)
|
||||
tcprint("##teamcity[testFinished name='%s']" % test)
|
||||
continue
|
||||
|
||||
if output.startswith("TESTERROR"):
|
||||
print "Failed to run test " + elf_filename + "!"
|
||||
print("Failed to run test " + elf_filename + "!")
|
||||
tests_failed.append(test)
|
||||
tcprint("##teamcity[testFailed name='%s' message='Failed to run test']" % test)
|
||||
tcprint("##teamcity[testFinished name='%s']" % test)
|
||||
|
@ -220,45 +221,45 @@ def run_tests(test_list, args):
|
|||
|
||||
for i in range(0, min(len(output_lines), len(expected_lines))):
|
||||
if output_lines[i] != expected_lines[i]:
|
||||
print "E%i < %s" % (i + 1, expected_lines[i])
|
||||
print "O%i > %s" % (i + 1, output_lines[i])
|
||||
print("E%i < %s" % (i + 1, expected_lines[i]))
|
||||
print("O%i > %s" % (i + 1, output_lines[i]))
|
||||
different = True
|
||||
|
||||
if len(output_lines) != len(expected_lines):
|
||||
for i in range(len(output_lines), len(expected_lines)):
|
||||
print "E%i < %s" % (i + 1, expected_lines[i])
|
||||
print("E%i < %s" % (i + 1, expected_lines[i]))
|
||||
for i in range(len(expected_lines), len(output_lines)):
|
||||
print "O%i > %s" % (i + 1, output_lines[i])
|
||||
print "*** Different number of lines!"
|
||||
print("O%i > %s" % (i + 1, output_lines[i]))
|
||||
print("*** Different number of lines!")
|
||||
different = True
|
||||
|
||||
if not different:
|
||||
if '-v' in args:
|
||||
print "++++++++++++++ The Equal Output +++++++++++++"
|
||||
print "\n".join(output_lines)
|
||||
print "+++++++++++++++++++++++++++++++++++++++++++++"
|
||||
print " " + test + " - passed!"
|
||||
print("++++++++++++++ The Equal Output +++++++++++++")
|
||||
print("\n".join(output_lines))
|
||||
print("+++++++++++++++++++++++++++++++++++++++++++++")
|
||||
print(" " + test + " - passed!")
|
||||
tests_passed.append(test)
|
||||
tcprint("##teamcity[testFinished name='%s']" % test)
|
||||
else:
|
||||
if '-v' in args:
|
||||
print "============== output from failed " + test + " :"
|
||||
print output
|
||||
print "============== expected output:"
|
||||
print expected_output
|
||||
print "==============================="
|
||||
print("============== output from failed " + test + " :")
|
||||
print(output)
|
||||
print("============== expected output:")
|
||||
print(expected_output)
|
||||
print("===============================")
|
||||
tests_failed.append(test)
|
||||
tcprint("##teamcity[testFailed name='%s' message='Output different from expected file']" % test)
|
||||
tcprint("##teamcity[testFinished name='%s']" % test)
|
||||
|
||||
print "%i tests passed, %i tests failed." % (
|
||||
len(tests_passed), len(tests_failed))
|
||||
print("%i tests passed, %i tests failed." % (
|
||||
len(tests_passed), len(tests_failed)))
|
||||
|
||||
if len(tests_failed):
|
||||
print "Failed tests:"
|
||||
print("Failed tests:")
|
||||
for t in tests_failed:
|
||||
print " " + t
|
||||
print "Ran " + PPSSPP_EXE
|
||||
print(" " + t)
|
||||
print("Ran " + PPSSPP_EXE)
|
||||
|
||||
|
||||
def main():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue