summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan Skinner <aidan@apache.org>2008-03-03 14:35:58 +0000
committerAidan Skinner <aidan@apache.org>2008-03-03 14:35:58 +0000
commitb9b20ea2e705d6258e3ba5cafc25e44c2fae9221 (patch)
tree703f3f08e0a3b6d40975d9735ef361f824d5a8cb
parente954a2147afe343f0cbd9c5522232eda88541594 (diff)
downloadqpid-python-b9b20ea2e705d6258e3ba5cafc25e44c2fae9221.tar.gz
Import test fail script
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@633099 13f79535-47bb-0310-9956-ffa450edef68
-rwxr-xr-xjava/systests/etc/bin/fail.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/java/systests/etc/bin/fail.py b/java/systests/etc/bin/fail.py
new file mode 100755
index 0000000000..d36c4568ff
--- /dev/null
+++ b/java/systests/etc/bin/fail.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+
+import os
+import re
+import datetime
+
+from optparse import OptionParser
+
+BASE_CMD = "mvn -Dskip.python.test=true %s test"
+
+def main():
+ parser = OptionParser()
+ parser.add_option("-t", "--test", dest="test",
+ action="store", type="string",
+ help="run specific tests")
+ parser.add_option("-c", "--continuous", dest="continuous",
+ action="store_true", default=False,
+ help="run tests after failures, don't stop")
+
+
+ (options, args) = parser.parse_args()
+
+ # determine command to run
+ if (options.test != None):
+ cmd = (BASE_CMD % ("-Dtest="+options.test))
+ else:
+ cmd = (BASE_CMD % (""))
+
+ run_forever = options.continuous
+
+
+ failed_runs = []
+ iteration = 0
+ fail_match = re.compile("BUILD SUCCESSFUL")
+ done = False
+
+ while (run_forever or not (len(failed_runs) > 0)):
+ iteration = iteration + 1
+ if (run_forever):
+ extra_text = (", %d failures so far: %s:" % (len(failed_runs), failed_runs))
+ else:
+ extra_text = ""
+ print ("%s Test run %d%s" % (datetime.datetime.today().isoformat(), iteration, extra_text))
+ (child_stdin, child_stdout_and_stderr) = os.popen4(cmd)
+ output = child_stdout_and_stderr.read()
+ child_stdin.close()
+ child_stdout_and_stderr.close()
+ matches = fail_match.search(output)
+ if (matches == None):
+ failed_runs.append(iteration)
+ output_name = ("test-run-%d.out" % (iteration))
+ #write testouput
+ test_output = file(output_name, "w")
+ test_output.write(output)
+ test_output.close()
+ #tar test-output and surefire reports together
+ find_stdout = os.popen("find . -type d -name surefire-reports")
+ surefire_dirs = find_stdout.read().replace('\n', ' ')
+ find_stdout.close()
+ tarcmd = ("tar -zcf test-failures-%d.tar.gz %s %s" % (iteration, output_name, surefire_dirs))
+ tar_stdout = os.popen(tarcmd)
+ tar_output = tar_stdout.read()
+ tar_exitstatus = tar_stdout.close()
+ print ("Something failed! Check %s" % (output_name))
+ if (tar_exitstatus != None):
+ print ("tar exited abornmally, aborting\n %s" % (tar_output))
+ run_forever = False
+
+if __name__ == "__main__":
+ main() \ No newline at end of file