tasks/testing.rake in opal-0.9.0.beta2 vs tasks/testing.rake in opal-0.9.0.rc1

- old
+ new

@@ -12,10 +12,11 @@ %w[ mspec/helpers/tmp mspec/helpers/environment mspec/guards/block_device mspec/guards/endian + a_file ] end def specs(env = ENV) suite = env['SUITE'] @@ -71,14 +72,16 @@ enter_benchmarking_mode = "OSpecRunner.main.bm!(#{Integer(ENV['BM'])}, '#{bm_filepath}')" end File.write filename, <<-RUBY require 'spec_helper' + require 'opal/platform' #{enter_benchmarking_mode} #{requires.join("\n ")} OSpecFilter.main.unused_filters_message(list: #{!!ENV['LIST_UNUSED_FILTERS']}) OSpecRunner.main.did_finish + exit MSpec.exit_code RUBY end def bm_filepath mkdir_p 'tmp/bench' @@ -99,24 +102,24 @@ bundle exec rake mspec_node PATTERN=spec/rubyspec/core/module/class_variable*_spec.rb bundle exec rake mspec_node PATTERN=spec/rubyspec/core/numeric/**_spec.rb DESC %w[rubyspec opal].each do |suite| - desc "Run the MSpec/#{suite} test suite on Phantom.js" + pattern_usage - task :"mspec_#{suite}_phantom" do - filename = File.expand_path('tmp/mspec_phantom.rb') - runner = "#{__dir__}/testing/phantomjs1-sprockets.js" + desc "Run the MSpec/#{suite} test suite on Opal::Sprockets/phantomjs" + pattern_usage + task :"mspec_#{suite}_sprockets_phantomjs" do + filename = File.expand_path('tmp/mspec_sprockets_phantomjs.rb') + runner = "#{__dir__}/testing/sprockets-phantomjs.js" port = 9999 url = "http://localhost:#{port}/" mkdir_p File.dirname(filename) Testing.write_file filename, Testing.specs(ENV.to_hash.merge 'SUITE' => suite) Testing.stubs.each {|s| ::Opal::Processor.stub_file s } Opal::Config.arity_check_enabled = true - Opal::Config.freezing_stubs_enabled = false + Opal::Config.freezing_stubs_enabled = true Opal::Config.tainting_stubs_enabled = false Opal::Config.dynamic_require_severity = :error Opal.use_gem 'mspec' Opal.append_path 'spec' @@ -132,33 +135,37 @@ ensure server.kill if server.alive? end end - desc "Run the MSpec test suite on Node.js" + pattern_usage - task :"mspec_#{suite}_node" do - include_paths = '-Ispec -Ilib' + %w[nodejs phantomjs].each do |platform| + desc "Run the MSpec test suite on Opal::Builder/#{platform}" + pattern_usage + task :"mspec_#{suite}_#{platform}" do + include_paths = '-Ispec -Ilib' - filename = 'tmp/mspec_node.rb' - js_filename = 'tmp/mspec_node.js' - mkdir_p File.dirname(filename) - bm_filepath = Testing.bm_filepath if ENV['BM'] - Testing.write_file filename, Testing.specs(ENV.to_hash.merge 'SUITE' => suite), bm_filepath + filename = "tmp/mspec_#{platform}.rb" + mkdir_p File.dirname(filename) + bm_filepath = Testing.bm_filepath if ENV['BM'] + Testing.write_file filename, Testing.specs(ENV.to_hash.merge 'SUITE' => suite), bm_filepath - stubs = Testing.stubs.map{|s| "-s#{s}"}.join(' ') + stubs = Testing.stubs.map{|s| "-s#{s}"}.join(' ') - sh "ruby -rbundler/setup -r#{__dir__}/testing/mspec_special_calls "\ - "bin/opal -gmspec #{include_paths} #{stubs} -rnodejs/io -rnodejs/kernel -Dwarning -A #{filename} -c > #{js_filename}" - sh "NODE_PATH=stdlib/nodejs/node_modules node #{js_filename}" + sh "ruby -rbundler/setup -r#{__dir__}/testing/mspec_special_calls "\ + "bin/opal -gmspec #{include_paths} #{stubs} -R#{platform} -Dwarning -A #{filename}" - if bm_filepath - puts "Benchmark results have been written to #{bm_filepath}" - puts "To view the results, run bundle exec rake bench:report" + if bm_filepath + puts "Benchmark results have been written to #{bm_filepath}" + puts "To view the results, run bundle exec rake bench:report" + end end end end +task :mspec_phantomjs => [:mspec_opal_phantomjs, :mspec_rubyspec_phantomjs] +task :mspec_nodejs => [:mspec_opal_nodejs, :mspec_rubyspec_nodejs] +task :mspec_sprockets_phantomjs => [:mspec_opal_sprockets_phantomjs, :mspec_rubyspec_sprockets_phantomjs] + task :jshint do js_filename = 'tmp/jshint.js' mkdir_p 'tmp' if ENV['SUITE'] == 'core' @@ -211,25 +218,13 @@ stubs = "-soptparse -sio/console -stimeout -smutex_m -srubygems -stempfile -smonitor" puts "== Running: #{files.join ", "}" sh "ruby -rbundler/setup "\ - "bin/opal #{include_paths} #{stubs} -rnodejs -ropal-parser -Dwarning -A #{filename} -c > #{js_filename}" + "bin/opal #{include_paths} #{stubs} -ropal/platform -ropal-parser -Dwarning -A #{filename} -c > #{js_filename}" sh "NODE_PATH=stdlib/nodejs/node_modules node #{js_filename}" end -task :mspec => [:mspec_rubyspec_node, :mspec_rubyspec_phantom, :mspec_opal_node, :mspec_opal_phantom] +task :mspec => [:mspec_phantomjs, :mspec_nodejs, :mspec_sprockets_phantomjs] task :minitest => [:cruby_tests] task :test_all => [:rspec, :mspec, :minitest] - -if (current_suite = ENV['SUITE']) - # Legacy tasks, only if ENV['SUITE'] is set - desc "Deprecated: use mspec_rubyspec_phantom or mspec_opal_phantom instead" - task :mspec_phantom => :"mspec_#{current_suite}_phantom" - - desc "Deprecated: use mspec_rubyspec_node or mspec_opal_node instead" - task :mspec_node => :"mspec_#{current_suite}_node" -else - task :mspec_phantom => [:mspec_opal_phantom, :mspec_rubyspec_phantom] - task :mspec_node => [:mspec_opal_node, :mspec_rubyspec_node] -end