1 ! Copyright (C) 2008, 2009 Eduardo Cavazos, Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: benchmark combinators.smart debugger fry io assocs
4 io.encodings.utf8 io.files io.sockets io.streams.string kernel
5 locals mason.common mason.config mason.platform math namespaces
6 prettyprint sequences xml.syntax xml.writer combinators.short-circuit
10 : common-report ( -- xml )
17 <h1>Build report for <->/<-></h1>
19 <tr><td>Build machine:</td><td><-></td></tr>
20 <tr><td>Build directory:</td><td><-></td></tr>
21 <tr><td>GIT ID:</td><td><-></td></tr>
25 : with-report ( quot -- )
30 [XML <html><body><-><-></body></html> XML]
32 ] with-file-writer ; inline
34 : file-tail ( file encoding lines -- seq )
35 [ file-lines ] dip short tail* "\n" join ;
37 :: failed-report ( error file what -- status )
39 error [ error. ] with-string-writer :> error
40 file utf8 400 file-tail :> output
52 : compile-failed ( error -- status )
53 "compile-log" "VM compilation failed" failed-report ;
55 : boot-failed ( error -- status )
56 "boot-log" "Bootstrap failed" failed-report ;
58 : test-failed ( error -- status )
59 "test-log" "Tests failed" failed-report ;
61 : timings-table ( -- xml )
70 dup eval-file milli-seconds>time
71 [XML <tr><td><-></td><td><-></td></tr> XML]
72 ] map [XML <h2>Timings</h2> <table><-></table> XML] ;
74 : error-dump ( heading vocabs-file messages-file -- xml )
75 [ eval-file ] dip over empty? [ 3drop f ] [
77 [ [ [XML <li><-></li> XML] ] map [XML <ul><-></ul> XML] ]
78 [ utf8 file-contents ]
80 [XML <h1><-></h1> <-> Details: <pre><-></pre> XML]
83 : benchmarks-table ( assoc -- xml )
86 [XML <tr><td><-></td><td><-></td></tr> XML]
87 ] { } assoc>map [XML <h2>Benchmarks</h2> <table><-></table> XML] ;
89 : successful-report ( -- )
101 compiler-error-messages-file
110 help-lint-vocabs-file
111 help-lint-errors-file
115 benchmark-error-vocabs-file
116 benchmark-error-messages-file
119 benchmarks-file eval-file benchmarks-table
123 : build-clean? ( -- ? )
127 help-lint-vocabs-file
129 benchmark-error-vocabs-file
130 } [ eval-file empty? ] all? ;
132 : success ( -- status )
133 successful-report build-clean? status-clean status-dirty ? ;