summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-02-07 23:41:19 +0000
committerGerrit Code Review <review@openstack.org>2013-02-07 23:41:19 +0000
commitbce3806efec31fb0fa536b152d763b333d75120d (patch)
tree6821f16bca4742d2cd421d10724e0cab736f8efc /tools
parent408c6b1dfd8fd76db50b89226ed006f75b0b0c5e (diff)
parent56b7cc79c6c364261567e4c9d4801bd923853607 (diff)
downloadnova-bce3806efec31fb0fa536b152d763b333d75120d.tar.gz
nova-bce3806efec31fb0fa536b152d763b333d75120d.tar.xz
nova-bce3806efec31fb0fa536b152d763b333d75120d.zip
Merge "Add regression testing tool"
Diffstat (limited to 'tools')
-rwxr-xr-xtools/regression_tester.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/tools/regression_tester.py b/tools/regression_tester.py
new file mode 100755
index 000000000..554260fbd
--- /dev/null
+++ b/tools/regression_tester.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+
+"""Tool for checking if patch contains a regression test.
+
+Pass in gerrit review number as parameter, tool will download branch and run
+modified tests without bug fix.
+"""
+
+import string
+import subprocess
+import sys
+
+#TODO(jogo) use proper optParser
+gerrit_number = sys.argv[1]
+
+
+def run(cmd, fail_ok=False):
+ print "running: %s" % cmd
+ try:
+ rval = subprocess.check_output(cmd, shell=True)
+ except subprocess.CalledProcessError:
+ if not fail_ok:
+ print "the above command terminated with an error"
+ sys.exit(1)
+ pass
+ return rval
+
+
+test_works = False
+
+original_branch = run("git rev-parse --abbrev-ref HEAD")
+run("git review -d %s" % gerrit_number)
+# run new tests with old code
+run("git checkout HEAD^ nova")
+run("git checkout HEAD nova/tests")
+
+# identify which tests have changed
+tests = run("git whatchanged --format=oneline -1 | grep \"nova/tests\" "
+ "| cut -f2").split()
+test_list = []
+for test in tests:
+ test_list.append(string.replace(test[0:-3], '/', '.'))
+
+# run new tests, expect them to fail
+expect_failure = run(("tox -epy27 %s 2>&1" % string.join(test_list)),
+ fail_ok=True)
+if "FAILED (id=" in expect_failure:
+ test_works = True
+
+# cleanup
+run("git checkout HEAD nova")
+new_branch = run("git status | head -1 | cut -d ' ' -f 4")
+run("git checkout %s" % original_branch)
+run("git branch -D %s" % new_branch)
+
+
+if test_works:
+ print expect_failure
+ print ""
+ print "*******************************"
+ print "SUCCESS: test covers regression"
+else:
+ print expect_failure
+ print ""
+ print "***************************************"
+ print "FAILURE: test does not cover regression"
+ sys.exit(1)