def reg_test_gc(argv): usage = """ ./reg_test_gc [--before|-b 2000-00-00] testfile.ini """ if len(sys.argv) == 1: print usage sys.exit(2) try: opts, next = getopt.getopt(argv[1:], "b:", ["before="]) except getopt.GetoptError: print "invalid calling sequence" print usage sys.exit(2) # defaults gcdate = "" for o, a in opts: if o == "--before" or o == "-b": gcdate = a try: testFile = next[0] except IndexError: print "ERROR: a test file was not specified" print usage sys.exit(2) if not gcdate: print "ERROR: date was not specified" print usage sys.exit(2) gcd = valid_date(gcdate) if gcd == '': print "ERROR: invalid date", gcdate print usage sys.exit(2) workdir = os.getcwd() reg_test.bold("loading " + testFile) suite, testList = reg_test.LoadParams(testFile) activeTestList = [t.name for t in testList] benchmarkTestList = [ t for t in testList if not (t.compileTest or t.restartTest) ] benchmarkNotFound = {} for t in benchmarkTestList: benchmarkNotFound[t.name] = '' ### clean up the web dir reg_test.bold("\ncleaning " + suite.webTopDir) os.chdir(suite.webTopDir) validDirs = [] for d in os.listdir(suite.webTopDir): if (d.startswith("20") and os.path.isdir(d)): statusFile = d + '/' + d + '.status' if (os.path.isfile(statusFile)): validDirs.append(d) validDirs.sort() validDirs.reverse() latestBMDate = {} for d in validDirs: bmtests = benchmarkNotFound.keys() if d >= gcd and bmtests: if isBenchmarkDir(d): for t in bmtests: if findBenchmark(d, t): del benchmarkNotFound[t] latestBMDate[t] = d else: if isBenchmarkDir(d) and bmtests: found = False for t in bmtests: if findBenchmark(d, t): found = True del benchmarkNotFound[t] latestBMDate[t] = d if not found: rmDir(d) else: rmDir(d) ### clean up the test dir testDirs = os.path.join(suite.testTopDir, suite.suiteName + "-tests") reg_test.bold("\ncleaning " + testDirs) os.chdir(testDirs) validDirs = [] for d in os.listdir(testDirs): if (d.startswith("20") and os.path.isdir(d)): validDirs.append(d) validDirs.sort() validDirs.reverse() for d in validDirs: if d < gcd: tests = [ t for t in os.listdir(d) if os.path.isdir(os.path.join(d, t)) ] found = False for t in tests: if t in latestBMDate.keys() and latestBMDate[t] == d: found = True break if not found: rmDir(d) reg_test.bold("\ncreating suite report...") tableHeight = min(max(suite.lenTestName, 4), 16) reg_test.reportAllRuns(suite, activeTestList, suite.webTopDir, tableHeight=tableHeight) reg_test.bold("\nGarbage cleaning finished.")
def reg_test_blame(argv): usage = """ ./reg_test_blame [--single_test test] testfile.ini """ if len(sys.argv) == 1: print usage sys.exit(2) try: opts, next = getopt.getopt(argv[1:], "", ["single_test="]) except getopt.GetoptError: print "invalid calling sequence" print usage sys.exit(2) # defaults single_test = "" for o, a in opts: if o == "--single_test": single_test = a try: testFile = next[0] except IndexError: print "ERROR: a test file was not specified" print usage sys.exit(2) origdir = os.getcwd() #-------------------------------------------------------------------------- # read in the test information #-------------------------------------------------------------------------- reg_test.bold("loading " + testFile) suite, testList = reg_test.LoadParams(testFile) if (len(testList) == 0): reg_test.fail("No valid tests defined") #-------------------------------------------------------------------------- # if we are doing a single test, remove all other tests #-------------------------------------------------------------------------- if not single_test == "": found = 0 for obj in testList: if (obj.name == single_test): found = 1 newTestList = [obj] break if (not found): fail("ERROR: %s is not a valid test" % (single_test)) else: testList = newTestList webDirs = buildWebDirs(suite) # build list of failed tests failedTestList = [] for obj in testList: to2 = check_test_status(obj, suite, webDirs) if not to2.passed: failedTestList.append(to2) if not failedTestList: reg_test.bold("All tests are successful. No one to blame.") sys.exit(0) else: print "\n" reg_test.bold("List of failed test:") for obj in failedTestList: print " %s " % obj.name badCommitList = [] for obj in failedTestList: print "\n" reg_test.bold("Working on " + obj.name) bad_commits, oldestFailed = find_someone_to_blame( obj, suite, testFile, origdir) badCommitList.append((bad_commits, oldestFailed)) print "\n" reg_test.bold("reporting...") for bad, obj in zip(badCommitList, failedTestList): coms = bad[0] oldestFailed = bad[1] print "\n" print obj.name, "first failed at" for src in coms.keys(): print " ", src, ', '.join(coms[src][:-1]) if oldestFailed: print " The strang thing is the above test was successful last time with the same source code." else: last_commit_time = 0 failed_src = '' for src in coms.keys(): if coms[src][-1] > last_commit_time: last_commit_time = coms[src][-1] failed_src = src print "\n" reg_test.bold("Regtester blames " + failed_src + "!")
def reg_test_gc(argv): usage = """ ./reg_test_gc [--before|-b 2000-00-00] testfile.ini """ if len(sys.argv) == 1: print usage sys.exit(2) try: opts, next = getopt.getopt(argv[1:], "b:", ["before="]) except getopt.GetoptError: print "invalid calling sequence" print usage sys.exit(2) # defaults gcdate = "" for o, a in opts: if o == "--before" or o == "-b" : gcdate = a try: testFile = next[0] except IndexError: print "ERROR: a test file was not specified" print usage sys.exit(2) if not gcdate: print "ERROR: date was not specified" print usage sys.exit(2) gcd = valid_date(gcdate) if gcd == '': print "ERROR: invalid date", gcdate print usage sys.exit(2) workdir = os.getcwd() reg_test.bold("loading " + testFile) suite, testList = reg_test.LoadParams(testFile) activeTestList = [t.name for t in testList] benchmarkTestList = [t for t in testList if not (t.compileTest or t.restartTest)] benchmarkNotFound = {} for t in benchmarkTestList: benchmarkNotFound[t.name] = '' ### clean up the web dir reg_test.bold("\ncleaning " + suite.webTopDir) os.chdir(suite.webTopDir) validDirs = [] for d in os.listdir(suite.webTopDir): if (d.startswith("20") and os.path.isdir(d)): statusFile = d + '/' + d + '.status' if (os.path.isfile(statusFile)): validDirs.append(d) validDirs.sort() validDirs.reverse() latestBMDate = {} for d in validDirs: bmtests = benchmarkNotFound.keys() if d >= gcd and bmtests: if isBenchmarkDir(d): for t in bmtests: if findBenchmark(d,t): del benchmarkNotFound[t] latestBMDate[t] = d else: if isBenchmarkDir(d) and bmtests: found = False for t in bmtests: if findBenchmark(d,t): found = True del benchmarkNotFound[t] latestBMDate[t] = d if not found: rmDir(d) else: rmDir(d) ### clean up the test dir testDirs = os.path.join(suite.testTopDir,suite.suiteName+"-tests") reg_test.bold("\ncleaning " + testDirs) os.chdir(testDirs) validDirs = [] for d in os.listdir(testDirs): if (d.startswith("20") and os.path.isdir(d)): validDirs.append(d) validDirs.sort() validDirs.reverse() for d in validDirs: if d < gcd: tests = [t for t in os.listdir(d) if os.path.isdir(os.path.join(d,t))] found = False for t in tests: if t in latestBMDate.keys() and latestBMDate[t] == d: found = True break if not found: rmDir(d) reg_test.bold("\ncreating suite report...") tableHeight = min(max(suite.lenTestName, 4), 16) reg_test.reportAllRuns(suite, activeTestList, suite.webTopDir, tableHeight=tableHeight) reg_test.bold("\nGarbage cleaning finished.")
def reg_test_blame(argv): usage = """ ./reg_test_blame [--single_test test] testfile.ini """ if len(sys.argv) == 1: print usage sys.exit(2) try: opts, next = getopt.getopt(argv[1:], "", ["single_test="]) except getopt.GetoptError: print "invalid calling sequence" print usage sys.exit(2) # defaults single_test = "" for o, a in opts: if o == "--single_test": single_test = a try: testFile = next[0] except IndexError: print "ERROR: a test file was not specified" print usage sys.exit(2) origdir = os.getcwd() #-------------------------------------------------------------------------- # read in the test information #-------------------------------------------------------------------------- reg_test.bold("loading " + testFile) suite, testList = reg_test.LoadParams(testFile) if (len(testList) == 0): reg_test.fail("No valid tests defined") #-------------------------------------------------------------------------- # if we are doing a single test, remove all other tests #-------------------------------------------------------------------------- if not single_test == "": found = 0 for obj in testList: if (obj.name == single_test): found = 1 newTestList = [obj] break if (not found): fail("ERROR: %s is not a valid test" % (single_test)) else: testList = newTestList webDirs = buildWebDirs(suite) # build list of failed tests failedTestList = [] for obj in testList: to2 = check_test_status(obj, suite, webDirs) if not to2.passed: failedTestList.append(to2) if not failedTestList: reg_test.bold("All tests are successful. No one to blame.") sys.exit(0) else: print "\n" reg_test.bold("List of failed test:") for obj in failedTestList: print " %s " % obj.name badCommitList = [] for obj in failedTestList: print "\n" reg_test.bold("Working on "+obj.name) bad_commits, oldestFailed = find_someone_to_blame(obj, suite, testFile, origdir) badCommitList.append((bad_commits, oldestFailed)) print "\n" reg_test.bold("reporting...") for bad, obj in zip(badCommitList,failedTestList) : coms = bad[0] oldestFailed = bad[1] print "\n" print obj.name, "first failed at" for src in coms.keys(): print " ", src, ', '.join(coms[src][:-1]) if oldestFailed: print " The strang thing is the above test was successful last time with the same source code." else: last_commit_time = 0 failed_src = '' for src in coms.keys(): if coms[src][-1] > last_commit_time: last_commit_time = coms[src][-1] failed_src = src print "\n" reg_test.bold("Regtester blames "+failed_src+"!")