ocrunner 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
data/lib/ocrunner/cli.rb CHANGED
@@ -5,7 +5,7 @@ module OCRunner
5
5
  module CLI
6
6
  def self.run
7
7
 
8
- Kernel.trap('INT') { exit }
8
+ Kernel.trap('INT') { puts; exit }
9
9
 
10
10
  opts = Trollop::options do
11
11
  version_number = File.read(File.join(File.dirname(__FILE__), '../../VERSION')).strip
@@ -1,10 +1,15 @@
1
1
  module OCRunner
2
2
  class TestCase
3
- attr :name
4
- attr_accessor :passed, :path, :line, :message
5
3
 
4
+ # Container for test case info
5
+
6
+ attr :name
7
+ attr_accessor :passed
8
+ attr_accessor :errors
9
+
6
10
  def initialize(name)
7
11
  @name = name
12
+ @errors = []
8
13
  end
9
14
  end
10
15
  end
@@ -0,0 +1,8 @@
1
+ module OCRunner
2
+
3
+ # Container for test failures info
4
+
5
+ class TestError < Struct.new(:path, :line, :message)
6
+ end
7
+
8
+ end
@@ -1,19 +1,30 @@
1
1
  module OCRunner
2
2
  class TestRunner
3
3
  include Console
4
-
5
- attr_reader :suites, :current_directory, :options, :log, :command
4
+
5
+ class BuildFailure < StandardError; end
6
+
7
+ attr_reader :compilation_error_occurred
6
8
 
7
9
  def initialize(options)
8
10
  @suites = []
9
11
  @log = ''
10
12
  @current_directory = Dir.pwd
11
13
  @options = options
14
+ @passed = true
15
+ @compilation_error_occurred = false
16
+ @output = []
12
17
 
18
+ setup
13
19
  build_command
14
20
  run_tests
15
- display_summary
16
- display_log
21
+ summarize
22
+ display_results
23
+ end
24
+
25
+ def setup
26
+ puts "="*80
27
+ puts
17
28
  end
18
29
 
19
30
  def build_command
@@ -35,44 +46,60 @@ module OCRunner
35
46
  end
36
47
  end
37
48
 
38
- def display_summary
39
- passed = true
49
+ def summarize
50
+
40
51
  @suites.each do |suite|
41
- failed = suite.cases.reject {|c| c.passed}
42
- failed.each do |c|
43
- passed = false
44
- puts
45
- puts ' ' + red("[#{suite.name} #{c.name}] FAIL") + " on line #{c.line} of #{clean_path(c.path)}"
46
- puts ' ' + c.message unless c.message.nil?
52
+ suite.cases.reject {|kase| kase.passed}.each do |kase|
53
+ out
54
+ out ' ' + red("[#{suite.name} #{kase.name}] FAIL")
55
+ kase.errors.each do |error|
56
+ out ' ' + red(error.message) + " line #{error.line} of #{clean_path(error.path)}"
57
+ end
47
58
  end
48
- puts
59
+ out
49
60
  end
50
61
 
51
62
  @suites.each do |suite|
52
63
  failed = suite.cases.reject {|c| c.passed}
53
- puts "Suite '#{suite.name}': #{suite.cases.size - failed.size} passes and #{failed.size} failures in #{suite.time} seconds."
64
+ out "Suite '#{suite.name}': #{suite.cases.size - failed.size} passes and #{failed.size} failures in #{suite.time} seconds."
54
65
  end
55
66
 
56
- puts
67
+ out
57
68
 
58
- if passed
59
- growl('Build succeeded.')
60
- puts green('*** BUILD SUCCEEDED ***')
69
+ if @passed
70
+ build_succeeded
61
71
  else
62
- growl('BUILD FAILED!')
63
- puts red('*** BUILD FAILED ***')
72
+ build_failed
64
73
  end
65
74
  end
66
-
67
- def display_log
68
- puts @log if @options[:verbose]
75
+
76
+ def display_results
77
+ puts @log if @options[:verbose] || compilation_error_occurred
78
+ puts @output.join("\n")
79
+ puts
69
80
  end
70
-
81
+
82
+ def build_error(message)
83
+ out red(message)
84
+ @passed = false
85
+ end
86
+
87
+ def build_failed
88
+ growl('BUILD FAILED!')
89
+ out red('*** BUILD FAILED ***')
90
+ end
91
+
92
+ def build_succeeded
93
+ growl('Build succeeded.')
94
+ out green('*** BUILD SUCCEEDED ***')
95
+ end
96
+
71
97
  def process_console_output(line)
72
98
 
73
99
  # test case started
74
- if line =~ /Test Case '-\[\w+ (.+)\]' started/
100
+ if line =~ /Test Case '-\[.+ (.+)\]' started/
75
101
  @current_case = TestCase.new($1)
102
+ @current_suite.cases << @current_case
76
103
  end
77
104
 
78
105
  # test case passed
@@ -84,13 +111,10 @@ module OCRunner
84
111
  end
85
112
 
86
113
  # test failure
87
- if line =~ /(.+\.m):(\d+): error: -\[(.+) (.+)\] :(?: (.+):)? /
114
+ if line =~ /(.+\.m):(\d+): error: -\[(.+) (.+)\] :(?: (.+):?)? /
88
115
  @current_case.passed = false
89
- @current_case.path = $1
90
- @current_case.line = $2
91
- @current_case.message = $5
92
- @current_suite.cases << @current_case
93
- @current_case = nil
116
+ @current_case.errors << TestError.new($1, $2, $5)
117
+ @passed = false
94
118
  print red('.')
95
119
  end
96
120
 
@@ -107,12 +131,35 @@ module OCRunner
107
131
  @current_suite = nil
108
132
  print "\n" # clear console line
109
133
  end
134
+
135
+ # test executable not found
136
+ if line =~ /The executable for the test bundle at (.+\.octest) could not be found/
137
+ build_error("Test executable #{clean_path($1)} could not be found")
138
+ end
139
+
140
+ # compilation reference error
141
+ if line =~ /"(.+)", referenced from:/
142
+ compilation_error_occurred!
143
+ build_error($&)
144
+ end
145
+ if line =~ /-\[\w+ \w+\] in .+\.o/
146
+ compilation_error_occurred!
147
+ build_error($&)
148
+ end
110
149
 
111
150
  # no Xcode project found
112
151
  if line =~ /does not contain an Xcode project/
113
- puts red('No Xcode project was found.')
114
- exit
152
+ build_error('No Xcode project was found.')
115
153
  end
154
+
155
+ end
156
+
157
+ def compilation_error_occurred!
158
+ @compilation_error_occurred = true
159
+ end
160
+
161
+ def out(line = '')
162
+ @output << line
116
163
  end
117
164
 
118
165
  def clean_path(path)
@@ -1,5 +1,8 @@
1
1
  module OCRunner
2
2
  class TestSuite
3
+
4
+ # Container for test suite info
5
+
3
6
  attr :name
4
7
  attr_accessor :cases, :time
5
8
 
data/lib/ocrunner.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/ocrunner/cli'
2
2
  require File.dirname(__FILE__) + '/ocrunner/console'
3
3
  require File.dirname(__FILE__) + '/ocrunner/test_case'
4
+ require File.dirname(__FILE__) + '/ocrunner/test_error'
4
5
  require File.dirname(__FILE__) + '/ocrunner/test_suite'
5
6
  require File.dirname(__FILE__) + '/ocrunner/test_runner'
data/ocrunner.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ocrunner}
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jim Benton"]
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  "lib/ocrunner/cli.rb",
31
31
  "lib/ocrunner/console.rb",
32
32
  "lib/ocrunner/test_case.rb",
33
+ "lib/ocrunner/test_error.rb",
33
34
  "lib/ocrunner/test_runner.rb",
34
35
  "lib/ocrunner/test_suite.rb",
35
36
  "ocrunner.gemspec",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 3
9
- version: 0.2.3
8
+ - 4
9
+ version: 0.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jim Benton
@@ -62,6 +62,7 @@ files:
62
62
  - lib/ocrunner/cli.rb
63
63
  - lib/ocrunner/console.rb
64
64
  - lib/ocrunner/test_case.rb
65
+ - lib/ocrunner/test_error.rb
65
66
  - lib/ocrunner/test_runner.rb
66
67
  - lib/ocrunner/test_suite.rb
67
68
  - ocrunner.gemspec