tasks/testing.rake in opal-1.3.2 vs tasks/testing.rake in opal-1.4.0.alpha1

- old
+ new

@@ -282,19 +282,27 @@ # (Note: the ruby_specs filters will still apply) bundle exec rake mspec_nodejs PATTERN=spec/ruby/core/module/class_variable*_spec.rb bundle exec rake mspec_nodejs PATTERN=spec/ruby/core/numeric/**_spec.rb DESC -platforms = %w[nodejs server chrome gjs quickjs] +platforms = %w[nodejs opalopal_nodejs server chrome gjs quickjs] +node_platforms = %w[nodejs opalopal_nodejs] mspec_suites = %w[ruby opal] minitest_suites = %w[cruby] +require 'opal/paths' +opalopal_cmdline = "-sreadline -rnodejs -rcorelib/string/unpack -popal/cli_runners/nodejs exe/opal -- #{Opal.paths.map{|i| "-I#{i}"}.join(" ")} --no-source-map " + platforms.each do |platform| mspec_suites.each do |suite| desc "Run the MSpec test suite on Opal::Builder/#{platform}" + pattern_usage task :"mspec_#{suite}_#{platform}" do filename = "tmp/mspec_#{platform}.rb" + if platform.start_with? "opalopal_" + platform = platform.split('_').last + cmdline = opalopal_cmdline + end mkdir_p File.dirname(filename) bm_filepath = Testing::MSpec.bm_filepath if ENV['BM'] specs_env = { 'SUITE' => suite, 'FORMATTER' => platform, # Use the current platform as the default formatter @@ -304,11 +312,11 @@ Testing::MSpec.write_file filename, Testing::MSpec.filters(suite), Testing::MSpec.specs(specs_env), specs_env stubs = Testing::MSpec.stubs.map{|s| "-s#{s}"}.join(' ') sh "ruby -w -rbundler/setup -r#{__dir__}/testing/mspec_special_calls "\ - "exe/opal -Ispec/mspec/lib -Ispec -Ilib #{stubs} -R#{platform} -Dwarning -A --enable-source-location #{filename}" + "exe/opal #{cmdline} -Ispec/mspec/lib -Ispec -Ilib #{stubs} -R#{platform} -Dwarning -A --enable-source-location #{filename}" if bm_filepath puts "Benchmark results have been written to #{bm_filepath}" puts "To view the results, run bundle exec rake bench:report" end @@ -340,50 +348,59 @@ opal/promisev2/test_when.rb ] end Testing::HTTPServer.new.with_server do |session| filename = "tmp/minitest_#{suite}_#{platform}.rb" + if platform.start_with? "opalopal_" + platform = platform.split('_').last + cmdline = opalopal_cmdline + end files.push('nodejs') if platform == 'nodejs' Testing::Minitest.write_file(filename, files, ENV) stubs = "-soptparse -sio/console -stimeout -smutex_m -srubygems -stempfile -smonitor" includes = "-Itest -Ilib -Ivendored-minitest #{includes}" sh "ruby -rbundler/setup "\ - "exe/opal #{includes} #{stubs} -R#{platform} -Dwarning -A --enable-source-location #{filename}" + "exe/opal #{cmdline} #{includes} #{stubs} -R#{platform} -Dwarning -A --enable-source-location #{filename}" end end end end -# The name ends with the platform, which is of course mandated in this case -desc "Run the Node.js Minitest suite on Node.js" -task :minitest_node_nodejs do - platform = 'nodejs' - files = %w[ - nodejs - opal-parser - nodejs/test_dir.rb - nodejs/test_env.rb - nodejs/test_error.rb - nodejs/test_file.rb - nodejs/test_file_encoding.rb - nodejs/test_io.rb - nodejs/test_opal_builder.rb - nodejs/test_string.rb - nodejs/test_await.rb - ] +node_platforms.each do |platform| + # The name ends with the platform, which is of course mandated in this case + desc "Run the Node.js Minitest suite on #{platform}" + task :"minitest_node_#{platform}" do + if platform.start_with? "opalopal_" + platform = platform.split('_').last + cmdline = opalopal_cmdline + end + files = %w[ + nodejs + opal-parser + nodejs/test_dir.rb + nodejs/test_env.rb + nodejs/test_error.rb + nodejs/test_file.rb + nodejs/test_file_encoding.rb + nodejs/test_io.rb + nodejs/test_opal_builder.rb + nodejs/test_string.rb + nodejs/test_await.rb + ] - filename = "tmp/minitest_node_nodejs.rb" - Testing::Minitest.write_file(filename, files, ENV) + filename = "tmp/minitest_node_nodejs.rb" + Testing::Minitest.write_file(filename, files, ENV) - stubs = "-soptparse -sio/console -stimeout -smutex_m -srubygems -stempfile -smonitor" - includes = "-Itest -Ilib -Ivendored-minitest" + stubs = "-soptparse -sio/console -stimeout -smutex_m -srubygems -stempfile -smonitor" + includes = "-Itest -Ilib -Ivendored-minitest" - use_strict_opt = ENV['USE_STRICT'] ? ' --use-strict' : '' - sh "ruby -rbundler/setup "\ - "exe/opal #{includes} #{stubs} -R#{platform} -Dwarning -A --enable-source-location#{use_strict_opt} #{filename}" + use_strict_opt = ENV['USE_STRICT'] ? ' --use-strict' : '' + sh "ruby -rbundler/setup "\ + "exe/opal #{cmdline} #{includes} #{stubs} -R#{platform} -Dwarning -A --enable-source-location#{use_strict_opt} #{filename}" + end end desc 'Run smoke tests with opal-rspec to see if something is broken' task :smoke_test do opal_rspec_dir = File.expand_path('tmp/smoke_test_opal_rspec') @@ -406,16 +423,17 @@ actual_output = File.read(actual_output_path) begin require 'rspec/expectations' extend RSpec::Matchers expect(actual_output.lines[0]).to eq("..\n") - expect(actual_output.lines[1]).to match(%r{^Finished in \d+\.\d+ seconds \(files took \d+\.\d+ seconds to load\)\n$}) - expect(actual_output.lines[2]).to eq("2 examples, 0 failures\n") - expect(actual_output.lines[3]).to eq("\n") - expect(actual_output.lines[4]).to match(%r{Top 2 slowest examples \(\d+\.\d+ seconds, \d+\.\d+% of total time\):\n}) - expect(actual_output.lines[5]).to eq(" Opal::Deprecations defaults to warn\n") - expect(actual_output.lines[6]).to match(%r{ \[1m\d+\.\d+\[0m \[1mseconds\[0m \n}) - expect(actual_output.lines[7]).to eq(" Opal::Deprecations can be set to raise\n") + expect(actual_output.lines[1]).to eq("\n") + expect(actual_output.lines[2]).to match(%r{^Finished in \d+\.\d+ seconds \(files took \d+\.\d+ seconds to load\)\n$}) + expect(actual_output.lines[3]).to eq("2 examples, 0 failures\n") + expect(actual_output.lines[4]).to eq("\n") + expect(actual_output.lines[5]).to match(%r{Top 2 slowest examples \(\d+\.\d+ seconds, \d+\.\d+% of total time\):\n}) + expect(actual_output.lines[6]).to eq(" Opal::Deprecations defaults to warn\n") + expect(actual_output.lines[7]).to match(%r{ \[1m\d+\.\d+\[0m \[1mseconds\[0m \n}) + expect(actual_output.lines[8]).to eq(" Opal::Deprecations can be set to raise\n") rescue RSpec::Expectations::ExpectationNotMetError warn $!.message warn "\n\n== Full output:\n#{actual_output}" exit 1 end