mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
Autotest: Add badge to index.html
This commit is contained in:
parent
cfb3dfc4e5
commit
963905f812
@ -484,6 +484,31 @@ class TestResults(object):
|
|||||||
for f in glob.glob(buildlogs_path(pattern)):
|
for f in glob.glob(buildlogs_path(pattern)):
|
||||||
self.addimage(name, os.path.basename(f))
|
self.addimage(name, os.path.basename(f))
|
||||||
|
|
||||||
|
def generate_badge(self):
|
||||||
|
"""
|
||||||
|
Gets the badge template, populates and saves the result to buildlogs
|
||||||
|
path.
|
||||||
|
"""
|
||||||
|
passed_tests = len([t for t in self.tests if "PASSED" in t.result])
|
||||||
|
total_tests = len(self.tests)
|
||||||
|
badge_color = "#4c1" if passed_tests == total_tests else "#e05d44"
|
||||||
|
|
||||||
|
badge_text = "{0}/{1}".format(passed_tests, total_tests)
|
||||||
|
# Text length so it is not stretched by svg
|
||||||
|
text_length = len(badge_text) * 70
|
||||||
|
|
||||||
|
# Load template file
|
||||||
|
template_path = 'Tools/autotest/web/autotest-badge-template.svg'
|
||||||
|
with open(util.reltopdir(template_path), "r") as f:
|
||||||
|
template = f.read()
|
||||||
|
|
||||||
|
# Add our results to the template
|
||||||
|
badge = template.format(color=badge_color,
|
||||||
|
text=badge_text,
|
||||||
|
text_length=text_length)
|
||||||
|
with open(buildlogs_path("autotest-badge.svg"), "w") as f:
|
||||||
|
f.write(badge)
|
||||||
|
|
||||||
|
|
||||||
def write_webresults(results_to_write):
|
def write_webresults(results_to_write):
|
||||||
"""Write webpage results."""
|
"""Write webpage results."""
|
||||||
@ -495,6 +520,7 @@ def write_webresults(results_to_write):
|
|||||||
f.close()
|
f.close()
|
||||||
for f in glob.glob(util.reltopdir('Tools/autotest/web/*.png')):
|
for f in glob.glob(util.reltopdir('Tools/autotest/web/*.png')):
|
||||||
shutil.copy(f, buildlogs_path(os.path.basename(f)))
|
shutil.copy(f, buildlogs_path(os.path.basename(f)))
|
||||||
|
results_to_write.generate_badge()
|
||||||
|
|
||||||
|
|
||||||
def write_fullresults():
|
def write_fullresults():
|
||||||
|
21
Tools/autotest/web/autotest-badge-template.svg
Normal file
21
Tools/autotest/web/autotest-badge-template.svg
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink" width="104" height="20">
|
||||||
|
<linearGradient id="b" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="a">
|
||||||
|
<rect width="104" height="20" rx="3" fill="#fff"/>
|
||||||
|
</clipPath>
|
||||||
|
<g clip-path="url(#a)">
|
||||||
|
<path fill="#555" d="M0 0h57v20H0z"/>
|
||||||
|
<path fill="{color}" d="M57 0h47v20H57z"/> 4c1
|
||||||
|
<path fill="url(#b)" d="M0 0h104v20H0z"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
||||||
|
<text x="295" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="470">Autotest</text>
|
||||||
|
<text x="295" y="140" transform="scale(.1)" textLength="470">Autotest</text>
|
||||||
|
<text x="795" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="{text_length}">{text}</text>
|
||||||
|
<text x="795" y="140" transform="scale(.1)" textLength="{text_length}">{text}</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
@ -32,6 +32,7 @@ Servers by <a href=http://www.jDrones.com/>jDrones</a>
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2>Test Results</h2>
|
<h2>Test Results</h2>
|
||||||
|
<img src="autotest-badge.svg"></img>
|
||||||
|
|
||||||
<ul id="testresults">
|
<ul id="testresults">
|
||||||
${{tests:<li>${name} - ${result} (${elapsed} seconds)</li>
|
${{tests:<li>${name} - ${result} (${elapsed} seconds)</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user