diff --git a/ext/jasmine-webkit-specrunner/specrunner.cpp b/ext/jasmine-webkit-specrunner/specrunner.cpp index 1f68c2a..7723be7 100644 --- a/ext/jasmine-webkit-specrunner/specrunner.cpp +++ b/ext/jasmine-webkit-specrunner/specrunner.cpp @@ -248,7 +248,13 @@ void HeadlessSpecRunner::finishSuite(const QString &duration, const QString &tot std::cout << "FAIL: "; } else { green(); - std::cout << "PASS: "; + std::cout << "PASS"; + + if (hasErrors) { + std::cout << " with JS errors"; + } + + std::cout << ": "; } std::cout << qPrintable(total) << " tests, " << qPrintable(failed) << " failures, " << qPrintable(duration) << " secs."; @@ -280,24 +286,22 @@ void HeadlessSpecRunner::timerEvent(QTimerEvent *event) if (hasErrors && m_runs > 2) QApplication::instance()->exit(1); - if (!hasErrors) { - if (isFinished) { - int exitCode = 0; - if (didFail) { - exitCode = 1; - } else { - if (usedConsole) { - exitCode = 2; - } + if (isFinished) { + int exitCode = 0; + if (didFail || hasErrors) { + exitCode = 1; + } else { + if (usedConsole) { + exitCode = 2; } - - QApplication::instance()->exit(exitCode); } - if (m_runs > 30) { - std::cout << "WARNING: too many runs and the test is still not finished!" << std::endl; - QApplication::instance()->exit(1); - } + QApplication::instance()->exit(exitCode); + } + + if (m_runs > 30) { + std::cout << "WARNING: too many runs and the test is still not finished!" << std::endl; + QApplication::instance()->exit(1); } } diff --git a/spec/bin/jasmine-headless-webkit_spec.rb b/spec/bin/jasmine-headless-webkit_spec.rb index b66ca83..85aeed2 100644 --- a/spec/bin/jasmine-headless-webkit_spec.rb +++ b/spec/bin/jasmine-headless-webkit_spec.rb @@ -24,6 +24,20 @@ describe "jasmine-headless-webkit" do end end + + describe 'success but with js error' do + it "should succeed with error code 0" do + system %{bin/jasmine-headless-webkit -j spec/jasmine/success_with_error/success_with_error.yml --report #{report}} + $?.exitstatus.should == 1 + + parts = File.read(report).strip.split('/') + parts.length.should == 4 + parts[0].should == "1" + parts[1].should == "0" + parts[2].should == "F" + end + end + describe 'failure' do it "should fail with an error code of 1" do system %{bin/jasmine-headless-webkit -j spec/jasmine/failure/failure.yml --report #{report}} diff --git a/spec/jasmine/success_with_error/success_with_error.js b/spec/jasmine/success_with_error/success_with_error.js new file mode 100644 index 0000000..a6ae9b4 --- /dev/null +++ b/spec/jasmine/success_with_error/success_with_error.js @@ -0,0 +1,3 @@ +var good = 2; +var bad = null; +if (bad.myProperty) {} diff --git a/spec/jasmine/success_with_error/success_with_error.yml b/spec/jasmine/success_with_error/success_with_error.yml new file mode 100644 index 0000000..16ec4c5 --- /dev/null +++ b/spec/jasmine/success_with_error/success_with_error.yml @@ -0,0 +1,9 @@ +src_files: + - spec/jasmine/success_with_error/success_with_error.js + +spec_files: + - spec/jasmine/success_with_error/success_with_error_spec.js + +src_dir: . +spec_dir: . + diff --git a/spec/jasmine/success_with_error/success_with_error_spec.js b/spec/jasmine/success_with_error/success_with_error_spec.js new file mode 100644 index 0000000..4012bb1 --- /dev/null +++ b/spec/jasmine/success_with_error/success_with_error_spec.js @@ -0,0 +1,6 @@ +describe('Success with error', function() { + it("should not fail", function() { + expect(good).toEqual(2); + }) +}); +