author | wenzelm |
Fri, 07 Oct 2016 17:41:19 +0200 | |
changeset 64086 | ac7ae5067783 |
parent 64085 | 1c451e5c145f |
child 64087 | a77c57235bae |
permissions | -rw-r--r-- |
64045 | 1 |
/* Title: Pure/Tools/build_log.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Build log parsing for historic versions, back to "build_history_base". |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
10 |
import java.time.ZonedDateTime |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
11 |
import java.time.format.{DateTimeFormatter, DateTimeParseException} |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
12 |
|
64054 | 13 |
import scala.collection.mutable |
14 |
import scala.util.matching.Regex |
|
15 |
||
16 |
||
64045 | 17 |
object Build_Log |
18 |
{ |
|
64081 | 19 |
/** settings **/ |
64080 | 20 |
|
64081 | 21 |
object Settings |
22 |
{ |
|
23 |
val build_settings = List("ISABELLE_BUILD_OPTIONS") |
|
24 |
val ml_settings = List("ML_PLATFORM", "ML_HOME", "ML_SYSTEM", "ML_OPTIONS") |
|
25 |
val all_settings = build_settings ::: ml_settings |
|
26 |
||
27 |
type Entry = (String, String) |
|
28 |
type T = List[Entry] |
|
64080 | 29 |
|
64081 | 30 |
object Entry |
31 |
{ |
|
32 |
def unapply(s: String): Option[Entry] = |
|
33 |
s.indexOf('=') match { |
|
34 |
case -1 => None |
|
35 |
case i => |
|
36 |
val a = s.substring(0, i) |
|
37 |
val b = Library.perhaps_unquote(s.substring(i + 1)) |
|
38 |
Some((a, b)) |
|
39 |
} |
|
40 |
def apply(a: String, b: String): String = a + "=" + quote(b) |
|
41 |
def getenv(a: String): String = apply(a, Isabelle_System.getenv(a)) |
|
42 |
} |
|
64080 | 43 |
|
64081 | 44 |
def show(): String = |
45 |
cat_lines( |
|
46 |
build_settings.map(Entry.getenv(_)) ::: List("") ::: ml_settings.map(Entry.getenv(_))) |
|
64080 | 47 |
} |
48 |
||
49 |
||
64062 | 50 |
/** log file **/ |
64045 | 51 |
|
64062 | 52 |
object Log_File |
53 |
{ |
|
64083 | 54 |
def apply(path: Path): Log_File = |
55 |
{ |
|
56 |
val (path_name, ext) = path.expand.split_ext |
|
57 |
val text = |
|
58 |
if (ext == "gz") File.read_gzip(path) |
|
59 |
else if (ext == "xz") File.read_xz(path) |
|
60 |
else File.read(path) |
|
61 |
apply(path_name.base.implode, text) |
|
62 |
} |
|
63 |
||
64062 | 64 |
def apply(name: String, lines: List[String]): Log_File = |
65 |
new Log_File(name, lines) |
|
66 |
||
67 |
def apply(name: String, text: String): Log_File = |
|
64063 | 68 |
Log_File(name, Library.trim_split_lines(text)) |
64062 | 69 |
} |
70 |
||
71 |
class Log_File private(val name: String, val lines: List[String]) |
|
64045 | 72 |
{ |
64062 | 73 |
log_file => |
74 |
||
75 |
override def toString: String = name |
|
76 |
||
77 |
def text: String = cat_lines(lines) |
|
78 |
||
79 |
def err(msg: String): Nothing = |
|
80 |
error("Error in log file " + quote(name) + ": " + msg) |
|
81 |
||
82 |
||
83 |
/* inlined content */ |
|
84 |
||
85 |
def find[A](f: String => Option[A]): Option[A] = |
|
86 |
lines.iterator.map(f).find(_.isDefined).map(_.get) |
|
87 |
||
88 |
def find_match(regex: Regex): Option[String] = |
|
89 |
lines.iterator.map(regex.unapplySeq(_)).find(res => res.isDefined && res.get.length == 1). |
|
90 |
map(res => res.get.head) |
|
91 |
||
92 |
||
93 |
/* settings */ |
|
94 |
||
64081 | 95 |
def get_setting(a: String): Settings.Entry = |
96 |
Settings.Entry.unapply( |
|
97 |
lines.find(_.startsWith(a + "=")) getOrElse err("missing " + a)).get |
|
64045 | 98 |
|
64081 | 99 |
def get_settings(as: List[String]): Settings.T = as.map(get_setting(_)) |
64062 | 100 |
|
101 |
||
102 |
/* properties (YXML) */ |
|
103 |
||
104 |
val xml_cache = new XML.Cache() |
|
105 |
||
106 |
def parse_props(text: String): Properties.T = |
|
107 |
xml_cache.props(XML.Decode.properties(YXML.parse_body(text))) |
|
108 |
||
109 |
def filter_props(prefix: String): List[Properties.T] = |
|
110 |
for (line <- lines; s <- Library.try_unprefix(prefix, line)) yield parse_props(s) |
|
64045 | 111 |
|
64062 | 112 |
def find_line(prefix: String): Option[String] = |
113 |
find(Library.try_unprefix(prefix, _)) |
|
114 |
||
115 |
def find_props(prefix: String): Option[Properties.T] = |
|
116 |
find_line(prefix).map(parse_props(_)) |
|
117 |
||
118 |
||
119 |
/* parse various formats */ |
|
120 |
||
64082 | 121 |
def parse_session_info( |
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
122 |
default_name: String = "", |
64082 | 123 |
command_timings: Boolean = false, |
124 |
ml_statistics: Boolean = false, |
|
125 |
task_statistics: Boolean = false): Session_Info = |
|
126 |
Build_Log.parse_session_info( |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
127 |
log_file, default_name, command_timings, ml_statistics, task_statistics) |
64062 | 128 |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
129 |
def parse_header(): Header = Build_Log.parse_header(log_file) |
64062 | 130 |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
131 |
def parse_build_info(): Build_Info = Build_Log.parse_build_info(log_file) |
64045 | 132 |
} |
133 |
||
134 |
||
135 |
/* session log: produced by "isabelle build" */ |
|
136 |
||
137 |
sealed case class Session_Info( |
|
138 |
session_name: String, |
|
139 |
session_timing: Properties.T, |
|
140 |
command_timings: List[Properties.T], |
|
141 |
ml_statistics: List[Properties.T], |
|
142 |
task_statistics: List[Properties.T]) |
|
143 |
||
64082 | 144 |
private def parse_session_info( |
145 |
log_file: Log_File, |
|
146 |
default_name: String, |
|
147 |
command_timings: Boolean, |
|
148 |
ml_statistics: Boolean, |
|
149 |
task_statistics: Boolean): Session_Info = |
|
64045 | 150 |
{ |
151 |
val xml_cache = new XML.Cache() |
|
152 |
||
153 |
val session_name = |
|
64062 | 154 |
log_file.find_line("\fSession.name = ") match { |
64082 | 155 |
case None => default_name |
156 |
case Some(name) if default_name == "" || default_name == name => name |
|
64062 | 157 |
case Some(name) => log_file.err("log from different session " + quote(name)) |
64045 | 158 |
} |
64062 | 159 |
val session_timing = log_file.find_props("\fTiming = ") getOrElse Nil |
64082 | 160 |
val command_timings_ = |
161 |
if (command_timings) log_file.filter_props("\fcommand_timing = ") else Nil |
|
162 |
val ml_statistics_ = |
|
163 |
if (ml_statistics) log_file.filter_props("\fML_statistics = ") else Nil |
|
164 |
val task_statistics_ = |
|
165 |
if (task_statistics) log_file.filter_props("\ftask_statistics = ") else Nil |
|
64045 | 166 |
|
64082 | 167 |
Session_Info(session_name, session_timing, command_timings_, ml_statistics_, task_statistics_) |
64045 | 168 |
} |
64054 | 169 |
|
170 |
||
64062 | 171 |
/* header and meta data */ |
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
172 |
|
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
173 |
object Header_Kind extends Enumeration |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
174 |
{ |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
175 |
val ISATEST = Value("isatest") |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
176 |
val AFP_TEST = Value("afp-test") |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
177 |
val JENKINS = Value("jenkins") |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
178 |
} |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
179 |
|
64081 | 180 |
sealed case class Header( |
181 |
kind: Header_Kind.Value, props: Properties.T, settings: List[(String, String)]) |
|
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
182 |
|
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
183 |
object Field |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
184 |
{ |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
185 |
val build_host = "build_host" |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
186 |
val build_start = "build_start" |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
187 |
val build_end = "build_end" |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
188 |
val isabelle_version = "isabelle_version" |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
189 |
val afp_version = "afp_version" |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
190 |
} |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
191 |
|
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
192 |
object AFP |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
193 |
{ |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
194 |
val Date_Format = |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
195 |
Date.Format.make_patterns(List("EEE MMM d HH:mm:ss VV yyyy", "EEE MMM d HH:mm:ss O yyyy"), |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
196 |
// workaround for jdk-8u102 |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
197 |
s => Word.implode(Word.explode(s).map({ case "CEST" => "GMT+2" case a => a }))) |
64062 | 198 |
|
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
199 |
val Test_Start = new Regex("""^Start test for .+ at (.+), (\w+)$""") |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
200 |
val Test_End = new Regex("""^End test on (.+), \w+, elapsed time:.*$""") |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
201 |
val Isabelle_Version = new Regex("""^Isabelle version: .* -- hg id (\w+)$""") |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
202 |
val AFP_Version = new Regex("""^AFP version: .* -- hg id (\w+)$""") |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
203 |
} |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
204 |
|
64062 | 205 |
private def parse_header(log_file: Log_File): Header = |
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
206 |
{ |
64062 | 207 |
log_file.lines match { |
208 |
case AFP.Test_Start(start, hostname) :: _ => |
|
209 |
(start, log_file.lines.last) match { |
|
210 |
case (AFP.Date_Format(start_date), AFP.Test_End(AFP.Date_Format(end_date))) => |
|
211 |
val isabelle_version = |
|
212 |
log_file.find_match(AFP.Isabelle_Version) getOrElse |
|
213 |
log_file.err("missing Isabelle version") |
|
214 |
val afp_version = |
|
215 |
log_file.find_match(AFP.AFP_Version) getOrElse |
|
216 |
log_file.err("missing AFP version") |
|
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
217 |
|
64062 | 218 |
Header(Header_Kind.AFP_TEST, |
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
219 |
List( |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
220 |
Field.build_host -> hostname, |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
221 |
Field.build_start -> start_date.toString, |
64062 | 222 |
Field.build_end -> end_date.toString, |
223 |
Field.isabelle_version -> isabelle_version, |
|
224 |
Field.afp_version -> afp_version), |
|
64081 | 225 |
log_file.get_settings(Settings.all_settings)) |
64062 | 226 |
|
227 |
case _ => log_file.err("cannot detect start/end date in afp-test log") |
|
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
228 |
} |
64062 | 229 |
case _ => log_file.err("cannot detect log header format") |
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
230 |
} |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
231 |
} |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
232 |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
233 |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
234 |
/* build info: produced by isabelle build */ |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
235 |
|
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
236 |
object Session_Status extends Enumeration |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
237 |
{ |
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
238 |
val EXISTING = Value("existing") |
64061
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
239 |
val FINISHED = Value("finished") |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
240 |
val FAILED = Value("failed") |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
241 |
val CANCELLED = Value("cancelled") |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
242 |
} |
1bbea2b55d22
some support for header and data fields, notably from afp-test;
wenzelm
parents:
64054
diff
changeset
|
243 |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
244 |
sealed case class Session_Entry( |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
245 |
chapter: String, |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
246 |
groups: List[String], |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
247 |
threads: Option[Int], |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
248 |
timing: Option[Timing], |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
249 |
ml_timing: Option[Timing], |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
250 |
status: Session_Status.Value) |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
251 |
{ |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
252 |
def finished: Boolean = status == Session_Status.FINISHED |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
253 |
} |
64054 | 254 |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
255 |
sealed case class Build_Info(sessions: Map[String, Session_Entry]) |
64054 | 256 |
{ |
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
257 |
def session(name: String): Session_Entry = sessions(name) |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
258 |
def get_session(name: String): Option[Session_Entry] = sessions.get(name) |
64054 | 259 |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
260 |
def finished(name: String): Boolean = |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
261 |
get_session(name) match { |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
262 |
case Some(entry) => entry.finished |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
263 |
case None => false |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
264 |
} |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
265 |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
266 |
def timing(name: String): Timing = |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
267 |
(for (entry <- get_session(name); t <- entry.timing) yield t) getOrElse Timing.zero |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
268 |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
269 |
def ml_timing(name: String): Timing = |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
270 |
(for (entry <- get_session(name); t <- entry.ml_timing) yield t) getOrElse Timing.zero |
64054 | 271 |
} |
272 |
||
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
273 |
private def parse_build_info(log_file: Log_File): Build_Info = |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
274 |
{ |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
275 |
object Chapter_Name |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
276 |
{ |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
277 |
def unapply(s: String): Some[(String, String)] = |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
278 |
space_explode('/', s) match { |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
279 |
case List(chapter, name) => Some((chapter, name)) |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
280 |
case _ => Some(("", s)) |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
281 |
} |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
282 |
} |
64054 | 283 |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
284 |
val Session_No_Groups = new Regex("""^Session (\S+)$""") |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
285 |
val Session_Groups = new Regex("""^Session (\S+) \((.*)\)$""") |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
286 |
val Session_Finished1 = |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
287 |
new Regex("""^Finished (\S+) \((\d+):(\d+):(\d+) elapsed time, (\d+):(\d+):(\d+) cpu time.*$""") |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
288 |
val Session_Finished2 = |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
289 |
new Regex("""^Finished (\S+) \((\d+):(\d+):(\d+) elapsed time.*$""") |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
290 |
val Session_Timing = |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
291 |
new Regex("""^Timing (\S+) \((\d) threads, (\d+\.\d+)s elapsed time, (\d+\.\d+)s cpu time, (\d+\.\d+)s GC time.*$""") |
64086
ac7ae5067783
clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents:
64085
diff
changeset
|
292 |
val Session_Started = new Regex("""^(?:Running|Building) (\S+) \.\.\.$""") |
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
293 |
val Session_Failed = new Regex("""^(\S+) FAILED""") |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
294 |
val Session_Cancelled = new Regex("""^(\S+) CANCELLED""") |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
295 |
|
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
296 |
var chapter = Map.empty[String, String] |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
297 |
var groups = Map.empty[String, List[String]] |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
298 |
var threads = Map.empty[String, Int] |
64054 | 299 |
var timing = Map.empty[String, Timing] |
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
300 |
var ml_timing = Map.empty[String, Timing] |
64086
ac7ae5067783
clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents:
64085
diff
changeset
|
301 |
var started = Set.empty[String] |
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
302 |
var failed = Set.empty[String] |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
303 |
var cancelled = Set.empty[String] |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
304 |
def all_sessions: Set[String] = |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
305 |
chapter.keySet ++ groups.keySet ++ threads.keySet ++ |
64086
ac7ae5067783
clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents:
64085
diff
changeset
|
306 |
timing.keySet ++ ml_timing.keySet ++ failed ++ cancelled ++ started |
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
307 |
|
64054 | 308 |
|
64062 | 309 |
for (line <- log_file.lines) { |
64054 | 310 |
line match { |
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
311 |
case Session_No_Groups(Chapter_Name(chapt, name)) => |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
312 |
chapter += (name -> chapt) |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
313 |
groups += (name -> Nil) |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
314 |
case Session_Groups(Chapter_Name(chapt, name), grps) => |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
315 |
chapter += (name -> chapt) |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
316 |
groups += (name -> Word.explode(grps)) |
64086
ac7ae5067783
clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents:
64085
diff
changeset
|
317 |
case Session_Started(name) => |
ac7ae5067783
clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents:
64085
diff
changeset
|
318 |
started += name |
64054 | 319 |
case Session_Finished1(name, |
320 |
Value.Int(e1), Value.Int(e2), Value.Int(e3), |
|
321 |
Value.Int(c1), Value.Int(c2), Value.Int(c3)) => |
|
322 |
val elapsed = Time.hms(e1, e2, e3) |
|
323 |
val cpu = Time.hms(c1, c2, c3) |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
324 |
timing += (name -> Timing(elapsed, cpu, Time.zero)) |
64054 | 325 |
case Session_Finished2(name, |
326 |
Value.Int(e1), Value.Int(e2), Value.Int(e3)) => |
|
327 |
val elapsed = Time.hms(e1, e2, e3) |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
328 |
timing += (name -> Timing(elapsed, Time.zero, Time.zero)) |
64054 | 329 |
case Session_Timing(name, |
330 |
Value.Int(t), Value.Double(e), Value.Double(c), Value.Double(g)) => |
|
331 |
val elapsed = Time.seconds(e) |
|
332 |
val cpu = Time.seconds(c) |
|
333 |
val gc = Time.seconds(g) |
|
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
334 |
ml_timing += (name -> Timing(elapsed, cpu, gc)) |
64054 | 335 |
threads += (name -> t) |
336 |
case _ => |
|
337 |
} |
|
338 |
} |
|
339 |
||
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
340 |
val sessions = |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
341 |
Map( |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
342 |
(for (name <- all_sessions.toList) yield { |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
343 |
val status = |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
344 |
if (failed(name)) Session_Status.FAILED |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
345 |
else if (cancelled(name)) Session_Status.CANCELLED |
64086
ac7ae5067783
clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents:
64085
diff
changeset
|
346 |
else if (timing.isDefinedAt(name) || ml_timing.isDefinedAt(name)) |
ac7ae5067783
clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents:
64085
diff
changeset
|
347 |
Session_Status.FINISHED |
ac7ae5067783
clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents:
64085
diff
changeset
|
348 |
else if (started(name)) Session_Status.FAILED |
64085
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
349 |
else Session_Status.EXISTING |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
350 |
val entry = |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
351 |
Session_Entry( |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
352 |
chapter.getOrElse(name, ""), |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
353 |
groups.getOrElse(name, Nil), |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
354 |
threads.get(name), |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
355 |
timing.get(name), |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
356 |
ml_timing.get(name), |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
357 |
status) |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
358 |
(name -> entry) |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
359 |
}):_*) |
1c451e5c145f
clarified parse_build_info: isabelle build output;
wenzelm
parents:
64083
diff
changeset
|
360 |
Build_Info(sessions) |
64054 | 361 |
} |
64045 | 362 |
} |