From 97a7ab30db82a94a54627110e289c71f49f47832 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sat, 15 Dec 2012 22:47:11 +0000 Subject: [PATCH] Added simple logging of test runs, to make it easier to be sure that tests has been run successfully on the latest code. - Legacy-Id: 5131 --- ietf/utils/test_runner.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ietf/utils/test_runner.py b/ietf/utils/test_runner.py index 4374a4619..ca70f13be 100644 --- a/ietf/utils/test_runner.py +++ b/ietf/utils/test_runner.py @@ -84,7 +84,7 @@ def run_tests_1(test_labels, *args, **kwargs): settings.SITE_ID = 1 assert(not settings.IDTRACKER_BASE_URL.endswith('/')) kwargs["verbosity"] = 0 - django_run_tests(test_labels, *args, **kwargs) + return django_run_tests(test_labels, *args, **kwargs) def run_tests(*args, **kwargs): # Tests that involve switching back and forth between the real @@ -93,5 +93,20 @@ def run_tests(*args, **kwargs): if socket.gethostname().split('.')[0] in ['core3', 'ietfa', 'ietfb', 'ietfc', ]: raise EnvironmentError("Refusing to run tests on production server") ietf.utils.mail.test_mode = True - run_tests_1(*args, **kwargs) - + failures = run_tests_1(*args, **kwargs) + # Record the test result in a file, in order to be able to check the + # results and avoid re-running tests if we've alread run them with OK + # result after the latest code changes: + import os, time, ietf.settings as config + topdir = os.path.dirname(os.path.dirname(config.__file__)) + tfile = open(os.path.join(topdir,"testresult"), "a") + timestr = time.strftime("%Y-%m-%d %H:%M:%S") + if failures: + tfile.write("%s FAILED (failures=%s)\n" % (timestr, failures)) + else: + if args: + tfile.write("%s SUCCESS (tests=%s)\n" % (timestr, repr(list(*args)))) + else: + tfile.write("%s OK\n" % (timestr, )) + tfile.close() + return failures