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