From 5e1520a7324b94a722068f79cae7e77febb78202 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 10 Jun 2011 11:10:09 -0400 Subject: [PATCH] option to not run all tests if you don't want it to --- bin/jasmine-headless-webkit | 14 +++++-- spec/bin/jasmine-headless-webkit_spec.rb | 47 ++++++++++++++++-------- 2 files changed, 42 insertions(+), 19 deletions(-) diff --git a/bin/jasmine-headless-webkit b/bin/jasmine-headless-webkit index 574dcf2..716008d 100755 --- a/bin/jasmine-headless-webkit +++ b/bin/jasmine-headless-webkit @@ -31,14 +31,16 @@ opts = GetoptLong.new( [ '--no-colors', GetoptLong::NO_ARGUMENT ], [ '--keep', GetoptLong::NO_ARGUMENT ], [ '--report', GetoptLong::REQUIRED_ARGUMENT ], - [ '--jasmine-config', '-j', GetoptLong::REQUIRED_ARGUMENT ] + [ '--jasmine-config', '-j', GetoptLong::REQUIRED_ARGUMENT ], + [ '--no-full-run', GetoptLong::NO_ARGUMENT ] ) options = { :colors => false, :remove_html_file => true, :jasmine_config => 'spec/javascripts/support/jasmine.yml', - :report => false + :report => false, + :full_run => true } @process_options = lambda { |*args| @@ -55,6 +57,8 @@ options = { options[:report] = arg when '--jasmine-config', '-j' options[:jasmine_config] = arg + when '--no-full-run' + options[:full_run] = false end } @@ -68,7 +72,11 @@ files_list = Jasmine::FilesList.new( :only => ARGV.dup ) -system jasmine_command(options, targets = Jasmine::TemplateWriter.write!(files_list)) +targets = Jasmine::TemplateWriter.write!(files_list) +run_targets = targets.dup +run_targets.pop if !options[:full_run] + +system jasmine_command(options, run_targets) status = $?.exitstatus if options[:remove_html_file] || (status == 0) diff --git a/spec/bin/jasmine-headless-webkit_spec.rb b/spec/bin/jasmine-headless-webkit_spec.rb index b2f49bb..c1a10fc 100644 --- a/spec/bin/jasmine-headless-webkit_spec.rb +++ b/spec/bin/jasmine-headless-webkit_spec.rb @@ -65,26 +65,41 @@ describe "jasmine-headless-webkit" do end describe 'with filtered run' do - it "should fail and not run the second" do - system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_failure/filtered_failure.yml --report #{report} ./spec/jasmine/filtered_failure/failure_spec.js} - $?.exitstatus.should == 1 + context "don't run a full run, just the filtered run" do + it "should succeed and run both" do + system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --no-full-run --report #{report} ./spec/jasmine/filtered_success/success_one_spec.js} + $?.exitstatus.should == 0 - parts = File.read(report).strip.split('/') - parts.length.should == 4 - parts[0].should == "1" - parts[1].should == "1" - parts[2].should == "F" + parts = File.read(report).strip.split('/') + parts.length.should == 4 + parts[0].should == "1" + parts[1].should == "0" + parts[2].should == "F" + end end - it "should succeed and run both" do - system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --report #{report} ./spec/jasmine/filtered_success/success_one_spec.js} - $?.exitstatus.should == 0 + context "do both runs" do + it "should fail and not run the second" do + system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_failure/filtered_failure.yml --report #{report} ./spec/jasmine/filtered_failure/failure_spec.js} + $?.exitstatus.should == 1 - parts = File.read(report).strip.split('/') - parts.length.should == 4 - parts[0].should == "2" - parts[1].should == "0" - parts[2].should == "F" + parts = File.read(report).strip.split('/') + parts.length.should == 4 + parts[0].should == "1" + parts[1].should == "1" + parts[2].should == "F" + end + + it "should succeed and run both" do + system %{bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --report #{report} ./spec/jasmine/filtered_success/success_one_spec.js} + $?.exitstatus.should == 0 + + parts = File.read(report).strip.split('/') + parts.length.should == 4 + parts[0].should == "2" + parts[1].should == "0" + parts[2].should == "F" + end end end end