autotest: show git hash in html

This commit is contained in:
Andrew Tridgell 2011-11-09 23:43:25 +11:00
parent 7dbbf187b9
commit 36ecc34a4b
3 changed files with 15 additions and 6 deletions

View File

@ -3,7 +3,7 @@
# Andrew Tridgell, October 2011 # Andrew Tridgell, October 2011
import pexpect, os, util, sys, shutil, arducopter import pexpect, os, util, sys, shutil, arducopter
import optparse, fnmatch, time, glob import optparse, fnmatch, time, glob, trackback
os.putenv('TMPDIR', util.reltopdir('tmp')) os.putenv('TMPDIR', util.reltopdir('tmp'))
@ -169,6 +169,7 @@ class TestResults(object):
'''test results class''' '''test results class'''
def __init__(self): def __init__(self):
self.date = time.asctime() self.date = time.asctime()
self.githash = util.loadfile(util.reltopdir('.git/refs/heads/master'))
self.tests = [] self.tests = []
self.files = [] self.files = []
@ -193,9 +194,7 @@ def write_webresults(results):
sys.path.insert(0, os.path.join(util.reltopdir("../pymavlink/generator"))) sys.path.insert(0, os.path.join(util.reltopdir("../pymavlink/generator")))
import mavtemplate import mavtemplate
t = mavtemplate.MAVTemplate() t = mavtemplate.MAVTemplate()
f = open(util.reltopdir('Tools/autotest/web/index.html'), mode='r') html = util.loadfile('Tools/autotest/web/index.html')
html = f.read()
f.close()
f = open(util.reltopdir("../buildlogs/index.html"), mode='w') f = open(util.reltopdir("../buildlogs/index.html"), mode='w')
t.write(f, html, results) t.write(f, html, results)
f.close() f.close()
@ -226,8 +225,9 @@ def run_tests(steps):
passed = False passed = False
failed.append(step) failed.append(step)
print(">>>> FAILED STEP: %s at %s (%s)" % (step, time.asctime(), msg)) print(">>>> FAILED STEP: %s at %s (%s)" % (step, time.asctime(), msg))
traceback.print_exc(file=sys.stdout)
results.add(step, "FAILED", time.time() - t1) results.add(step, "FAILED", time.time() - t1)
raise pass
results.add(step, "PASSED", time.time() - t1) results.add(step, "PASSED", time.time() - t1)
print(">>>> PASSED STEP: %s at %s" % (step, time.asctime())) print(">>>> PASSED STEP: %s at %s" % (step, time.asctime()))
if not passed: if not passed:

View File

@ -153,3 +153,10 @@ def mkdir_p(dir):
return return
mkdir_p(os.path.dirname(dir)) mkdir_p(os.path.dirname(dir))
os.mkdir(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

View File

@ -4,11 +4,13 @@
<TITLE>ArduPilot Automatic Testing</TITLE> <TITLE>ArduPilot Automatic Testing</TITLE>
</HEAD> </HEAD>
<BODY> <BODY>
<image src="../APM/Tools/autotest/web/logo.png"/> <a href="http://autotest.diydrones.com/"><image src="../APM/Tools/autotest/web/logo.png"/></a>
<h1>ArduPilot Automatic Testing</h1> <h1>ArduPilot Automatic Testing</h1>
<h2>Automatic test run at ${date}</h2> <h2>Automatic test run at ${date}</h2>
Test run on git commit <a href="http://code.google.com/p/ardupilot-mega/source/detail?r=${githash}">${githash}</a>
<ul> <ul>
${{tests:<li>${name} - ${result} (${elapsed} seconds)</li> ${{tests:<li>${name} - ${result} (${elapsed} seconds)</li>
}} }}