guard-maven 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/guard/maven/version.rb +1 -1
- data/lib/guard/maven.rb +28 -6
- metadata +1 -1
data/lib/guard/maven/version.rb
CHANGED
data/lib/guard/maven.rb
CHANGED
@@ -54,8 +54,12 @@ module Guard
|
|
54
54
|
|
55
55
|
def notify(success, name, data={})
|
56
56
|
title = 'Maven Tests'
|
57
|
-
message = "Maven Test Results
|
58
|
-
|
57
|
+
message = "Maven Test Results:"
|
58
|
+
if data[:test_counts].empty?
|
59
|
+
message += "No Tests Run"
|
60
|
+
else
|
61
|
+
message = guard_message(data[:test_counts][:total], data[:test_counts][:fail],data[:test_counts][:error],data[:test_counts][:skip],data[:total_time])
|
62
|
+
end
|
59
63
|
image = success ? :success : :failed
|
60
64
|
Notifier.notify(message, title: title, image: image)
|
61
65
|
end
|
@@ -72,7 +76,7 @@ module Guard
|
|
72
76
|
#
|
73
77
|
# @return [Hash] the relevant information
|
74
78
|
def parse_test_results(results)
|
75
|
-
data = { :success => true }
|
79
|
+
data = { :success => true, :test_counts => [], :failures => [] }
|
76
80
|
|
77
81
|
time = results.match(/\[INFO\] Total time: ([sm\d\.]+)/i)
|
78
82
|
data[:total_time] = time[1] if time
|
@@ -94,6 +98,11 @@ module Guard
|
|
94
98
|
failures = results.match /Failed tests:(.*)\n\nTests run/im
|
95
99
|
data[:failures] = failures ? failures[1].split("\n").compact : []
|
96
100
|
|
101
|
+
if results =~ /COMPILATION ERROR/
|
102
|
+
data[:success] = false
|
103
|
+
data[:dump] = true
|
104
|
+
end
|
105
|
+
|
97
106
|
data
|
98
107
|
end
|
99
108
|
|
@@ -112,7 +121,7 @@ module Guard
|
|
112
121
|
# output as well as diplay it in terminal
|
113
122
|
output = []
|
114
123
|
IO.popen(cmds.join(' ')).each do |line|
|
115
|
-
if options[:verbose]
|
124
|
+
if @options[:verbose]
|
116
125
|
puts line.chomp
|
117
126
|
else
|
118
127
|
clean_output(line.chomp)
|
@@ -127,8 +136,9 @@ module Guard
|
|
127
136
|
data = parse_test_results(results)
|
128
137
|
success = false unless data[:success]
|
129
138
|
|
130
|
-
unless options[:verbose]
|
131
|
-
puts "Failed Tests:\n#{data[:failures].join("\n")}"
|
139
|
+
unless @options[:verbose]
|
140
|
+
puts "Failed Tests:\n#{data[:failures].join("\n")}" unless data[:failures].empty?
|
141
|
+
puts results if data[:dump]
|
132
142
|
end
|
133
143
|
|
134
144
|
notify(success, options[:name] || '', data)
|
@@ -149,5 +159,17 @@ module Guard
|
|
149
159
|
# do nothing
|
150
160
|
end
|
151
161
|
end
|
162
|
+
|
163
|
+
def guard_message(test_count, failure_count, error_count, skip_count, duration)
|
164
|
+
message = "#{test_count} tests"
|
165
|
+
if skip_count > 0
|
166
|
+
message << " (#{skip_count} skipped)"
|
167
|
+
end
|
168
|
+
message << "\n#{failure_count} failures, #{error_count} errors"
|
169
|
+
if test_count
|
170
|
+
message << "\n\nFinished in #{duration}"
|
171
|
+
end
|
172
|
+
message
|
173
|
+
end
|
152
174
|
end
|
153
175
|
end
|