this repo has no description
at fixPythonPipStalling 129 lines 3.6 kB view raw
1#!/usr/bin/env python 2import os 3import glob 4import subprocess 5import time 6from xml.dom.minidom import Document 7 8TEST_ARCHITECTURES = [ "i386", "x86-64" ] 9TEST_PLATFORMS = tuple([ "10.2", "10.6", "10.8" ]) 10 11successful_tests = {} 12failed_tests = {} 13dyld_command = "dyld" 14 15def main(): 16 global dyld_command 17 orig_cwd = os.getcwd() 18 19 if 'DYLD' in os.environ: 20 dyld_command = os.environ['DYLD'] 21 22 if dyld_command.endswith('32'): 23 TEST_ARCHITECTURES.remove('x86-64') 24 elif dyld_command.endswith('64'): 25 TEST_ARCHITECTURES.remove('i386') 26 27 os.chdir(os.path.dirname(os.path.realpath(__file__))) 28 tests = glob.glob('i386/*.stdout'); 29 30 for arch in TEST_ARCHITECTURES: 31 successful_tests[arch] = {} 32 failed_tests[arch] = {} 33 34 for plat in TEST_PLATFORMS: 35 successful_tests[arch][plat] = [] 36 failed_tests[arch][plat] = [] 37 38 for fileName in tests: 39 runTest(fileName[5:-7]) 40 41 src_dir = os.path.realpath(os.getcwd() + '/..') 42 os.chdir(orig_cwd) 43 writeTestResults("report.xml", src_dir) 44 45def runTest(fileName): 46 print "************" 47 print "Running test " + fileName 48 print "************" 49 50 51 for arch in TEST_ARCHITECTURES: 52 expectedOutput = open(arch + "/" + fileName + ".stdout", "r").read() 53 54 for plat in TEST_PLATFORMS: 55 print "* Testing " + arch + "/" + plat 56 path = arch + "/" + plat + "/" + fileName 57 58 if not os.path.exists(path + ".bin"): 59 print "Skipping " + path 60 continue 61 62 try: 63 time_start = time.time() 64 output = subprocess.check_output([dyld_command, path + ".bin"]) 65 elapsed_time = (time.time()-time_start) 66 67 if output != expectedOutput: 68 description = "Expected output:\n" + expectedOutput + "\n\nActual output:\n" + output 69 70 print "*** FAILED!" 71 print description 72 73 failed_tests[arch][plat].append({ 'test': fileName, 'output': description, 'time': elapsed_time }) 74 else: 75 successful_tests[arch][plat].append({ 'test': fileName, 'output': output, 'time': elapsed_time }) 76 77 except subprocess.CalledProcessError: 78 elapsed_time = (time.time()-time_start) 79 failed_tests[arch][plat].append({ 'test': fileName, 'output': "Non-zero exit code", 'time': elapsed_time }) 80 81def writeTestResults(outFile, sourcesDir): 82 doc = Document() 83 file = open(outFile, "w") 84 85 testLog = doc.createElement("testsuites"); 86 87 for arch in TEST_ARCHITECTURES: 88 89 for plat in TEST_PLATFORMS: 90 91 platNode = doc.createElement("testsuite") 92 platNode.setAttribute("name", arch+"/"+plat) 93 platNode.setAttribute("tests", str(len(failed_tests[arch][plat]) + len(successful_tests[arch][plat]))) 94 95 for test in failed_tests[arch][plat]: 96 testNode = doc.createElement("testcase") 97 testNode.setAttribute("name", test['test']) 98 99 errorNode = doc.createElement("failure") 100 #errorNode.setAttribute("file", sourcesDir + '/' + test['test']) 101 #errorNode.setAttribute("line", "0") 102 errorNode.appendChild(doc.createTextNode(test['output'])) 103 104 #timeNode = doc.createElement("TestingTime") 105 testNode.setAttribute("time", str(test['time']) + "s") 106 #testNode.appendChild(timeNode) 107 108 testNode.appendChild(errorNode) 109 platNode.appendChild(testNode) 110 111 for test in successful_tests[arch][plat]: 112 testNode = doc.createElement("testcase") 113 testNode.setAttribute("name", test['test']) 114 115 #timeNode = doc.createElement("TestingTime") 116 testNode.setAttribute("time", str(test['time']) + "s") 117 #testNode.appendChild(timeNode) 118 platNode.appendChild(testNode) 119 120 testLog.appendChild(platNode) 121 122 doc.appendChild(testLog) 123 doc.writexml(file, encoding="utf-8") 124 file.close() 125 126 127if __name__ == "__main__": 128 main() 129