-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathextract-package-output
executable file
·55 lines (47 loc) · 1.2 KB
/
extract-package-output
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
#!/usr/bin/gawk -f
function usage() {
print("extract-package-output: Extract package output from a build log using colcon markers")
print("USAGE: extract-package-output OPERATION PACKAGE [BUILD_LOG_FILE]")
print("\tOPERATION: Either 'build' or 'test'")
print("\tPACKAGE: The target package name")
print("\tBUILD_LOG_FILE: Path to the target build log. Defaults to stdin")
exit(0)
}
BEGIN {
ORS="\n"
for (i = 0; i < ARGC; i++) {
if (ARGV[i] == "-h" || ARGV[i] == "--help") {
usage()
}
}
operation = ARGV[1]
if (operation != "build" && operation != "test") {
print operation " is not a valid operation." > "/dev/stderr"
print "\t One of `build` or `test`" > "/dev/stderr"
exit 1
}
package = ARGV[2]
if (package == "") {
print "No package supplied. Please provide a package name" > "/dev/stderr"
exit 1
}
delete ARGV[2]
ARGC--
delete ARGV[1]
ARGC--
section_pattern = "BEGIN SUBSECTION: " operation
start_pattern = "Starting >>> " package
finish_pattern = "(Finished|Failed) +<<< " package
}
$0 ~ section_pattern {
in_section = 1
}
in_section && $0 ~ start_pattern {
start = 1
}
start {
print $0
}
start && $0 ~ finish_pattern {
exit 0
}