From 7f6030bc362f00867479ae92b63c20ab008f83fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Sun, 10 Jul 2011 13:32:32 +0100 Subject: [PATCH] Fix junit formatter problems on Windows. Closes #81. Closes #86. --- History.md | 1 + legacy_features/junit_formatter.feature | 14 +++++++------- lib/cucumber/formatter/junit.rb | 3 +-- spec/cucumber/formatter/junit_spec.rb | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/History.md b/History.md index 522f17e3087..7b61f2db9c4 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ ### Bugfixes * Removed extra colons emitted by rerun formatter ([#99](https://github.com/cucumber/cucumber/pull/99) Juan Manuel Barreneche) * cucumber 1.0.0 wrong number of arguments error when generating json format on jruby for windows ([#97](https://github.com/cucumber/cucumber/issues/97) (Aslak Hellesøy) +* Recent change to junit.rb breaks on Windows ([#81](https://github.com/cucumber/cucumber/issues/81), [#86](https://github.com/cucumber/cucumber/pull/86) Johnlon, Aslak Hellesøy) ### New Features * If the CUCUMBER_TRUNCATE_OUTPUT environment variable is set, lines will be truncated. Used by the Cucumber book. (Aslak Hellesøy) diff --git a/legacy_features/junit_formatter.feature b/legacy_features/junit_formatter.feature index d0bb00b19c1..73ed7b8ba42 100644 --- a/legacy_features/junit_formatter.feature +++ b/legacy_features/junit_formatter.feature @@ -12,7 +12,7 @@ Feature: JUnit output formatter """ """ - And "fixtures/junit/tmp/TEST-one_passing_one_failing.xml" with junit duration "0.005" should contain + And "fixtures/junit/tmp/TEST-features-one_passing_one_failing.xml" with junit duration "0.005" should contain """ @@ -40,7 +40,7 @@ Feature: JUnit output formatter """ """ - And "fixtures/junit/tmp/TEST-some_subdirectory_one_passing_one_failing.xml" with junit duration "0.005" should contain + And "fixtures/junit/tmp/TEST-features-some_subdirectory-one_passing_one_failing.xml" with junit duration "0.005" should contain """ @@ -68,7 +68,7 @@ Feature: JUnit output formatter """ """ - And "fixtures/junit/tmp/TEST-pending.xml" with junit duration "0.009" should contain + And "fixtures/junit/tmp/TEST-features-pending.xml" with junit duration "0.009" should contain """ @@ -88,7 +88,7 @@ Feature: JUnit output formatter """ """ - And "fixtures/junit/tmp/TEST-pending.xml" with junit duration "0.000160" should contain + And "fixtures/junit/tmp/TEST-features-pending.xml" with junit duration "0.000160" should contain """ @@ -120,8 +120,8 @@ Feature: JUnit output formatter """ """ - And "fixtures/junit/tmp/TEST-one_passing_one_failing.xml" should exist - And "fixtures/junit/tmp/TEST-pending.xml" should exist + And "fixtures/junit/tmp/TEST-features-one_passing_one_failing.xml" should exist + And "fixtures/junit/tmp/TEST-features-pending.xml" should exist Scenario: show correct error message if no --out is passed When I run cucumber --format junit features @@ -140,7 +140,7 @@ You \*must\* specify \-\-out DIR for the junit formatter """ """ - And "fixtures/junit/tmp/TEST-scenario_outline.xml" with junit duration "0.005" should contain + And "fixtures/junit/tmp/TEST-features-scenario_outline.xml" with junit duration "0.005" should contain """ diff --git a/lib/cucumber/formatter/junit.rb b/lib/cucumber/formatter/junit.rb index 8e34e043400..d1f3ecba38a 100644 --- a/lib/cucumber/formatter/junit.rb +++ b/lib/cucumber/formatter/junit.rb @@ -144,8 +144,7 @@ def feature_result_filename(feature_file) end def basename(feature_file) - ext_length = File.extname(feature_file).length - feature_file.gsub('features/', '').gsub(File::SEPARATOR, '_')[0...-ext_length] + File.basename(feature_file.gsub(/[\\\/]/, '-'), '.feature') end def write_file(feature_filename, data) diff --git a/spec/cucumber/formatter/junit_spec.rb b/spec/cucumber/formatter/junit_spec.rb index 99bc81744d4..9b58fccd91d 100644 --- a/spec/cucumber/formatter/junit_spec.rb +++ b/spec/cucumber/formatter/junit_spec.rb @@ -61,7 +61,7 @@ def write_file(feature_filename, data) }, File.join('features', 'some', 'path', 'spec.feature') it 'writes the filename including the subdirectory' do - @formatter.written_files.keys.first.should == File.join('', 'TEST-some_path_spec.xml') + @formatter.written_files.keys.first.should == File.join('', 'TEST-features-some-path-spec.xml') end end