diff -urN cruisecontrol-1.4.0/app/controllers/builds_controller.rb cruisecontrol-1.4.0-opera-patched/app/controllers/builds_controller.rb --- cruisecontrol-1.4.0/app/controllers/builds_controller.rb 2009-06-30 17:46:13.000000000 +0200 +++ cruisecontrol-1.4.0-opera-patched/app/controllers/builds_controller.rb 2009-12-17 15:01:21.000000000 +0100 @@ -8,9 +8,11 @@ if params[:build] @build = @project.find_build(params[:build]) + @test_collector = @project.test_result_collector.new(@build) if @build render :text => "Build #{params[:build].inspect} not found", :status => 404 and return if @build.nil? else @build = @project.last_build + @test_collector = @project.test_result_collector.new(@build) if @build render :action => 'no_builds_yet' and return if @build.nil? end @@ -74,4 +76,4 @@ end end -end \ No newline at end of file +end diff -urN cruisecontrol-1.4.0/app/helpers/application_helper.rb cruisecontrol-1.4.0-opera-patched/app/helpers/application_helper.rb --- cruisecontrol-1.4.0/app/helpers/application_helper.rb 2009-06-30 17:46:13.000000000 +0200 +++ cruisecontrol-1.4.0-opera-patched/app/helpers/application_helper.rb 2009-12-17 14:47:39.000000000 +0100 @@ -81,7 +81,30 @@ url.match(/\/\/.+?(\/.+)/)[1] end end - + + def testrun_summary_long(build, project) + if build.incomplete? + "Build incomplete" + else + build_collector = project.test_result_collector.new(build) + prev_build = project.previous_build(build) + prev_build_collector = project.test_result_collector.new(prev_build) + + current_fail_list = build_collector.test_nonpass_names + prev_fail_list = prev_build_collector.test_nonpass_names + fixes = prev_fail_list - current_fail_list + regressions = current_fail_list - prev_fail_list + + "
\ +#{ build_collector.total_number_tests.to_s } total tests, \ +#{ build_collector.number_passed_tests.to_s } passed. +Failed test list: #{ current_fail_list.size > 0 ? current_fail_list.join(", ") : "none" }. +Fixes: #{fixes.size > 0 ? fixes.join(", ") : "none"}. +Regressions: #{regressions.size > 0 ? regressions.join(", ") : "none"}. +
" + end + end + private def build_label(build) diff -urN cruisecontrol-1.4.0/app/helpers/builds_helper.rb cruisecontrol-1.4.0-opera-patched/app/helpers/builds_helper.rb --- cruisecontrol-1.4.0/app/helpers/builds_helper.rb 2009-06-30 17:46:13.000000000 +0200 +++ cruisecontrol-1.4.0-opera-patched/app/helpers/builds_helper.rb 2009-12-17 14:49:31.000000000 +0100 @@ -39,21 +39,23 @@ h(settings) end end - - def failures_and_errors_if_any(log) - errors = BuildLogParser.new(log).failures_and_errors - return nil if errors.empty? - - link_to_code(errors.collect{|error| format_test_error_output(error)}.join) + + def format_nonpasses(collector) + if collector.build.incomplete? + "Build incomplete" + else + link_to_code(collector.test_nonpasses.collect{|error| format_test_error_output(error)}.join) + end end - + def format_test_error_output(test_error) - message = test_error.message + message = test_error.message.strip.gsub(/\\n/, "\n"); + stacktrace = test_error.stacktrace || "" "Name: #{test_error.test_name}\n" + "Type: #{test_error.type}\n" + - "Message: #{h message}\n\n" + - "#{h test_error.stacktrace}\n\n\n" + (message != "" ? "Message: #{h message}\n\n" : "") + + (stacktrace != "" ? "#{h stacktrace}\n\n\n" : "") end def display_build_time @@ -80,4 +82,4 @@ def strip_ansi_colors(log) log.gsub(/\e\[\d+m/, '') end -end \ No newline at end of file +end diff -urN cruisecontrol-1.4.0/app/models/project.rb cruisecontrol-1.4.0-opera-patched/app/models/project.rb --- cruisecontrol-1.4.0/app/models/project.rb 2009-06-30 17:46:13.000000000 +0200 +++ cruisecontrol-1.4.0-opera-patched/app/models/project.rb 2009-12-17 14:38:37.000000000 +0100 @@ -23,7 +23,7 @@ end attr_reader :name, :plugins, :build_command, :rake_task, :config_tracker, :path, :settings, :config_file_content, :error_message - attr_accessor :source_control, :scheduler + attr_accessor :source_control, :scheduler, :test_result_collector def initialize(name, scm = nil) @name = name @@ -35,6 +35,7 @@ @settings = '' @config_file_content = '' @error_message = '' + @test_result_collector = TestCollectors::RubyTestUnit # default @triggers = [ChangeInSourceControlTrigger.new(self)] self.source_control = scm if scm instantiate_plugins @@ -523,4 +524,4 @@ end -plugin_loader.load_all \ No newline at end of file +plugin_loader.load_all diff -urN cruisecontrol-1.4.0/app/models/projects.rb cruisecontrol-1.4.0-opera-patched/app/models/projects.rb --- cruisecontrol-1.4.0/app/models/projects.rb 2009-06-30 17:46:13.000000000 +0200 +++ cruisecontrol-1.4.0-opera-patched/app/models/projects.rb 2009-12-17 14:36:37.000000000 +0100 @@ -15,7 +15,8 @@ end def load_project(dir) - project = Project.read(dir, load_config = false) + # project = Project.read(dir, load_config = false) + project = Project.read(dir, load_config = true) project.path = dir project end diff -urN cruisecontrol-1.4.0/app/models/test_collectors/base.rb cruisecontrol-1.4.0-opera-patched/app/models/test_collectors/base.rb --- cruisecontrol-1.4.0/app/models/test_collectors/base.rb 1970-01-01 01:00:00.000000000 +0100 +++ cruisecontrol-1.4.0-opera-patched/app/models/test_collectors/base.rb 2009-12-17 14:37:09.000000000 +0100 @@ -0,0 +1,66 @@ +module TestCollectors + class FakeBuild + def initialize(log) + @log = log + end + def output + @log + end + end + + class Base + attr_reader :build + + def initialize(build) + @build = build + end + + # Returns if the build output is understood by the test collector + def valid_build? + raise NotImplementedError + end + + def total_number_tests + raise NotImplementedError + end + + def number_passed_tests + total_number_tests - number_nonpassed_tests + end + + def number_nonpassed_tests + test_failures.size + test_errors.size + end + + # Should be implemented in every subclass, and return an array of + # TestErrorEntry objects + def test_failures + raise NotImplementedError + end + + # Should be implemented in every subclass, and return an array of + # TestErrorEntry objects + def test_errors + raise NotImplementedError + end + + def test_nonpasses + test_failures + test_errors + end + + # Convenience method to get the names of the test nonpasses + def test_nonpass_names + test_nonpasses.map {|f| f.test_name} + end + + # Convenience method to get the names of the test failures + def test_failure_names + test_failures.map {|f| f.test_name} + end + + # Convenience method to get the names of the test errors + def test_error_names + test_errors.map {|f| f.test_name} + end + end +end diff -urN cruisecontrol-1.4.0/app/models/test_collectors/dummy.rb cruisecontrol-1.4.0-opera-patched/app/models/test_collectors/dummy.rb --- cruisecontrol-1.4.0/app/models/test_collectors/dummy.rb 1970-01-01 01:00:00.000000000 +0100 +++ cruisecontrol-1.4.0-opera-patched/app/models/test_collectors/dummy.rb 2009-12-17 14:37:09.000000000 +0100 @@ -0,0 +1,19 @@ +module TestCollectors + class Dummy < Base + def valid_build? + true + end + + def total_number_tests + 0 + end + + def test_failures + [] + end + + def test_errors + [] + end + end +end diff -urN cruisecontrol-1.4.0/app/models/test_collectors/nosetests.rb cruisecontrol-1.4.0-opera-patched/app/models/test_collectors/nosetests.rb --- cruisecontrol-1.4.0/app/models/test_collectors/nosetests.rb 1970-01-01 01:00:00.000000000 +0100 +++ cruisecontrol-1.4.0-opera-patched/app/models/test_collectors/nosetests.rb 2009-12-17 14:37:09.000000000 +0100 @@ -0,0 +1,80 @@ +module TestCollectors + class Nosetests < Base + VALID_BUILD_REGEX = /Ran (\d+) tests in ((\d|\.)+)s/ + + TEST_LINE = /^(.+)\s+\.\.\.\s+(ok|FAIL|ERROR)\s*$/ + ERROR_DETAIL_HEADER = /^(FAIL|ERROR): (.+)/ + + def valid_build? + @build.output =~ VALID_BUILD_REGEX + end + + def total_number_tests + @build.output =~ VALID_BUILD_REGEX + n = $1 + n ? n.to_i : 0 + end + + def get_nonpasses(type) + raise "Type has to be :failures or :errors!" unless + [:failures, :errors].include? type + + test_nonpasses = [] + test_nonpass_details = {} + maybe_end_of_detail = false + + current_failure_detail = nil + @build.output.each_line do |line| + case line + when TEST_LINE + test_name, result = $1, $2 + if %w(FAIL ERROR).include? result + if (result == 'FAIL' and type == :failures) or + (result == 'ERROR' and type == :errors) + test_nonpasses << test_name + test_nonpass_details[test_name] = "" + end + end + when ERROR_DETAIL_HEADER + current_failure_detail = $2.sub(/^FAIL: /, '') + maybe_end_of_detail = false + if test_nonpass_details.has_key? current_failure_detail + test_nonpass_details[current_failure_detail] += line + end + when /^\s*================+\s*$/ + current_failure_detail = nil + else + if current_failure_detail and + test_nonpass_details.has_key? current_failure_detail + test_nonpass_details[current_failure_detail] += line + end + + if maybe_end_of_detail and line =~ /^\s*----------------+\s*$/ + current_failure_detail = nil + end + + if line =~ /^\s*$/ + maybe_end_of_detail = true + end + end + end + + method = type == :failures ? :create_failure : :create_error + test_nonpasses.map do |np| + details = test_nonpass_details[np].chomp.sub(/-+\z/, '').strip + TestErrorEntry.send(method, + np, + details, + "") + end + end + + def test_failures + get_nonpasses(:failures) + end + + def test_errors + get_nonpasses(:errors) + end + end +end diff -urN cruisecontrol-1.4.0/app/models/test_collectors/perl_test.rb cruisecontrol-1.4.0-opera-patched/app/models/test_collectors/perl_test.rb --- cruisecontrol-1.4.0/app/models/test_collectors/perl_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ cruisecontrol-1.4.0-opera-patched/app/models/test_collectors/perl_test.rb 2009-12-17 14:37:09.000000000 +0100 @@ -0,0 +1,69 @@ +module TestCollectors + class PerlTest < Base + def total_number_tests + @build.output =~ /Files=(\d+),/ + n = $1 + if n.nil? + @build.output =~ /Failed \d+\/(\d+) test scripts/ + $1.to_i || 0 + else + n.to_i + end + end + + def valid_build? + (@build.output =~ /Tests=(\d+),/ or + @build.output =~ /\d+\/(\d+) subtests failed/) + end + + def test_failures + error_details = {} + current_test = nil + @build.output.each_line do |line| + if line =~ /^(t\/[^\.]*)\.+/ # t/something......* + current_test = $1 + next + elsif line =~ /^Failed Test/ # "Heading" for the final summary + break + end + + if current_test + # Only consider error output messages starting with '#' and blank + # lines... + if line =~ /^# / or line =~ /^\s*$/ + # ...but don't "create" errors only with blank + error_details[current_test] ||= "" + error_details[current_test] += line + end + end + end + + list = [] + error_details.keys.sort.each do |error| + # Ignore errors not containing "Failed test" or "Looks like" + next if error_details[error] !~ /Failed (\(TODO\) )?test/ and + error_details[error] !~ /Looks like/ + list << TestErrorEntry.create_failure(error, format_error(error_details[error]), "") + end + list + end + + def test_errors + [] + end + + + private + + def format_error(error) + error.gsub(/\n\n+/, "\n\n").strip+"\n" + end + + def unpack_failure_assertions(test_name, list) + list.split(" ").map {|i| bot,top=i.split("-") + top ||= bot + (bot.to_i .. top.to_i).to_a }.flatten. + map {|i| test_name + " (#{i})"} + end + end +end diff -urN cruisecontrol-1.4.0/app/models/test_collectors/perl_test_unit.rb cruisecontrol-1.4.0-opera-patched/app/models/test_collectors/perl_test_unit.rb --- cruisecontrol-1.4.0/app/models/test_collectors/perl_test_unit.rb 1970-01-01 01:00:00.000000000 +0100 +++ cruisecontrol-1.4.0-opera-patched/app/models/test_collectors/perl_test_unit.rb 2009-12-17 14:37:09.000000000 +0100 @@ -0,0 +1,90 @@ +module TestCollectors + class PerlTestUnit < Base + TEST_FAILURE_BLOCK_REGEX = /There (was|were) \d+ failures?:\s*\n([\S\s]+\n(There w|Test was not successful))\D/ + TEST_ERROR_BLOCK_REGEX = /There (was|were) \d+ errors?:\s*\n([\S\s]+\n(There w|Test was not successful))\D/ + + def valid_build? + (@build.output =~ /OK \((\d+) tests\)/ or @build.output =~ /^Run: (\d+),/) + end + + def total_number_tests + @build.output =~ /OK \((\d+) tests\)/ + n = $1 + if n.nil? + @build.output =~ /^Run: (\d+),/ + $1.to_i || 0 + else + n.to_i + end + end + + def get_nonpasses_from_log(log, type) + create_method = "create_#{type}" + list = [] + + message_mode = false + error_name, error_message = nil, nil + log.split(/\n/).each do |line| + case line + when /^\d+\) \S+:\d+ - (.+)/ + if message_mode + list << TestErrorEntry.send(create_method, error_name, error_message.strip, "") + end + error_name, error_message = $1, "" + message_mode = true + when /^There (was|were) \d+ /, /^Test was not successful/ + if message_mode + list << TestErrorEntry.send(create_method, error_name, error_message.strip, "") + end + message_mode = false + error_name, error_message = nil, nil + else + if message_mode + error_message += line + "\n" + end + end + end + + # Dangling error + if message_mode + list << TestErrorEntry.send(create_method, error_name, error_message.strip, "") + end + + list + end + + def test_failures + log = "" + get_output = false + @build.output.each_line do |line| + log += line if get_output + + if line =~ /There (was|were) \d+ failures?:/ + get_output = true + end + + if line =~ /There (was|were) \d+ errors?:/ or line =~ /Test was not successful/ + get_output = false + end + end + get_nonpasses_from_log(log, :failure) + end + + def test_errors + log = "" + get_output = false + @build.output.each_line do |line| + log += line if get_output + + if line =~ /There (was|were) \d+ errors?:/ + get_output = true + end + + if line =~ /There (was|were) \d+ failures?:/ or line =~ /Test was not successful/ + get_output = false + end + end + get_nonpasses_from_log(log, :error) + end + end +end diff -urN cruisecontrol-1.4.0/app/models/test_collectors/ruby_test_unit.rb cruisecontrol-1.4.0-opera-patched/app/models/test_collectors/ruby_test_unit.rb --- cruisecontrol-1.4.0/app/models/test_collectors/ruby_test_unit.rb 1970-01-01 01:00:00.000000000 +0100 +++ cruisecontrol-1.4.0-opera-patched/app/models/test_collectors/ruby_test_unit.rb 2009-12-17 14:37:09.000000000 +0100 @@ -0,0 +1,52 @@ +module TestCollectors + class RubyTestUnit < Base + VALID_BUILD_REGEX = /(\d+) tests, \d+ assertions, \d+ failures, \d+ errors/ + + TEST_NAME_REGEX = /\S+/ + MESSAGE_REGEX = /\]\:\n([\s\S]+)/ + STACK_TRACE_REGEX = /\[([\s\S]*?)\]\:/ + TEST_FAILURE_BLOCK_REGEX = /^\s+\d+\) Failure:\n([\S\s]*?)\n\n/ + + FIND_TEST_ERROR_REGEX = /^\s+\d+\) Error:\n(.*):\n(.*)\n([\s\S]*?)\n\n/ + + def valid_build? + @build.output =~ VALID_BUILD_REGEX + end + + def total_number_tests + @build.output =~ VALID_BUILD_REGEX + n = $1 + n ? n.to_i : 0 + end + + def test_failures + testFailures = [] + + @build.output.gsub(TEST_FAILURE_BLOCK_REGEX) do |text| + content = $1 + + begin + test_name = content.match(TEST_NAME_REGEX).to_s + message = content.match(MESSAGE_REGEX)[1] + stack_trace = content.match(STACK_TRACE_REGEX)[1] + + testFailures << TestErrorEntry.create_failure(test_name, message, stack_trace) + rescue + # Do Nothing, Pattern does not match + end + end + + testFailures + end + + def test_errors + test_errors = Array.new + + @build.output.gsub(FIND_TEST_ERROR_REGEX) do |match| + test_errors << TestErrorEntry.create_error($1, $2, $3) + end + + return test_errors + end + end +end diff -urN cruisecontrol-1.4.0/app/views/builds/show.rhtml cruisecontrol-1.4.0-opera-patched/app/views/builds/show.rhtml --- cruisecontrol-1.4.0/app/views/builds/show.rhtml 2009-06-30 17:46:13.000000000 +0200 +++ cruisecontrol-1.4.0-opera-patched/app/views/builds/show.rhtml 2009-12-17 15:00:37.000000000 +0100 @@ -58,17 +58,27 @@
+ <% if @test_collector %> + <% if @test_collector.valid_build? %> +
+
Testrun summary
+
<%= testrun_summary_long(@build, @project) %>
+
+ <% end %> + <% end %> +
Build Changeset
<%= format_changeset_log(@build.changeset) %>
- <% test_failures = failures_and_errors_if_any(@build.output) %> - <% if test_failures %> -
-
Test Failures and Errors
-
<%= test_failures %>
-
+ <% if @test_collector %> + <% if @test_collector.number_nonpassed_tests > 0 %> +
+
Test Failures and Errors
+
<%= format_nonpasses(@test_collector) %>
+
+ <% end %> <% end %> <% plugin_errors = @build.plugin_errors %> diff -urN cruisecontrol-1.4.0/public/stylesheets/site.css cruisecontrol-1.4.0-opera-patched/public/stylesheets/site.css --- cruisecontrol-1.4.0/public/stylesheets/site.css 1970-01-01 01:00:00.000000000 +0100 +++ cruisecontrol-1.4.0-opera-patched/public/stylesheets/site.css 2009-12-17 15:01:23.000000000 +0100 @@ -0,0 +1,11 @@ +/* this is a copy of /root/.cruise/site.css, please make any changes to it there */ + +/* if you'd like to add custom styles to cruise, add them here */ +/* the following will make successful builds green */ +a.success, a.success:visited { + color: #0A0; +} + +.build_success { + background-image: url(/images/green_gradient.png); +} diff -urN cruisecontrol-1.4.0/test/unit/builds_helper_test.rb cruisecontrol-1.4.0-opera-patched/test/unit/builds_helper_test.rb --- cruisecontrol-1.4.0/test/unit/builds_helper_test.rb 2009-06-30 17:46:13.000000000 +0200 +++ cruisecontrol-1.4.0-opera-patched/test/unit/builds_helper_test.rb 2009-12-17 14:37:09.000000000 +0100 @@ -72,43 +72,6 @@ assert_equal expected, format_build_log(log) end - # this is tested elsewhere in depth, this is a functional test - def test_parse_test_results - log = <<-EOL - 1) Error: -test_build_loop_failed_creates_file__build_loop_failed__(BuilderStatusTest): -NameError: uninitialized constant BuilderStatusTest::BuilderStatus - ./test/unit/builder_status_test.rb:8:in `setup' - - 2) Error: -test_build_started_creates_file__building__(BuilderStatusTest): -NameError: uninitialized constant BuilderStatusTest::BuilderStatus - /active_support/dependencies.rb:477:in `const_missing' - ./test/unit/builder_status_test.rb:8:in `setup' - - EOL - - expected = <<-EOL -Name: test_build_loop_failed_creates_file__build_loop_failed__(BuilderStatusTest) -Type: Error -Message: NameError: uninitialized constant BuilderStatusTest::BuilderStatus - - ./test/unit/builder_status_test.rb:8:in `setup' - - -Name: test_build_started_creates_file__building__(BuilderStatusTest) -Type: Error -Message: NameError: uninitialized constant BuilderStatusTest::BuilderStatus - - /active_support/dependencies.rb:477:in `const_missing' - ./test/unit/builder_status_test.rb:8:in `setup' - - - EOL - - assert_equal expected, failures_and_errors_if_any(log) - end - BuildStub = Struct.new :label, :time, :state # failed, incomplete class BuildStub def failed?() @state == 'failed' end diff -urN cruisecontrol-1.4.0/test/unit/test_collector_nosetests_test.rb cruisecontrol-1.4.0-opera-patched/test/unit/test_collector_nosetests_test.rb --- cruisecontrol-1.4.0/test/unit/test_collector_nosetests_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ cruisecontrol-1.4.0-opera-patched/test/unit/test_collector_nosetests_test.rb 2009-12-17 14:37:09.000000000 +0100 @@ -0,0 +1,214 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'test_collectors/nosetests' + +class TestCollectorNosetestsTest < Test::Unit::TestCase + +LOG_OUTPUT_WITHOUT_FAILURES = < + import opera.auth.api as auth_api + File "/root/.cruise/projects/widgets-unit/work/opera_auth/opera/auth/api.py", line 7, in + from opera.util import decorators + File "/root/.cruise/projects/widgets/work/opera_util/opera/util/decorators.py", line 1, in + from decorator import decorator +ImportError: No module named decorator + +====================================================================== +ERROR: Tests storing and loading of data +---------------------------------------------------------------------- +Traceback (most recent call last): + File "/root/.cruise/projects/widgets-unit/work/opera_files/opera/files/test/test_files.py", line 42, in test_FileSystemDOA_storage + user = self._get_random_user() + File "/root/.cruise/projects/widgets-unit/work/opera_files/opera/files/test/test_files.py", line 86, in _get_random_user + return opera.auth.model.User(666, "randomuser") +AttributeError: 'module' object has no attribute 'auth' + +---------------------------------------------------------------------- +Ran 9 tests in 0.053s + +FAILED (errors=3) +EOF + +LOG_OUTPUT_WITH_FAILURES = <<'EOF' +/root/.cruise/projects/widgets-unit/work root$ for i in opera_* widgetsoperacom; do PYTHONPATH=:; done; export PYTHONPATH; nosetests -c nose.cfg +No handlers could be found for logger "opera.util.bbcode" +Test banning users ... ok +Test creating Auth User ... ok +Test find_all_users ... ok +Test find by id ... ok +Test find by username ... ok +Tests find real username ... FAIL +Test Author count ... ok +Test find_users_by_first_letter ... ok +Test find_all_users ... ok +Test find by id ... ok +Test find by username ... ok +Tests find real username ... FAIL +Test Author count ... ok +Test find_users_by_first_letter ... ok +Test AuthService.is_valid ... ok +Test the penging ban feature ... ok +Test register user ... ok +Test creating a user row ... ok +Test find_comments_by_user ... ok +Test that the decorator doesn't cache the wrong exceptions. ... ok +testCreateZip (test_ziputil.TestZipUtil) ... ok + +====================================================================== +FAIL: Tests find real username +---------------------------------------------------------------------- +Traceback (most recent call last): + File "/root/.cruise/projects/widgets/work/opera_auth/opera/auth/test/test_auth.py", line 108, in test_find_real_username + "Tests find real username") +AssertionError: Tests find real username + +====================================================================== +FAIL: Tests find real username +---------------------------------------------------------------------- +Traceback (most recent call last): + File "/root/.cruise/projects/widgets/work/opera_auth/opera/auth/test/test_auth.py", line 108, in test_find_real_username + "Tests find real username") +AssertionError: Tests find real username + +---------------------------------------------------------------------- +Ran 21 tests in 119.360s + +FAILED (failures=2) +EOF + + + def test_should_find_no_test_errors_with_successful_build + collector = TestCollectors::Nosetests.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITHOUT_FAILURES)) + assert_equal 0, collector.test_errors.length + assert_equal 0, collector.test_failures.length + assert_equal 43, collector.total_number_tests + end + + def test_should_get_errors + collector = TestCollectors::Nosetests.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_ERRORS)) + failures = collector.test_failures + errors = collector.test_errors + assert_equal 0, failures.length, "Should not find failures in the errors log" + assert_equal 3, errors.length, "Should find three errors in the errors log" + assert_equal 9, collector.total_number_tests + # Both are actually the same, because the "test name" (the error printed by + # nosetests) is the same + assert_equal expected_first_error, errors[0] + assert_equal expected_second_error, errors[1] + assert_equal expected_third_error, errors[2] + end + + def test_should_get_failures + collector = TestCollectors::Nosetests.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_FAILURES)) + failures = collector.test_failures + errors = collector.test_errors + assert_equal 0, errors.length, "Should not find errors in the failures log" + assert_equal 2, failures.length, "Should find three failures in the failures log" + assert_equal 21, collector.total_number_tests + # Both are actually the same, because the "test name" (the error printed by + # nosetests) is the same + assert_equal expected_first_failure, failures[0] + assert_equal expected_second_failure, failures[1] + end + + def expected_first_error + TestErrorEntry.create_error("Failure: ImportError (No module named decorator)", + "ERROR: Failure: ImportError (No module named decorator)\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"/usr/lib/python2.5/site-packages/nose-0.10.3-py2.5.egg/nose/loader.py\", line 364, in loadTestsFromName\n addr.filename, addr.module)\n File \"/usr/lib/python2.5/site-packages/nose-0.10.3-py2.5.egg/nose/importer.py\", line 39, in importFromPath\n return self.importFromDir(dir_path, fqname)\n File \"/usr/lib/python2.5/site-packages/nose-0.10.3-py2.5.egg/nose/importer.py\", line 84, in importFromDir\n mod = load_module(part_fqname, fh, filename, desc)\n File \"/root/.cruise/projects/widgets-unit/work/opera_auth/opera/auth/test/test_auth.py\", line 9, in \n import opera.auth.api as auth_api\n File \"/root/.cruise/projects/widgets-unit/work/opera_auth/opera/auth/api.py\", line 7, in \n from opera.util import decorators\n File \"/root/.cruise/projects/widgets/work/opera_util/opera/util/decorators.py\", line 1, in \n from decorator import decorator\nImportError: No module named decorator", + "") + end + + def expected_second_error + TestErrorEntry.create_error("Tests storing and loading of data", + "ERROR: Tests storing and loading of data\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"/root/.cruise/projects/widgets-unit/work/opera_files/opera/files/test/test_files.py\", line 42, in test_FileSystemDOA_storage\n user = self._get_random_user()\n File \"/root/.cruise/projects/widgets-unit/work/opera_files/opera/files/test/test_files.py\", line 86, in _get_random_user\n return opera.auth.model.User(666, \"randomuser\")\nAttributeError: 'module' object has no attribute 'auth'", + "") + end + + def expected_third_error + TestErrorEntry.create_error("Failure: ImportError (No module named decorator)", + "ERROR: Failure: ImportError (No module named decorator)\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"/usr/lib/python2.5/site-packages/nose-0.10.3-py2.5.egg/nose/loader.py\", line 364, in loadTestsFromName\n addr.filename, addr.module)\n File \"/usr/lib/python2.5/site-packages/nose-0.10.3-py2.5.egg/nose/importer.py\", line 39, in importFromPath\n return self.importFromDir(dir_path, fqname)\n File \"/usr/lib/python2.5/site-packages/nose-0.10.3-py2.5.egg/nose/importer.py\", line 84, in importFromDir\n mod = load_module(part_fqname, fh, filename, desc)\n File \"/root/.cruise/projects/widgets-unit/work/opera_auth/opera/auth/test/test_auth.py\", line 9, in \n import opera.auth.api as auth_api\n File \"/root/.cruise/projects/widgets-unit/work/opera_auth/opera/auth/api.py\", line 7, in \n from opera.util import decorators\n File \"/root/.cruise/projects/widgets/work/opera_util/opera/util/decorators.py\", line 1, in \n from decorator import decorator\nImportError: No module named decorator", + "") + end + + def expected_first_failure + TestErrorEntry.create_failure("Tests find real username", + "FAIL: Tests find real username\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"/root/.cruise/projects/widgets/work/opera_auth/opera/auth/test/test_auth.py\", line 108, in test_find_real_username\n \"Tests find real username\")\nAssertionError: Tests find real username\n\nFAIL: Tests find real username\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"/root/.cruise/projects/widgets/work/opera_auth/opera/auth/test/test_auth.py\", line 108, in test_find_real_username\n \"Tests find real username\")\nAssertionError: Tests find real username", + "") + end + + def expected_second_failure + TestErrorEntry.create_failure("Tests find real username", + "FAIL: Tests find real username\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"/root/.cruise/projects/widgets/work/opera_auth/opera/auth/test/test_auth.py\", line 108, in test_find_real_username\n \"Tests find real username\")\nAssertionError: Tests find real username\n\nFAIL: Tests find real username\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"/root/.cruise/projects/widgets/work/opera_auth/opera/auth/test/test_auth.py\", line 108, in test_find_real_username\n \"Tests find real username\")\nAssertionError: Tests find real username", + "") + end + +end diff -urN cruisecontrol-1.4.0/test/unit/test_collector_perl_test_test.rb cruisecontrol-1.4.0-opera-patched/test/unit/test_collector_perl_test_test.rb --- cruisecontrol-1.4.0/test/unit/test_collector_perl_test_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ cruisecontrol-1.4.0-opera-patched/test/unit/test_collector_perl_test_test.rb 2009-12-17 14:37:09.000000000 +0100 @@ -0,0 +1,1163 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'test_collectors/perl_test' + +class TestCollectorPerlTestTest < Test::Unit::TestCase + +LOG_OUTPUT_WITH_FAILURES = <<'EOF' +/usr/src/cruisecontrolrb-1.1.0/projects/myopera/work root$ ssh -p 10022 myoperatester@myoperatestserver sudo /usr/src/MyOperaFunctionalTests/setup_test_env.sh +Updated to revision 4076. +Updated to revision 4076. +Updated to revision 5242. +Current DB version: 7 | Latest: 7 +Already at latest version +Forcing reload of web server (apache2)... waiting . +Found directory /var/www/my.opera.com/www/community/users/homes/ +Cleaning directory /var/www/my.opera.com/www/community/users/homes/... +/usr/src/cruisecontrolrb-1.1.0/projects/myopera/work root$ cd MyOperaFunctionalTests +/usr/src/cruisecontrolrb-1.1.0/projects/myopera/work root$ perl Makefile.PL +Writing Makefile for Opera::MyOperaMechanizeTester +/usr/src/cruisecontrolrb-1.1.0/projects/myopera/work root$ make test +PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*/*.t +t/auth/000-setup..................ok +t/auth/001-login.................. +# Failed test at t/auth/001-login.t line 28. +# ' +# +# 500 Internal Server Error +# +#

Internal Server Error

+#

The server encountered an internal error or +# misconfiguration and was unable to complete +# your request.

+#

Please contact the server administrator, +# my@opera.com and inform them of the time the error occurred, +# and anything you might have done that may have +# caused the error.

+#

More information about this error may be available +# in the server error log.

+#
+#
Apache/2.2.3 (Debian) mod-xslt/1.3.9 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 Server at auth.test.is.oslo.opera.com Port 10080
+# +# ' +# doesn't match '(?-xism:404)' +# Looks like you failed 1 test of 2. +dubious + Test returned status 1 (wstat 256, 0x100) +DIED. FAILED test 2 + Failed 1/2 tests, 50.00% okay +t/auth/002-registration........... +# Failed test at t/auth/002-registration.t line 67. +# ' +# +# 500 Internal Server Error +# +#

Internal Server Error

+#

The server encountered an internal error or +# misconfiguration and was unable to complete +# your request.

+#

Please contact the server administrator, +# my@opera.com and inform them of the time the error occurred, +# and anything you might have done that may have +# caused the error.

+#

More information about this error may be available +# in the server error log.

+#
+#
Apache/2.2.3 (Debian) mod-xslt/1.3.9 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 Server at auth.test.is.oslo.opera.com Port 10080
+# +# ' +# doesn't match '(?-xism:401)' + +# Failed test at t/auth/002-registration.t line 77. +# ' +# +# 500 Internal Server Error +# +#

Internal Server Error

+#

The server encountered an internal error or +# misconfiguration and was unable to complete +# your request.

+#

Please contact the server administrator, +# my@opera.com and inform them of the time the error occurred, +# and anything you might have done that may have +# caused the error.

+#

More information about this error may be available +# in the server error log.

+#
+#
Apache/2.2.3 (Debian) mod-xslt/1.3.9 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 Server at auth.test.is.oslo.opera.com Port 10080
+# +# ' +# doesn't match '(?-xism:401)' + +# Failed test at t/auth/002-registration.t line 87. +# ' +# +# 500 Internal Server Error +# +#

Internal Server Error

+#

The server encountered an internal error or +# misconfiguration and was unable to complete +# your request.

+#

Please contact the server administrator, +# my@opera.com and inform them of the time the error occurred, +# and anything you might have done that may have +# caused the error.

+#

More information about this error may be available +# in the server error log.

+#
+#
Apache/2.2.3 (Debian) mod-xslt/1.3.9 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 Server at auth.test.is.oslo.opera.com Port 10080
+# +# ' +# doesn't match '(?-xism:406)' + +# Failed test at t/auth/002-registration.t line 154. +# ' +# +# 500 Internal Server Error +# +#

Internal Server Error

+#

The server encountered an internal error or +# misconfiguration and was unable to complete +# your request.

+#

Please contact the server administrator, +# my@opera.com and inform them of the time the error occurred, +# and anything you might have done that may have +# caused the error.

+#

More information about this error may be available +# in the server error log.

+#
+#
Apache/2.2.3 (Debian) mod-xslt/1.3.9 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 Server at auth.test.is.oslo.opera.com Port 10080
+# +# ' +# doesn't match '(?-xism:403)' +# Looks like you failed 4 tests of 7. +dubious + Test returned status 4 (wstat 1024, 0x400) +DIED. FAILED tests 2-4, 7 + Failed 4/7 tests, 42.86% okay +t/blogs/000-setup.................ok +t/blogs/001-create_blog...........ok +t/blogs/002-comments..............ok +t/blogs/003-pagination............ok +t/blogs/004-languages............. +# Failed test 'Serbian blog post in 'Local blogs'' +# at t/blogs/004-languages.t line 59. +# searched: "\x{0a}\x{0a}\x{0a}\x{0a}\x{0a}\x{0a}> /usr/src/cruisecontrolrb-1.1.0/projects/myopera/build-4097/build.log && ssh -p 10022 myoperatester@myoperatestserver sudo /usr/src/MyOperaFunctionalTests/setup_test_env.sh >> /usr/src/cruisecontrolrb-1.1.0/projects/myopera/build-4097/build.log 2>&1 && echo /usr/src/cruisecontrolrb-1.1.0/projects/myopera/work root$ cd MyOperaFunctionalTests >> /usr/src/cruisecontrolrb-1.1.0/projects/myopera/build-4097/build.log && cd MyOperaFunctionalTests >> /usr/src/cruisecontrolrb-1.1.0/projects/myopera/build-4097/build.log 2>&1 && echo /usr/src/cruisecontrolrb-1.1.0/projects/myopera/work root$ perl Makefile.PL >> /usr/src/cruisecontrolrb-1.1.0/projects/myopera/build-4097/build.log && perl Makefile.PL >> /usr/src/cruisecontrolrb-1.1.0/projects/myopera/build-4097/build.log 2>&1 && echo /usr/src/cruisecontrolrb-1.1.0/projects/myopera/work root$ make test >> /usr/src/cruisecontrolrb-1.1.0/projects/myopera/build-4097/build.log && make test >> /usr/src/cruisecontrolrb-1.1.0/projects/myopera/build-4097/build.log 2>&1 +exitstatus: 2 +STDERR TAIL START + +STDERR TAIL END +EOF + +LOG_OUTPUT_WITH_MANY_FAILURES_AND_GARBAGE = <<'EOF' +/usr/src/cruisecontrolrb-1.1.0/projects/myopera/work root$ ssh -p 10022 myoperatester@myoperatestserver sudo /usr/src/MyOperaFunctionalTests/setup_test_env.sh +Updated to revision 4094. +Updated to revision 4094. +Updated to revision 5260. +Current DB version: 7 | Latest: 7 +Already at latest version +Found directory /var/www/my.opera.com/www/community/users/homes/ +Cleaning directory /var/www/my.opera.com/www/community/users/homes/... +/usr/src/cruisecontrolrb-1.1.0/projects/myopera/work root$ cd MyOperaFunctionalTests +/usr/src/cruisecontrolrb-1.1.0/projects/myopera/work root$ perl Makefile.PL +Writing Makefile for Opera::MyOperaMechanizeTester +/usr/src/cruisecontrolrb-1.1.0/projects/myopera/work root$ make test +PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*/*.t +t/auth/000-setup..................ok +t/auth/001-login..................ok +t/auth/002-registration...........ok +t/blogs/000-setup.................ok +t/blogs/001-create_blog...........ok +t/blogs/002-comments..............ok +t/blogs/003-pagination............ok +t/blogs/004-languages............. +# Failed test 't/blogs/004-languages.t:32 - Posting 'Serbian title'' +# at Opera/MyOperaMechanizeTester.pm line 765. + +# Failed test at t/blogs/004-languages.t line 39. +# 500 +# Internal Server Error +There is no form numbered 2 at t/blogs/004-languages.t line 40 +Died at /usr/share/perl5/WWW/Mechanize.pm line 1493. +# Looks like you planned 20 tests but only ran 6. +# Looks like you failed 2 tests of 6 run. +# Looks like your test died just after 6. +dubious + Test returned status 255 (wstat 65280, 0xff00) +DIED. FAILED tests 5-20 + Failed 16/20 tests, 20.00% okay +t/blogs/005-preview............... +# Failed test 'No forms when trying to login???' +# at Opera/MyOperaMechanizeTester.pm line 435. +# got: '1' +# expected: '0' + + + +Crash Debugger + + + + +
+ +

Crash Debugger

+


+SERVER_NAME = my.test.is.oslo.opera.com
+GATEWAY_INTERFACE = CGI/1.1
+SCRIPT_FILENAME = /var/www/my.opera.com/www/community/index.dml
+

+ + + +# Failed test at Opera/MyOperaMechanizeTester.pm line 445. +# got: " + + +Crash Debugger + + + + +
+ +

Crash Debugger

+


+GATEWAY_INTERFACE = CGI/1.1
+SCRIPT_FILENAME = /var/www/my.opera.com/www/community/index.dml
+

+ + + +# Failed test at Opera/MyOperaMechanizeTester.pm line 445. +# got: " + + +Crash Debugger + + + + +
+ +

Crash Debugger

+


+GATEWAY_INTERFACE = CGI/1.1
+SCRIPT_FILENAME = /var/www/my.opera.com/www/community/index.dml
+

+ + + +# Failed test at Opera/MyOperaMechanizeTester.pm line 445. +# got: " + + +Crash Debugger + + + + +
+ +

Crash Debugger

+


+GATEWAY_INTERFACE = CGI/1.1
+SCRIPT_FILENAME = /var/www/my.opera.com/www/community/index.dml
+

+ + + +# Failed test at Opera/MyOperaMechanizeTester.pm line 445. +# got: " + + +Crash Debugger + + + + +
+ +

Crash Debugger

+


+GATEWAY_INTERFACE = CGI/1.1
+SCRIPT_FILENAME = /var/www/my.opera.com/www/community/index.dml
+

+ + + +# Failed test at Opera/MyOperaMechanizeTester.pm line 445. +# got: "last_build_restart.log && MYOPERA_TEST_CONFIG=suite-test.ini PERL5LIB=../lib make -C MyOperaFunctionalTests test +make: Entering directory `/root/.cruise/projects/myopera/work/MyOperaFunctionalTests' +PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*/*.t +t/auth/000-setup.......................ok +t/auth/001-login.......................ok +t/auth/002-registration................ok +t/auth/003-unite_devices...............ok +t/auth/004-api1_1......................ok +t/auth/005-basic_auth..................ok +t/auth/006-api2_0......................ok +t/blogs/000-setup......................ok +t/blogs/001-create_blog................ok +t/blogs/002-comments...................ok +t/blogs/003-pagination.................ok +t/blogs/004-languages..................ok +t/blogs/005-preview.................... +# Failed (TODO) test 'The correctly escaped body should be visible when actually posting in the blog' +# in ../lib/Opera/MyOperaMechanizeTester.pm at line 111. +# searched: " is your friend' message is not there (for testuser) +# The ' is your friend' message is not there (for testuser) +# The ' is your friend' message is not there (for testuser) +ok +t/friends/003-ignore_friends...........# The ' is your friend' message is not there (for testuser) +ok +t/friends/004-foaf.....................ok +t/friends/005-pagination...............ok +t/friends/006-invite_friends...........ok +t/groups/000-setup.....................ok +t/groups/001-group.....................ok +t/groups/002-albums....................ok +t/groups/003-permissions...............ok +t/groups/004-tags......................ok +t/groups/005-edit_profile..............ok +t/groups/006-group_albums..............ok +t/groups/007-applications..............ok +t/links/000-setup......................ok +t/links/001-create_links...............ok +t/login/000-setup......................ok +t/login/001-login......................ok +t/login/002-signup.....................ok +t/login/003-lost_and_reset_password....ok +t/messages/000-setup...................ok +t/messages/001-send....................ok +t/messages/002-delete..................ok +t/messages/003-misc....................ok +t/messages/004-limit...................ok +t/misc/000-setup.......................ok +t/misc/001-smileys.....................ok +t/misc/002-urls........................ok +t/misc/003-events......................ok +t/misc/004-design......................ok +t/misc/005-subscriptions...............ok +t/misc/006-titles......................ok +t/misc/007-top_bar.....................ok +t/misc/008-xml.........................ok +t/mms/000-setup........................ok +t/mms/001-blog_post....................ok +t/mms/002-album_post................... +# Failed (TODO) test 'Should find 'Iván Ferreiro' in the image properties, from the image filename' +# in ../lib/Opera/MyOperaMechanizeTester.pm at line 111. +# searched: "\n# \n# 500 Internal Server Error\n# \n#

Internal Server Error

\n#

The server encountered an internal error or\n# misconfiguration and was unable to complete\n# your request.

\n#

Please contact the server administrator,\n# my@opera.com and inform them of the time the error occurred,\n# and anything you might have done that may have\n# caused the error.

\n#

More information about this error may be available\n# in the server error log.

\n#
\n#
Apache/2.2.3 (Debian) mod-xslt/1.3.9 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 Server at auth.test.is.oslo.opera.com Port 10080
\n# \n# '\n# doesn't match '(?-xism:404)'\n# Looks like you failed 1 test of 2.\n", + "") + end + + def expected_second_test_failure + TestErrorEntry.create_failure("t/auth/002-registration", + "# Failed test at t/auth/002-registration.t line 67.\n# '\n# \n# 500 Internal Server Error\n# \n#

Internal Server Error

\n#

The server encountered an internal error or\n# misconfiguration and was unable to complete\n# your request.

\n#

Please contact the server administrator,\n# my@opera.com and inform them of the time the error occurred,\n# and anything you might have done that may have\n# caused the error.

\n#

More information about this error may be available\n# in the server error log.

\n#
\n#
Apache/2.2.3 (Debian) mod-xslt/1.3.9 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 Server at auth.test.is.oslo.opera.com Port 10080
\n# \n# '\n# doesn't match '(?-xism:401)'\n\n# Failed test at t/auth/002-registration.t line 77.\n# '\n# \n# 500 Internal Server Error\n# \n#

Internal Server Error

\n#

The server encountered an internal error or\n# misconfiguration and was unable to complete\n# your request.

\n#

Please contact the server administrator,\n# my@opera.com and inform them of the time the error occurred,\n# and anything you might have done that may have\n# caused the error.

\n#

More information about this error may be available\n# in the server error log.

\n#
\n#
Apache/2.2.3 (Debian) mod-xslt/1.3.9 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 Server at auth.test.is.oslo.opera.com Port 10080
\n# \n# '\n# doesn't match '(?-xism:401)'\n\n# Failed test at t/auth/002-registration.t line 87.\n# '\n# \n# 500 Internal Server Error\n# \n#

Internal Server Error

\n#

The server encountered an internal error or\n# misconfiguration and was unable to complete\n# your request.

\n#

Please contact the server administrator,\n# my@opera.com and inform them of the time the error occurred,\n# and anything you might have done that may have\n# caused the error.

\n#

More information about this error may be available\n# in the server error log.

\n#
\n#
Apache/2.2.3 (Debian) mod-xslt/1.3.9 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 Server at auth.test.is.oslo.opera.com Port 10080
\n# \n# '\n# doesn't match '(?-xism:406)'\n\n# Failed test at t/auth/002-registration.t line 154.\n# '\n# \n# 500 Internal Server Error\n# \n#

Internal Server Error

\n#

The server encountered an internal error or\n# misconfiguration and was unable to complete\n# your request.

\n#

Please contact the server administrator,\n# my@opera.com and inform them of the time the error occurred,\n# and anything you might have done that may have\n# caused the error.

\n#

More information about this error may be available\n# in the server error log.

\n#
\n#
Apache/2.2.3 (Debian) mod-xslt/1.3.9 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 Server at auth.test.is.oslo.opera.com Port 10080
\n# \n# '\n# doesn't match '(?-xism:403)'\n# Looks like you failed 4 tests of 7.\n", + "") + end + + def expected_third_test_failure + TestErrorEntry.create_failure("t/blogs/004-languages", + "# Failed test 'Serbian blog post in 'Local blogs''\n# at t/blogs/004-languages.t line 59.\n# searched: \"\\x{0a}\\x{0a}\\x{0a}\\x{0a}\\x{0a}\\x{0a} + + + After a blank line + + +2) /usr/share/perl5/Error.pm:274 - test_receive_updates(FunctionalTests::T008PushServer) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +3) /usr/share/perl5/Error.pm:274 - test_case_insensitiveness(FunctionalTests::T008PushServer) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +4) /usr/share/perl5/Error.pm:274 - test_modify_element(FunctionalTests::T004Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +5) /usr/share/perl5/Error.pm:274 - test_readd_element2(FunctionalTests::T004Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +6) /usr/share/perl5/Error.pm:274 - test_readd_element(FunctionalTests::T004Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +7) /usr/share/perl5/Error.pm:274 - test_move_element(FunctionalTests::T004Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +8) /usr/share/perl5/Error.pm:274 - test_elements(FunctionalTests::T004Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +9) /usr/share/perl5/Error.pm:274 - test_same_element(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +10) /usr/share/perl5/Error.pm:274 - test_delete_non_existent_element(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +11) /usr/share/perl5/Error.pm:274 - test_move_elements_around2(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +12) /usr/share/perl5/Error.pm:274 - test_drop_to_root_all_elements_previous(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +13) /usr/share/perl5/Error.pm:274 - test_include_data_sent_in_dirty_request(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +14) /usr/share/perl5/Error.pm:274 - test_fishy_visited_date(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +15) /usr/share/perl5/Error.pm:274 - test_drop_to_root_order(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +16) /usr/share/perl5/Error.pm:274 - test_get_data_in_a_dirty_sync(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +17) /usr/share/perl5/Error.pm:274 - test_drop_to_root_all_elements_previous_different_order(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +18) /usr/share/perl5/Error.pm:274 - test_drop_to_root_first_parent(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +19) /usr/share/perl5/Error.pm:274 - test_move_separator(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +20) /usr/share/perl5/Error.pm:274 - test_drop_separator_to_root(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +21) /usr/share/perl5/Error.pm:274 - test_drop_to_root_last_previous(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +22) /usr/share/perl5/Error.pm:274 - test_add_in_deleted_folder(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +23) /usr/share/perl5/Error.pm:274 - test_move_elements_around(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +24) /usr/share/perl5/Error.pm:274 - test_move_folder_inside_contained_folder(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +25) /usr/share/perl5/Error.pm:274 - test_drop_to_root_middle_previous(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +26) /usr/share/perl5/Error.pm:274 - test_add_separator(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +27) /usr/share/perl5/Error.pm:274 - test_modify_folder_same_parent(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +28) /usr/share/perl5/Error.pm:274 - test_drop_to_root_first_previous(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +29) /usr/share/perl5/Error.pm:274 - test_same_folder_and_element_twice(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +30) /usr/share/perl5/Error.pm:274 - test_drop_to_root_all_elements_parent(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +31) /usr/share/perl5/Error.pm:274 - test_drop_to_root_all_elements_parent_different_order(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +32) /usr/share/perl5/Error.pm:274 - test_drop_to_root_last_parent(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +33) /usr/share/perl5/Error.pm:274 - test_drop_to_root_middle_parent(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +34) /usr/share/perl5/Error.pm:274 - test_delete_and_receive_another_client(FunctionalTests::T005Element) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +35) /usr/share/perl5/Error.pm:274 - test_elems(FunctionalTests::T010Elems) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +36) /usr/share/perl5/Error.pm:274 - test_move_elem(FunctionalTests::T010Elems) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +37) /usr/share/perl5/Error.pm:274 - test_readd_elem(FunctionalTests::T010Elems) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +38) /usr/share/perl5/Error.pm:274 - test_readd_elem2(FunctionalTests::T010Elems) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +39) /usr/share/perl5/Error.pm:274 - test_modify_elem(FunctionalTests::T010Elems) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +40) /usr/share/perl5/Error.pm:274 - test_wrong_protocol_version(FunctionalTests::T003MiscErrorCodes) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +41) /usr/share/perl5/Error.pm:274 - test_no_post_data(FunctionalTests::T003MiscErrorCodes) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +42) /usr/share/perl5/Error.pm:274 - test_wrong_encoding(FunctionalTests::T003MiscErrorCodes) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +43) /usr/share/perl5/Error.pm:274 - test_user_unavailable(FunctionalTests::T003MiscErrorCodes) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +44) /usr/share/perl5/Error.pm:274 - test_invalid_status(FunctionalTests::T003MiscErrorCodes) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +45) /usr/share/perl5/Error.pm:274 - test_invalid_request(FunctionalTests::T003MiscErrorCodes) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +46) /usr/share/perl5/Error.pm:274 - test_banned_builds(FunctionalTests::T003MiscErrorCodes) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +47) /usr/share/perl5/Error.pm:274 - test_invalid_xml(FunctionalTests::T003MiscErrorCodes) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +48) /usr/share/perl5/Error.pm:274 - test_incorrect_dirty_flag(FunctionalTests::T003MiscErrorCodes) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +49) /usr/share/perl5/Error.pm:274 - test_delete_element_outside_target(FunctionalTests::T006AnotherElement) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +50) /usr/share/perl5/Error.pm:274 - test_move_target_folder_around(FunctionalTests::T006AnotherElement) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +51) /usr/share/perl5/Error.pm:274 - test_delete_target_folder(FunctionalTests::T006AnotherElement) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +52) /usr/share/perl5/Error.pm:274 - test_moving_bm_to_trash(FunctionalTests::T006AnotherElement) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +53) /usr/share/perl5/Error.pm:274 - test_create_element(FunctionalTests::T006AnotherElement) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +54) /usr/share/perl5/Error.pm:274 - test_create_folder(FunctionalTests::T006AnotherElement) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +55) /usr/share/perl5/Error.pm:274 - test_show_on_start_page(FunctionalTests::T006AnotherElement) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +56) /usr/share/perl5/Error.pm:274 - test_move_separator_out_of(FunctionalTests::T006AnotherElement) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +57) /usr/share/perl5/Error.pm:274 - test_move_element_out_of_target(FunctionalTests::T006AnotherElement) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +58) /usr/share/perl5/Error.pm:274 - test_case_insensitiveness(FunctionalTests::T006AnotherElement) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +59) /usr/share/perl5/Error.pm:274 - test_moving_between_targets(FunctionalTests::T007Targets) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +60) /usr/share/perl5/Error.pm:274 - test_deleting_from_target(FunctionalTests::T007Targets) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +61) /usr/share/perl5/Error.pm:274 - test_create_target_folder(FunctionalTests::T007Targets) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +62) /usr/share/perl5/Error.pm:274 - test_migration_10_11(FunctionalTests::T009VersionManager) +Couldn't get user info for testuser1 with the following XML (code 500): + + + + + After a blank line + + +63) /usr/share/perl5/Error.pm:274 - test_handle_broken_separators_desktop(FunctionalTests::T011ClientBugWorkarounds) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +64) /usr/share/perl5/Error.pm:274 - test_utf8_username(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +65) /usr/share/perl5/Error.pm:274 - test_status_modified_non_destructive(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +66) /usr/share/perl5/Error.pm:274 - test_get_update(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +67) /usr/share/perl5/Error.pm:274 - test_icon(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +68) /usr/share/perl5/Error.pm:274 - test_supports(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +69) /usr/share/perl5/Error.pm:274 - test_move_folder(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +70) /usr/share/perl5/Error.pm:274 - test_misc_attributes(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +71) /usr/share/perl5/Error.pm:274 - test_move_inside_folders(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +72) /usr/share/perl5/Error.pm:274 - test_move_element(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +73) /usr/share/perl5/Error.pm:274 - test_simple_element(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +74) /usr/share/perl5/Error.pm:274 - test_simple_add(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +75) /usr/share/perl5/Error.pm:274 - test_elements_in_row(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +76) /usr/share/perl5/Error.pm:274 - test_dirty_flag(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +77) /usr/share/perl5/Error.pm:274 - test_delete_folder_update(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +78) /usr/share/perl5/Error.pm:274 - test_authentication(FunctionalTests::T001SmokeTests) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +79) /usr/share/perl5/Error.pm:274 - test_modify_inconsistent_parent_and_previous(FunctionalTests::T002InconsistentData) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +80) /usr/share/perl5/Error.pm:274 - test_nonexistent_as_modified(FunctionalTests::T002InconsistentData) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +81) /usr/share/perl5/Error.pm:274 - test_non_existent_parent(FunctionalTests::T002InconsistentData) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +82) /usr/share/perl5/Error.pm:274 - test_parent_not_a_folder(FunctionalTests::T002InconsistentData) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +83) /usr/share/perl5/Error.pm:274 - test_higher_syncstate(FunctionalTests::T002InconsistentData) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +84) /usr/share/perl5/Error.pm:274 - test_funny_chars(FunctionalTests::T002InconsistentData) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +85) /usr/share/perl5/Error.pm:274 - test_add_inconsistent_parent_and_previous(FunctionalTests::T002InconsistentData) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + +86) /usr/share/perl5/Error.pm:274 - test_non_existent_previous(FunctionalTests::T002InconsistentData) +Couldn't get user info for tester with the following XML (code 500): + + + + + After a blank line + + + +Test was not successful. +EOF + + +LOG_OUTPUT_WITH_ERRORS_AND_FAILURES2 = < + + + 5 + 120 + + + + + + + + + +F.E..........................................................Unexpected number of elements (expected 3). Received this: + + + + 5 + 120 + + + + + + + + + +F................................... +Time: 165 wallclock secs (16.72 usr + 1.10 sys = 17.82 CPU) + +!!!FAILURES!!! +Test Results: +Run: 100, Failures: 2, Errors: 2 + +There were 2 errors: +1) /usr/share/perl5/Error.pm:274 - test_sane_update(FunctionalTests::T013Update) +FunctionalTests.pm:1140 - Can't find element '111dir1dup' in + + + + 5 + 120 + + + +2) /usr/share/perl5/Error.pm:274 - test_simple(FunctionalTests::T013Update) +FunctionalTests.pm:1126 - Can't find element '001simpleduplicated' in + + + + 5 + 120 + + + + +There were 2 failures: +1) FunctionalTests.pm:620 - test_non_ascii(FunctionalTests::T013Update) +FunctionalTests/T013Update.pm:156 - 2 elements for 'tester', expected 1 + +2) FunctionalTests.pm:620 - test_case_insensitiveness(FunctionalTests::T006AnotherElement) +FunctionalTests/T006AnotherElement.pm:191 - 4 elements for 'tester', expected 3 + +Test was not successful. +EOF + + + + + def test_should_not_find_test_errors_with_a_build_with_test_failures + collector = TestCollectors::PerlTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_JUST_FAILURES)) + assert_equal 0, collector.test_errors.length + end + + def test_should_find_no_test_errors_with_successful_build + collector = TestCollectors::PerlTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITHOUT_ERRORS)) + assert_equal 0, collector.test_errors.length + end + + def test_should_find_test_errors_with_unsuccessful_build + collector = TestCollectors::PerlTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_ERRORS_AND_FAILURES)) + assert_equal 1, collector.test_errors.length + assert_equal expected_test_error.test_name, collector.test_errors.first.test_name + assert_equal expected_test_error.message, collector.test_errors.first.message + assert_equal expected_test_error.stacktrace, collector.test_errors.first.stacktrace + end + + def test_should_find_errors_even_with_blank_lines + collector = TestCollectors::PerlTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_MANY_ERRORS_WITH_BLANK_LINES)) + assert_equal TestErrorEntry.create_error("test_simple_unsubscription(FunctionalTests::T008PushServer)", + "Couldn't get user info for tester with the following XML (code 500):\n\n \n\n After a blank line\n", + ""), + collector.test_errors.first + assert_equal 86, collector.test_errors.length + end + + + def expected_test_error + TestErrorEntry.create_error("test_drop_to_root_first_previous(FunctionalTests::T005Element)", + "FunctionalTests.pm:892 - Can't find element 'foobarbaz' in", + "") + end + + + + + + + def test_should_not_find_test_failures_with_a_build_with_test_errors + collector = TestCollectors::PerlTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_JUST_ERRORS)) + assert_equal 0, collector.test_failures.length + end + + def test_should_find_no_test_failures_with_successful_build + collector = TestCollectors::PerlTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITHOUT_ERRORS)) + assert_equal 0, collector.test_failures.length + end + + def test_should_find_test_failures + collector = TestCollectors::PerlTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_JUST_FAILURES)) + test_failures = collector.test_failures + assert_equal expected_first_test_failure, test_failures[0] + assert_equal expected_second_test_failure, test_failures[1] + assert_equal 2, test_failures.length + end + + def expected_first_test_failure + TestErrorEntry.create_failure("test_delete_element_outside_target(FunctionalTests::T006Targets)", + "FunctionalTests/T006Targets.pm:163 - 2 elements for 'tester', expected 3", + "") + end + + def expected_second_test_failure + TestErrorEntry.create_failure("test_case_insensitiveness(FunctionalTests::T008Server)", + "FunctionalTests/T008Server.pm:169 - Expected to receive 'foo,bar,baz', received ''", + "") + end + + def test_should_find_both_tests_and_failures + collector = TestCollectors::PerlTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_ERRORS_AND_FAILURES2)) + test_failures = collector.test_failures + test_errors = collector.test_errors + assert_equal 2, test_failures.length + assert_equal 2, test_errors.length + assert_equal expected_first_test_failure_in_mix, test_failures[0] + assert_equal expected_second_test_failure_in_mix, test_failures[1] + assert_equal expected_first_test_error_in_mix, test_errors[0] + assert_equal expected_second_test_error_in_mix, test_errors[1] + assert_equal 4, collector.test_nonpasses.length + end + + def expected_first_test_failure_in_mix + TestErrorEntry.create_failure("test_non_ascii(FunctionalTests::T013Update)", + "FunctionalTests/T013Update.pm:156 - 2 elements for 'tester', expected 1", + "") + end + + def expected_second_test_failure_in_mix + TestErrorEntry.create_failure("test_case_insensitiveness(FunctionalTests::T006AnotherElement)", + "FunctionalTests/T006AnotherElement.pm:191 - 4 elements for 'tester', expected 3", + "") + end + + def expected_first_test_error_in_mix + TestErrorEntry.create_error("test_sane_update(FunctionalTests::T013Update)", + "FunctionalTests.pm:1140 - Can't find element '111dir1dup' in + + + + 5 + 120 + +", + "") + end + + def expected_second_test_error_in_mix + TestErrorEntry.create_error("test_simple(FunctionalTests::T013Update)", + "FunctionalTests.pm:1126 - Can't find element '001simpleduplicated' in + + + + 5 + 120 + +", + "") + end + +end diff -urN cruisecontrol-1.4.0/test/unit/test_collector_ruby_test_unit_test.rb cruisecontrol-1.4.0-opera-patched/test/unit/test_collector_ruby_test_unit_test.rb --- cruisecontrol-1.4.0/test/unit/test_collector_ruby_test_unit_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ cruisecontrol-1.4.0-opera-patched/test/unit/test_collector_ruby_test_unit_test.rb 2009-12-17 14:37:09.000000000 +0100 @@ -0,0 +1,216 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'test_collectors/ruby_test_unit' + +class TestCollectorRubyTestUnitTest < Test::Unit::TestCase + +LOG_OUTPUT_WITH_NO_TEST_ERRORS = < + C:/projects/cruisecontrol.rb/builds/ccrb/work/config/../vendor/rails/actionpack/lib/action_controller/test_process.rb:456:in `method_missing' + ./test/unit/test_failure_parser_test.rb:75:in `test_should_fail_due_to_comparing_same_objects_with_different_data' + C:/projects/cruisecontrol.rb/builds/ccrb/work/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `__send__' + C:/projects/cruisecontrol.rb/builds/ccrb/work/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `run' + +83 tests, 185 assertions, 2 failures, 0 errors +EOF + +LOG_OUTPUT_WITH_TEST_FAILURE = < expected but was +<"abc">. + + 2) Failure: +test_should_check_force_build(PollingSchedulerTest) [./test/unit/polling_scheduler_test.rb:44]: +#.force_build_if_requested - expected calls: 1, actual calls: 2 + +125 tests, 284 assertions, 1 failures, 0 errors +/usr/bin/ruby1.8 -Ilib:test "/usr/lib/ruby/1.8/rake/rake_test_loader.rb" "test/functional/projects_controller_test.rb" +Loaded suite /usr/lib/ruby/1.8/rake/rake_test_loader +Started +.......... +Finished in 0.251448 seconds. + +10 tests, 23 assertions, 0 failures, 0 errors +/usr/bin/ruby1.8 -Ilib:test "/usr/lib/ruby/1.8/rake/rake_test_loader.rb" "test/integration/builder_integration_test.rb" +Loaded suite /usr/lib/ruby/1.8/rake/rake_test_loader +Started +.............. +Finished in 25.224997 seconds. + +14 tests, 28 assertions, 0 failures, 0 errors +rake aborted! +Test failures +EOF + + def test_should_not_find_test_errors_with_a_build_with_test_failures + collector = TestCollectors::RubyTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_TEST_FAILURE)) + assert_equal 0, collector.test_errors.length + end + + def test_should_find_no_test_errors_with_successful_build + collector = TestCollectors::RubyTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_NO_TEST_ERRORS)) + assert_equal 0, collector.test_errors.length + end + + def test_should_find_test_errors_with_unsuccessful_build + collector = TestCollectors::RubyTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_TEST_ERRORS)) + assert_equal 1, collector.test_errors.length + assert_equal expected_test_error.test_name, collector.test_errors.first.test_name + assert_equal expected_test_error.message, collector.test_errors.first.message + assert_equal expected_test_error.stacktrace, collector.test_errors.first.stacktrace + end + + + def expected_test_error + TestErrorEntry.create_error("test_should_fail_due_to_comparing_same_objects_with_different_data(TestFailureParserTest)", + "NameError: undefined local variable or method `expectedFirstTestFixture' for #", + " C:/projects/cruisecontrol.rb/builds/ccrb/work/config/../vendor/rails/actionpack/lib/action_controller/test_process.rb:456:in `method_missing'\n" + + " ./test/unit/test_failure_parser_test.rb:75:in `test_should_fail_due_to_comparing_same_objects_with_different_data'\n" + + " C:/projects/cruisecontrol.rb/builds/ccrb/work/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `__send__'\n" + + " C:/projects/cruisecontrol.rb/builds/ccrb/work/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `run'") + end + + + + + + +LOG_OUTPUT_WITH_NO_TEST_FAILURE = < expected but was +<"abc">. + + 2) Failure: +test_should_fail_two(SubversionLogParserTest) + [./test/unit/subversion_log_parser_test.rb:129:in `test_should_fail_two' + C:/projects/cruisecontrol.rb/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `__send__' + C:/projects/cruisecontrol.rb/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `run']: +<1> expected but was +<"abc">. + +83 tests, 185 assertions, 2 failures, 0 errors +EOF + +LOG_OUTPUT_WITH_MOCK_TEST_FAILURE = <.force_build_if_requested - expected calls: 1, actual calls: 2 + +126 tests, 284 assertions, 1 failures, 0 errors + +EOF + + def test_should_not_find_test_failures_with_a_build_with_test_errors + collector = TestCollectors::RubyTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_TEST_ERRORS)) + assert_equal 0, collector.test_failures.length + end + + def test_should_find_no_test_failures_with_successful_build + collector = TestCollectors::RubyTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_NO_TEST_FAILURE)) + assert_equal 0, collector.test_failures.length + end + + def test_should_find_test_failures + collector = TestCollectors::RubyTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_TEST_FAILURES)) + test_failures = collector.test_failures + assert_equal 2, test_failures.length + assert_equal expected_first_test_failure, test_failures[0] + assert_equal expected_second_test_failure, test_failures[1] + end + + def test_should_correctly_parse_mocha_test_failures + collector = TestCollectors::RubyTestUnit.new(TestCollectors::FakeBuild.new(LOG_OUTPUT_WITH_MOCK_TEST_FAILURE)) + test_failures = collector.test_failures + assert_equal 1, test_failures.length + assert_equal expected_mock_test_failure, test_failures.first + end + + def expected_first_test_failure + TestErrorEntry.create_failure("test_should_fail(SubversionLogParserTest)", + "<1> expected but was\n<\"abc\">.", + "./test/unit/subversion_log_parser_test.rb:125:in `test_should_fail'\n" + + " C:/projects/cruisecontrol.rb/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `__send__'\n" + + " C:/projects/cruisecontrol.rb/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `run'") + end + + def expected_second_test_failure + TestErrorEntry.create_failure("test_should_fail_two(SubversionLogParserTest)", + "<1> expected but was\n<\"abc\">.", + "./test/unit/subversion_log_parser_test.rb:129:in `test_should_fail_two'\n" + + " C:/projects/cruisecontrol.rb/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `__send__'\n" + + " C:/projects/cruisecontrol.rb/config/../vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:19:in `run'") + end + + def expected_mock_test_failure + TestErrorEntry.create_failure("test_should_check_force_build(PollingSchedulerTest)", + "#.force_build_if_requested - expected calls: 1, actual calls: 2", + "./test/unit/polling_scheduler_test.rb:44") + end + +end