OILS / test / report.R View on Github | oilshell.org

54 lines, 34 significant
1#!/usr/bin/env Rscript
2#
3# report.R
4
5library(dplyr)
6
7options(stringsAsFactors = F)
8
9source('benchmarks/common.R')
10
11UnitTestReport = function(in_dir, out_dir) {
12 tasks = readTsv(file.path(in_dir, 'tasks.tsv'))
13
14 tasks %>% filter(status != 0) -> failed
15 if (nrow(failed) != 0) {
16 print(failed)
17 stop('Some tasks failed')
18 }
19
20 tasks %>%
21 mutate(elapsed_ms = elapsed_secs * 1000) %>%
22 select(-c(status, elapsed_secs)) %>%
23 select(c(elapsed_ms, test, test_HREF)) ->
24 tasks
25
26 precision = SamePrecision(0)
27 writeTsv(tasks, file.path(out_dir, 'report'), precision)
28}
29
30main = function(argv) {
31 action = argv[[1]]
32 in_dir = argv[[2]]
33 out_dir = argv[[3]]
34
35 if (action == 'unit') {
36 UnitTestReport(in_dir, out_dir)
37
38 } else if (action == 'spec') {
39 # TODO
40
41 } else {
42 Log("Invalid action '%s'", action)
43 quit(status = 1)
44 }
45 Log('PID %d done', Sys.getpid())
46}
47
48
49if (length(sys.frames()) == 0) {
50 # increase ggplot font size globally
51 #theme_set(theme_grey(base_size = 20))
52
53 main(commandArgs(TRUE))
54}