factor/extra/mason/report/report.factor

146 lines
3.7 KiB
Factor
Raw Normal View History

! Copyright (C) 2008, 2010 Eduardo Cavazos, Slava Pestov.
2008-09-16 00:20:33 -04:00
! See http://factorcode.org/license.txt for BSD license.
2014-11-15 19:20:49 -05:00
USING: assocs combinators.smart debugger fry io.encodings.utf8
io.files io.streams.string kernel literals locals mason.common
mason.config mason.disk math namespaces sequences xml.syntax
xml.writer ;
2008-09-16 00:20:33 -04:00
IN: mason.report
: git-link ( id -- link )
[ "http://github.com/slavapestov/factor/commit/" "" prepend-as ] keep
[XML <a href=<->><-></a> XML] ;
: common-report ( -- xml )
target-os get
target-cpu get
short-host-name
disk-usage
build-dir
current-git-id get git-link
[XML
<h1>Build report for <->/<-></h1>
<table>
<tr><td>Build machine:</td><td><-></td></tr>
<tr><td>Disk usage:</td><td><-></td></tr>
<tr><td>Build directory:</td><td><-></td></tr>
<tr><td>GIT ID:</td><td><-></td></tr>
</table>
XML] ;
2008-09-16 00:20:33 -04:00
: with-report ( quot -- )
[ "report" utf8 ] dip
'[
common-report
_ call( -- xml )
[XML <html><body><-><-></body></html> XML]
write-xml
] with-file-writer ; inline
2008-09-16 00:20:33 -04:00
2009-05-18 17:50:11 -04:00
: file-tail ( file encoding lines -- seq )
[ file-lines ] dip short tail* "\n" join ;
:: failed-report ( error file what -- status )
2008-09-16 00:20:33 -04:00
[
error [ error. ] with-string-writer :> error
2009-05-18 17:50:11 -04:00
file utf8 400 file-tail :> output
[XML
<h2><-what-></h2>
Build output:
<pre><-output-></pre>
Launcher error:
<pre><-error-></pre>
XML]
] with-report
status-error ;
2008-09-16 00:20:33 -04:00
: compile-failed ( error -- status )
"compile-log" "VM compilation failed" failed-report ;
: boot-failed ( error -- status )
"boot-log" "Bootstrap failed" failed-report ;
2008-09-16 00:20:33 -04:00
: test-failed ( error -- status )
"test-log" "Tests failed" failed-report ;
: timings-table ( -- xml )
2009-05-21 01:08:43 -04:00
${
boot-time-file
load-time-file
test-time-file
help-lint-time-file
benchmark-time-file
html-help-time-file
} [
dup eval-file nanos>time
[XML <tr><td><-></td><td><-></td></tr> XML]
] map [XML <h2>Timings</h2> <table><-></table> XML] ;
: error-dump ( heading vocabs-file messages-file -- xml )
[ eval-file ] dip over empty? [ 3drop f ] [
[ ]
[ [ [XML <li><-></li> XML] ] map [XML <ul><-></ul> XML] ]
[ utf8 file-contents ]
tri*
[XML <h1><-></h1> <-> Details: <pre><-></pre> XML]
] if ;
: benchmarks-table ( assoc -- xml )
2008-09-16 00:20:33 -04:00
[
2009-11-20 19:20:45 -05:00
1,000,000,000 /f
[XML <tr><td><-></td><td><-></td></tr> XML]
2009-11-20 19:20:45 -05:00
] { } assoc>map
[XML
<h2>Benchmarks</h2>
<table>
<tr><th>Benchmark</th><th>Time (seconds)</th></tr>
<->
</table>
XML] ;
2008-09-16 00:20:33 -04:00
: successful-report ( -- )
[
[
timings-table
2008-09-16 00:20:33 -04:00
"Load failures"
load-all-vocabs-file
load-all-errors-file
error-dump
2008-09-16 00:20:33 -04:00
2009-04-23 23:17:25 -04:00
"Compiler errors"
compiler-errors-file
compiler-error-messages-file
error-dump
2008-09-16 00:20:33 -04:00
"Unit test failures"
test-all-vocabs-file
test-all-errors-file
error-dump
"Help lint failures"
help-lint-vocabs-file
help-lint-errors-file
error-dump
2008-11-16 14:46:45 -05:00
"Benchmark errors"
benchmark-error-vocabs-file
benchmark-error-messages-file
error-dump
2009-05-08 22:33:49 -04:00
benchmarks-file eval-file benchmarks-table
] output>array
] with-report ;
: build-clean? ( -- ? )
2009-05-21 01:08:43 -04:00
${
load-all-vocabs-file
test-all-vocabs-file
help-lint-vocabs-file
compiler-errors-file
benchmark-error-vocabs-file
} [ eval-file empty? ] all? ;
: success ( -- status )
successful-report build-clean? status-clean status-dirty ? ;