File: lsw-summary-table.js

package info (click to toggle)
libreswan 5.2-2.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 81,632 kB
  • sloc: ansic: 129,988; sh: 32,018; xml: 20,646; python: 10,303; makefile: 3,022; javascript: 1,506; sed: 574; yacc: 511; perl: 264; awk: 52
file content (145 lines) | stat: -rw-r--r-- 3,074 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// lsw-summary-table.js

function lsw_summary_table(table_id, summary) {

    let now = new Date()

    let columns = []

    columns.push({
	title: "Commits",
	html: function(row) {
	    // If there are no commits, this (correctly) returns a
	    // blank column.
	    return row.html_commits()
	},
	sort: function(l, r) {
	    // sort descending!
	    return r.commit.rank - l.commit.rank
	}
    })

    //
    // Add columns showing the broken down totals.
    //
    // The table "totals" is structured:
    //
    //    <kind> . <status> . <result|issues> . <count>
    //
    // and the table reflects this (with some filtering).

    STATUSES = ["good", "wip"]
    RESULTS = ["passed", "failed", "unresolved", "untested"]
    KINDS = ["kvmplutotest"]
    for (const kind of KINDS) {

	let statuses_columns = []
	statuses_columns.title = kind
	columns.push(statuses_columns);

	for (const status of STATUSES) {

	    let results_columns = []
	    results_columns.title = status
	    statuses_columns.push(results_columns)

	    for (const result of RESULTS) {
		result_column = {
		    title: result,
		    kind: kind,
		    status: status,
		    value: function(summary) {
			// field may be missing
			return (summary.totals &&
				summary.totals[this.kind] &&
				summary.totals[this.kind][this.status] &&
				summary.totals[this.kind][this.status][this.title] ||
				"")
		    },
		}
		results_columns.push(result_column)
	    }

	    results_columns.push({
		title: "issues",
		kind: kind,
		status: status,
		value: function(summary) {
		    let issues = (summary.totals &&
				  summary.totals[this.kind] &&
				  summary.totals[this.kind][this.status] &&
				  summary.totals[this.kind][this.status][this.title] ||
				  null)
		    html = ""
		    if (issues) {
			html += "<div class=\"issues\">"
			for (const issue of Object.keys(issues).sort()) {
			    // only real issues are UPPER CASE?
			    if (issue == issue.toUpperCase()) {
				html += issue + ": " + issues[issue] + "<br>"
			    }
			}
			html += "</div>"
		    }
		    return html;
		},
	    })
	}
    }

    //
    // Add the totals column
    //

    columns.push({
	title: "Total",
    })

    // Add Extra info columns

    columns.push({
	title: "Start Time",
	html: function(row) {
	    if (row.start_time)
		return row.start_time.toLocaleString()
	    return ""
	},
    })
    columns.push({
	title: "Run Time",
	value: function(row) {
	    if (row.start_time) {
		return subtime(row.current_time, row.start_time)
	    }
	    return ""
	}
    })
    columns.push({
	title: "Directory",
	html: function(row) {
	    let a = ("<a href=\"" + row.directory + "\">"
		     + row.directory
		     + "</a>")
	    if (row == summary.current) {
		a += "<br/>" + summary.status.details
	    }
	    return a
	},
	value: function(row) {
	    return row.directory
	},
    })

    // Compute the body's rows

    lsw_table({
	id: table_id,
	data: summary.test_runs,
	columns: columns,
	select: {
	    row: function(selected_test_runs) {
		lsw_compare_test_runs(selected_test_runs)
	    }
	},
    })
}