bin/jazrb in smparkes-jazrb-0.0.9 vs bin/jazrb in smparkes-jazrb-0.0.10

- old
+ new

@@ -2,52 +2,59 @@ $VERBOSE = true require 'jazrb/options' -ENV["JAZRB_JS_PATH"] = JAZ_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'jazrb')) -INTRO = File.join(JAZ_DIR, "intro.js") -OUTRO = File.join(JAZ_DIR, "outro.js") +ENV["JAZRB_JS_PATH"] = + JAZ_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'jazrb')) +intro = File.join(JAZ_DIR, "intro.js") +outro = File.join(JAZ_DIR, "outro.js") + +if $jazrb_qunit + intro = File.join(JAZ_DIR, "qintro.js") + outro = File.join(JAZ_DIR, "qoutro.js") +end + args = [ "envjsrb" ] if $jazrb_deps args += [ "--deps", $jazrb_deps ] end -args << INTRO +args << intro introd = true outrod = true ARGV.each do |f| if f =~ /\.x?html?$/ || f =~ %r(^https?://) if introd && !outrod - args << OUTRO + args << outro args << "about:blank" outrod = true introd = false end if !introd - args << INTRO + args << intro end args << f introd = true outrod = false elsif f == "about:blank" if introd && !outrod - args << OUTRO + args << outro outrod = true introd = false end args << f else args << f end end -args << OUTRO +args << outro cmd = args.join(" ") puts cmd if $jazrb_verbose @@ -81,11 +88,11 @@ when "testsuites"; when "testsuite"; @testsuite_name = attrs["name"] when "testcase"; $spec_info[:specs] << (tc = {}) - tc[:name] = @testsuite_name + tc[:name] = @testsuite_name + " : " + attrs["name"] @testcase_failed = false when "failure"; $spec_info[:failures] << (tc = $spec_info[:specs].last) tc[:message] = attrs["message"] @testcase_failed = true @@ -120,10 +127,12 @@ else; raise "hell: #{name}" end end end +$failed_processes = 0 + module WriteToNokogiri def post_init @parser = Nokogiri::XML::SAX::PushParser.new( SAX.new ) end def receive_data data @@ -139,35 +148,58 @@ $stderr.puts "Parser raised #{e} on #{data}" exit 1 end end def unbind + $failed_processes += 1 if get_status.exitstatus && + get_status.exitstatus > 0 EM.stop end end date = Time.now +failures = nil +examples = nil +pending = nil + EM.run do EM.popen cmd, WriteToNokogiri end puts puts if !$jazrb_xml $spec_info[:failures].each_with_index do |failure,i| print i+1,")\n" print red("#{failure[:name]} FAILED\n") print red(failure[:message]),"\n" - print failure[:stack],"\n" + # double check, but is there really anything in the jaz stack that's useful? + stack = failure[:stack] + stack and ( stack = stack.split "\n" ) + stack and stack.each do |line| + if line =~ %r(/jasmine.js:\d+) || line =~ %r(/jasmine/src/.*\.js:\d+) + break + end + print line, "\n" + end + # p stack + # print failure[:stack],"\n" end puts "Finished in #{Time.now - date} seconds" puts - msg = "#{$spec_info[:specs].length} examples, #{$spec_info[:failures].length} failures, #{$spec_info[:pending].length} pending" - if $spec_info[:failures].length > 0 + examples = $spec_info[:specs].length + failures = $spec_info[:failures].length + pending = $spec_info[:pending].length + if $failed_processes > 0 + examples += $failed_processes + failures += $failed_processes + end + msg = "#{examples} examples, #{failures} failures, #{pending} pending" + if failures > 0 msg = red(msg) - elsif $spec_info[:pending].length > 0 + elsif pending > 0 msg = yellow(msg) else msg = green(msg) end puts msg end -exit $spec_info[:failures].length > 0 ? 1 : 0 +exit ( !failures.nil? && failures > 0 ) ? 1 : 0