testowl 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/lib/testowl/growl.rb CHANGED
@@ -3,7 +3,7 @@ module Testowl
3
3
 
4
4
  Growlnotify = "growlnotify"
5
5
 
6
- def self.grr(title, message, status, files, suffix)
6
+ def self.grr(title, message, seconds, status, files, suffix)
7
7
  project = File.expand_path(".").split("/").last
8
8
  growlnotify = `which #{Growlnotify}`.chomp
9
9
  if growlnotify == ''
@@ -14,9 +14,12 @@ module Testowl
14
14
  @warning_done = true
15
15
  end
16
16
  else
17
+ message_lines = [message.gsub("'", "`")]
18
+ message_lines << sprintf("(%0.1f seconds)", seconds) if seconds
19
+ message_lines << "#{files.map{|file| file.sub(/^spec\/[^\/]*\//, '').sub(/_test.rb$/, '')}.join("\n")}\n#{suffix}"
17
20
  options = []
18
21
  options << "-n Watchr"
19
- options << "--message '#{message.gsub("'", "`")}\n\n#{files.map{|file| file.sub(/^spec\/[^\/]*\//, '').sub(/_test.rb$/, '')}.join("\n")}\n#{suffix}'"
22
+ options << "--message '#{message_lines.join("\n\n")}'"
20
23
  options << "--sticky" if status == :error
21
24
  options << "--image '#{image_path(status)}'"
22
25
  options << "--identifier #{Digest::MD5.hexdigest files.join}" # (used for coalescing)
@@ -8,10 +8,12 @@ module Testowl
8
8
  @runner = RspecRunner.new
9
9
  @test_dir = "spec"
10
10
  @test_suffix = "spec"
11
+ puts "TestOwl #{VERSION} has detected RSpec"
11
12
  elsif File.exist?("test/test_helper.rb")
12
13
  @runner = TestUnitRunner.new
13
14
  @test_dir = "test"
14
15
  @test_suffix = "test"
16
+ puts "TestOwl #{VERSION} has detected Test Unit"
15
17
  else
16
18
  raise "Can't find either spec_helper.rb or test_helper.rb and this owl is confused."
17
19
  end
@@ -34,7 +36,7 @@ module Testowl
34
36
  puts "Detected change in #{match[0]}"
35
37
  run_controller(match[1], "triggered by #{match[0]}")
36
38
  end
37
- puts "Monitoring files..."
39
+ puts "Waiting for code changes..."
38
40
  Watchr::Controller.new(script, Watchr.handler.new).run
39
41
  end
40
42
 
@@ -3,20 +3,15 @@ module Testowl
3
3
 
4
4
  def run(files)
5
5
  results = runDirectly(files)
6
- lines = results.split("\n")
7
- exception_message = lines.detect{|line| line =~ /^Exception encountered/ }
8
- counts = lines.detect{|line| line =~ /(\d+)\sexamples?,\s(\d+)\sfailures?/ }
9
- if counts
10
- test_count, fail_count = counts.split(',').map(&:to_i)
11
- timing = lines.detect{|line| line =~ /Finished\sin/}
12
- timing = timing.sub(/Finished\sin/, '').strip if timing
6
+ count_match = /(\d+)\sexamples?,\s(\d+)\sfailures?/.match(results)
7
+ timing_match = /Finished\sin\s([0-9\.]*)\sseconds/.match(results)
8
+ if count_match && timing_match
9
+ test_count = count_match[1].to_i
10
+ fail_count = count_match[2].to_i
11
+ timing = timing_match[1].to_f
13
12
  return test_count, fail_count, timing
14
13
  else
15
- if exception_message
16
- raise exception_message
17
- else
18
- raise "Problem interpreting result. Please check the terminal output."
19
- end
14
+ raise "Problem interpreting result. Please check the terminal output."
20
15
  end
21
16
  end
22
17
 
@@ -18,21 +18,17 @@ module Testowl
18
18
  runDirectly(files)
19
19
  end
20
20
  puts "Done"
21
- lines = results.split("\n")
22
- exception_message = lines.detect{|line| line =~ /^Exception encountered/ }
23
- counts = lines.detect{|line| line =~ /(\d+)\sassertions?,\s(\d+)\sfailures?,\s(\d+)\serrors?/ }
24
- if counts
25
- file_count, test_count, fail_count, error_count = counts.split(',').map(&:to_i)
26
- fail_count += error_count # let's lump errors and failures together
27
- timing = lines.detect{|line| line =~ /Finished\sin/}
28
- timing = timing.sub(/Finished\sin/, '').strip if timing
21
+ count_match = /(\d+)\sassertions?,\s(\d+)\sfailures?,\s(\d+)\serrors?/.match(results)
22
+ timing_match = /Finished\sin\s([0-9\.]*)\sseconds/.match(results)
23
+ puts count_match
24
+ puts timing_match
25
+ if count_match && timing_match
26
+ test_count = count_match[1].to_i
27
+ fail_count = count_match[2].to_i + count_match[3].to_i # let's lump errors and failures together
28
+ timing = timing_match[1].to_f
29
29
  return test_count, fail_count, timing
30
30
  else
31
- if exception_message
32
- raise exception_message
33
- else
34
- raise "Problem interpreting result. Please check the terminal output."
35
- end
31
+ raise "Problem interpreting result. Please check the terminal output."
36
32
  end
37
33
  end
38
34
 
@@ -14,6 +14,7 @@ module Testowl
14
14
  def run
15
15
  test_count = 0
16
16
  fail_count = 0
17
+ seconds = 0
17
18
  files_run = []
18
19
  begin
19
20
  @files_list.each do |files|
@@ -21,20 +22,21 @@ module Testowl
21
22
  files_run += files
22
23
  test_count += result[0]
23
24
  fail_count += result[1]
25
+ seconds += result[2]
24
26
  break if fail_count > 0
25
27
  end
26
28
  if test_count == 0
27
- Growl.grr "Empty Test", "No tests run", :error, files_run, @reason
29
+ Growl.grr "Empty Test", "No tests run", seconds, :error, files_run, @reason
28
30
  return false
29
31
  elsif fail_count > 0
30
- Growl.grr "Fail", "#{fail_count} out of #{test_count} test#{'s' if test_count > 1} failed :(", :failed, files_run, @reason
32
+ Growl.grr "Fail", "#{fail_count} out of #{test_count} test#{'s' if test_count > 1} failed :(", seconds, :failed, files_run, @reason
31
33
  return false
32
34
  else
33
- Growl.grr "Pass", "All #{test_count} example#{'s' if test_count > 1} passed :)", :success, files_run, @reason
35
+ Growl.grr "Pass", "All #{test_count} example#{'s' if test_count > 1} passed :)", seconds, :success, files_run, @reason
34
36
  return true
35
37
  end
36
38
  rescue => exc
37
- Growl.grr "Exception", exc.message, :error, files_run, @reason
39
+ Growl.grr "Exception", exc.message, nil, :error, files_run, @reason
38
40
  end
39
41
  end
40
42
 
@@ -1,3 +1,3 @@
1
1
  module Testowl
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testowl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bill Horsman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-28 00:00:00 -07:00
18
+ date: 2011-06-30 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency