From 36ecc34a4b4367def4d3c4a2ca59451ab75d3c7d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 9 Nov 2011 23:43:25 +1100 Subject: [PATCH] autotest: show git hash in html --- Tools/autotest/autotest.py | 10 +++++----- Tools/autotest/util.py | 7 +++++++ Tools/autotest/web/index.html | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Tools/autotest/autotest.py b/Tools/autotest/autotest.py index c90bf75165..9bdca5403d 100755 --- a/Tools/autotest/autotest.py +++ b/Tools/autotest/autotest.py @@ -3,7 +3,7 @@ # Andrew Tridgell, October 2011 import pexpect, os, util, sys, shutil, arducopter -import optparse, fnmatch, time, glob +import optparse, fnmatch, time, glob, trackback os.putenv('TMPDIR', util.reltopdir('tmp')) @@ -169,6 +169,7 @@ class TestResults(object): '''test results class''' def __init__(self): self.date = time.asctime() + self.githash = util.loadfile(util.reltopdir('.git/refs/heads/master')) self.tests = [] self.files = [] @@ -193,9 +194,7 @@ def write_webresults(results): sys.path.insert(0, os.path.join(util.reltopdir("../pymavlink/generator"))) import mavtemplate t = mavtemplate.MAVTemplate() - f = open(util.reltopdir('Tools/autotest/web/index.html'), mode='r') - html = f.read() - f.close() + html = util.loadfile('Tools/autotest/web/index.html') f = open(util.reltopdir("../buildlogs/index.html"), mode='w') t.write(f, html, results) f.close() @@ -226,8 +225,9 @@ def run_tests(steps): passed = False failed.append(step) print(">>>> FAILED STEP: %s at %s (%s)" % (step, time.asctime(), msg)) + traceback.print_exc(file=sys.stdout) results.add(step, "FAILED", time.time() - t1) - raise + pass results.add(step, "PASSED", time.time() - t1) print(">>>> PASSED STEP: %s at %s" % (step, time.asctime())) if not passed: diff --git a/Tools/autotest/util.py b/Tools/autotest/util.py index 8f9a779285..d27943fe22 100644 --- a/Tools/autotest/util.py +++ b/Tools/autotest/util.py @@ -153,3 +153,10 @@ def mkdir_p(dir): return mkdir_p(os.path.dirname(dir)) os.mkdir(dir) + +def loadfile(fname): + '''load a file as a string''' + f = open(fname, mode='r') + r = f.read() + f.close() + return r diff --git a/Tools/autotest/web/index.html b/Tools/autotest/web/index.html index 4447c46872..01d1eb2ebb 100644 --- a/Tools/autotest/web/index.html +++ b/Tools/autotest/web/index.html @@ -4,11 +4,13 @@ ArduPilot Automatic Testing - +

ArduPilot Automatic Testing

Automatic test run at ${date}

+Test run on git commit ${githash} +