Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 63 lines (54 sloc) 2.028 kb
3d58051 Mario Domenech Goulart Added salmonella-log-merger
authored
1 (use salmonella salmonella-log-parser)
2 (include "salmonella-common.scm")
3
4 (define (merge-logs log-files)
5 (let* ((logs (map read-log-file log-files))
6 (first-started
7 (let loop ((logs logs)
8 (first-started (caar logs)))
9 (if (null? logs)
10 first-started
11 (let* ((log (car logs))
12 (log-start (start-time log)))
13 (loop (cdr logs)
14 (if (< log-start (report-duration first-started))
15 (car log)
16 first-started))))))
17 (last-finished
18 (let loop ((logs logs)
19 (last-finished (last (car logs))))
20 (if (null? logs)
21 last-finished
22 (let* ((log (car logs))
23 (log-end (end-time log)))
24 (loop (cdr logs)
25 (if (> log-end (report-duration last-finished))
26 (last log)
27 last-finished)))))))
28
29 (append
30 (list (report->list first-started))
31 (let loop ((logs logs))
32 (if (null? logs)
33 '()
34 (append (map report->list
35 (butlast (cdr (car logs))))
36 (loop (cdr logs)))))
37 (list (report->list last-finished)))))
38
39
40 (define (usage #!optional exit-code)
41 (let ((this (pathname-strip-directory (program-name))))
e9c702e Mario Domenech Goulart salmonella-log-merger's --out-file renamed to --log-file
authored
42 (print this " --log-file=<log file> log1 log2 ... logn")
3d58051 Mario Domenech Goulart Added salmonella-log-merger
authored
43 (when exit-code (exit exit-code))))
44
45
46
47 (let ((args (command-line-arguments)))
48 (when (null? args)
49 (usage 1))
50 (let ((log-files
51 (remove (lambda (arg)
52 (string-prefix? "--" arg))
53 args))
e9c702e Mario Domenech Goulart salmonella-log-merger's --out-file renamed to --log-file
authored
54 (out-file (cmd-line-arg '--log-file args)))
3d58051 Mario Domenech Goulart Added salmonella-log-merger
authored
55 (when (file-exists? out-file)
56 (die out-file " already exists. Aborting."))
57 (unless out-file
58 (usage 1))
59
60 (with-output-to-file out-file
61 (lambda ()
62 (for-each pp (merge-logs log-files))))))
Something went wrong with that request. Please try again.