File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+
1
3
# Adds tags based on error and failures output (e.g., from a CI log),
2
4
# without running any spec code.
3
5
8
10
abort 'Could not find tags directory' unless tags_dir
9
11
10
12
output = ARGF . readlines
11
- # Remove leading "[exec] " from JRuby logs
12
- output = output . map { |line | line . sub ( /^\[ exec\] / , '' ) }
13
13
14
14
NUMBER = /^\d +\) $/
15
15
ERROR_OR_FAILED = / (ERROR|FAILED)$/
16
16
SPEC_FILE = /^(\/ .+_spec\. rb)\: \d +/
17
17
18
- failures = output . slice_before ( NUMBER ) . select { |number , error_line , *rest |
18
+ output . slice_before ( NUMBER ) . select { |number , error_line , *rest |
19
19
number =~ NUMBER and error_line =~ ERROR_OR_FAILED
20
20
} . each { |number , error_line , *rest |
21
21
description = error_line . match ( ERROR_OR_FAILED ) . pre_match
31
31
Dir . mkdir ( dir ) unless Dir . exist? ( dir )
32
32
33
33
tag_line = "fails:#{ description } "
34
- unless File . exist? ( tags_file ) and File . readlines ( tags_file , chomp : true ) . include? ( tag_line )
35
- File . open ( tags_file , 'a' ) do |f |
36
- f . puts tag_line
37
- end
34
+ lines = File . exist? ( tags_file ) ? File . readlines ( tags_file , chomp : true ) : [ ]
35
+ unless lines . include? ( tag_line )
36
+ File . write ( tags_file , ( lines + [ tag_line ] ) . join ( "\n " ) + "\n " )
38
37
end
39
38
}
You can’t perform that action at this time.
0 commit comments