-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathirtt_report.go
More file actions
39 lines (36 loc) · 805 Bytes
/
Copy pathirtt_report.go
File metadata and controls
39 lines (36 loc) · 805 Bytes
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
package irtt
import (
"encoding/json"
"io"
"os"
)
// runReport emits a report from a JSON file.
func runReport(args []string) {
var r io.Reader
if len(args) == 0 || args[0] == "-" {
r = os.Stdin
} else {
f, err := os.Open(args[0])
if err != nil {
exitOnError(err, exitCodeRuntimeError)
}
defer f.Close()
r = f
}
var p PrintableResult
d := json.NewDecoder(r)
if err := d.Decode(&p); err != nil {
exitOnError(err, exitCodeRuntimeError)
}
printResult(&p)
}
func reportUsage() {
setBufio()
printf("Usage: report [file|-]")
printf("")
printf("Emits the standard end of test report from JSON output.")
printf("")
printf("If a filename is given, JSON is read from the given file.")
printf("")
printf("If no argument or a - character is given, JSON is read from stdin.")
}