mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-05 07:28:29 -04:00
make the web site a bit prettier
This commit is contained in:
parent
5ed2c02bbd
commit
7bbbe7f7fc
@ -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
|
import optparse, fnmatch, time, glob
|
||||||
|
|
||||||
os.putenv('TMPDIR', util.reltopdir('tmp'))
|
os.putenv('TMPDIR', util.reltopdir('tmp'))
|
||||||
|
|
||||||
@ -152,31 +152,95 @@ def run_step(step):
|
|||||||
|
|
||||||
raise RuntimeError("Unknown step %s" % step)
|
raise RuntimeError("Unknown step %s" % step)
|
||||||
|
|
||||||
|
class TestResult(object):
|
||||||
|
'''test result class'''
|
||||||
|
def __init__(self, name, result, elapsed):
|
||||||
|
self.name = name
|
||||||
|
self.result = result
|
||||||
|
self.elapsed = "%.1f" % elapsed
|
||||||
|
|
||||||
|
class TestFile(object):
|
||||||
|
'''test result file'''
|
||||||
|
def __init__(self, name, fname):
|
||||||
|
self.name = name
|
||||||
|
self.fname = fname
|
||||||
|
|
||||||
|
class TestResults(object):
|
||||||
|
'''test results class'''
|
||||||
|
def __init__(self):
|
||||||
|
self.date = time.asctime()
|
||||||
|
self.tests = []
|
||||||
|
self.files = []
|
||||||
|
|
||||||
|
def add(self, name, result, elapsed):
|
||||||
|
'''add a result'''
|
||||||
|
self.tests.append(TestResult(name, result, elapsed))
|
||||||
|
|
||||||
|
def addfile(self, name, fname):
|
||||||
|
'''add a result file'''
|
||||||
|
self.files.append(TestFile(name, fname))
|
||||||
|
|
||||||
|
def addglob(self, name, pattern):
|
||||||
|
'''add a set of files'''
|
||||||
|
import glob
|
||||||
|
for f in glob.glob(util.reltopdir('../buildlogs/%s' % pattern)):
|
||||||
|
self.addfile(name, os.path.basename(f))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def write_webresults(results):
|
||||||
|
'''write webpage 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()
|
||||||
|
f = open(util.reltopdir("../buildlogs/index.html"), mode='w')
|
||||||
|
t.write(f, html, results)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run_tests(steps):
|
def run_tests(steps):
|
||||||
'''run a list of steps'''
|
'''run a list of steps'''
|
||||||
|
|
||||||
|
results = TestResults()
|
||||||
|
|
||||||
passed = True
|
passed = True
|
||||||
failed = []
|
failed = []
|
||||||
for step in steps:
|
for step in steps:
|
||||||
if skip_step(step):
|
if skip_step(step):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
t1 = time.time()
|
||||||
print(">>>> RUNNING STEP: %s at %s" % (step, time.asctime()))
|
print(">>>> RUNNING STEP: %s at %s" % (step, time.asctime()))
|
||||||
try:
|
try:
|
||||||
if not run_step(step):
|
if not run_step(step):
|
||||||
print(">>>> FAILED STEP: %s at %s" % (step, time.asctime()))
|
print(">>>> FAILED STEP: %s at %s" % (step, time.asctime()))
|
||||||
passed = False
|
passed = False
|
||||||
failed.append(step)
|
failed.append(step)
|
||||||
|
results.add(step, "FAILED", time.time() - t1)
|
||||||
continue
|
continue
|
||||||
except Exception, msg:
|
except Exception, msg:
|
||||||
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))
|
||||||
|
results.add(step, "FAILED", time.time() - t1)
|
||||||
raise
|
raise
|
||||||
|
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:
|
||||||
print("FAILED %u tests: %s" % (len(failed), failed))
|
print("FAILED %u tests: %s" % (len(failed), failed))
|
||||||
|
|
||||||
|
results.addfile('Full Logs', 'autotest-output.txt')
|
||||||
|
results.addglob('DataFlash Log', '*.flashlog')
|
||||||
|
results.addglob("MAVLink log", '*.mavlog')
|
||||||
|
results.addglob("GPX track", '*.gpx')
|
||||||
|
results.addglob("KML track", '*.kml')
|
||||||
|
|
||||||
|
write_webresults(results)
|
||||||
|
|
||||||
return passed
|
return passed
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
26
Tools/autotest/web/index.html
Normal file
26
Tools/autotest/web/index.html
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<HTML>
|
||||||
|
<HEAD>
|
||||||
|
<TITLE>ArduPilot Automatic Testing</TITLE>
|
||||||
|
</HEAD>
|
||||||
|
<BODY>
|
||||||
|
<image src="../APM/Tools/autotest/web/logo.png"/>
|
||||||
|
<h1>ArduPilot Automatic Testing</h1>
|
||||||
|
|
||||||
|
<h2>Automatic test run at ${date}</h2>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
${{tests:<li>${name} - ${result} (${elapsed} seconds)</li>
|
||||||
|
}}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>Test logs</h2>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
${{files:<li>${name} - <a href="${fname}">${fname}</a>
|
||||||
|
}}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
</BODY>
|
||||||
|
</HTML>
|
Loading…
Reference in New Issue
Block a user