Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1189)

Unified Diff: tools/purge_flakies.py

Issue 7688004: Added tools for finding and purging flaky tests (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/find_flakies.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/purge_flakies.py
diff --git a/tools/purge_flakies.py b/tools/purge_flakies.py
new file mode 100755
index 0000000000000000000000000000000000000000..a24eea0871916ee7518cb27906c69e6c48cfa3be
--- /dev/null
+++ b/tools/purge_flakies.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+
+
M-A Ruel 2011/08/19 15:07:01 Just add the copyright header there
clee 2011/08/19 16:53:57 Done.
+"""Usage: python %prog testname [infile] [num_tests]
+"""
+
+
+import os
+import re
+import subprocess
+import sys
+import time
+
+
+def main():
+ test = sys.argv[1]
+ path = "/usr/local/google/home/charleslee/chromium/src/out/Debug/" + test
+ test_name_regex = r"(?P<testname>(\w+/)?\w+\.\w+(/\d+)?)"
+ test_start = re.compile("\[\s+RUN\s+\] " + test_name_regex)
+ test_list = []
+ if len(sys.argv) > 2:
+ infile = sys.argv[2]
+ data_list = open(infile, "r")
+ for line in data_list:
+ test_list.append(line.rstrip())
+ data_list.close()
+ else:
+ proc = subprocess.Popen([path], stdout=subprocess.PIPE)
+ while True:
+ line = proc.stdout.readline()
+ if not line:
+ if proc.poll() is not None:
+ break
+ continue
+ sys.stdout.write(line)
+ results = test_start.search(line)
+ if results:
+ test_list.append(results.group("testname"))
+ failures = []
+ index = 0
+ total = len(test_list)
+ print total
+ if len(sys.argv) > 3:
+ num_tests = int(sys.argv[3])
+ test_list = test_list[:num_tests]
+ for test_name in test_list:
+ num_fails = 0
+ num_terminated = 0
+ procs = []
+ args = [path, "--gtest_filter=" + test_name, "--gtest_repeat=10"]
+ while len(procs) < 18:
+ procs.append(subprocess.Popen(args))
+ seconds = 0
+ while procs:
+ for proc in procs:
+ if proc.poll() is not None:
+ if proc.returncode != 0:
+ ++num_fails
+ procs.remove(proc)
+ if seconds > 1000:
+ num_fails += len(procs)
+ num_terminated = len(procs)
+ while procs:
+ procs.pop().terminate()
+ time.sleep(1)
+ seconds += 1
+ if num_fails:
+ line = "%s: %i" % (test_name, num_fails)
+ if num_terminated:
+ line += ", %i terminated" % num_terminated
+ failures.append(line)
+ print "%s (%i / %i): %i" % (test_name, index, total, num_fails)
+ index += 1
+ time.sleep(1)
+ print failures
+ data_file = open(test + "_purges", "w")
+ for line in failures:
+ data_file.write(line + "\n")
+ data_file.close()
+
+
+if __name__ == "__main__":
+ main()
+
M-A Ruel 2011/08/19 15:07:01 remove the extra line there
clee 2011/08/19 16:53:57 Done.
« no previous file with comments | « tools/find_flakies.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698