tasks/testing.rake in opal-0.9.4 vs tasks/testing.rake in opal-0.10.0.beta1
- old
+ new
@@ -1,7 +1,10 @@
-require_relative './testing/mspec_special_calls'
+# Remove when we drop support for 1.9.3
+__dir__ = defined?(Kernel.__dir__) ? Kernel.__dir__ : File.dirname(File.realpath(__FILE__))
+require "#{__dir__}/testing/mspec_special_calls"
+
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:rspec) do |t|
t.pattern = 'spec/lib/**/*_spec.rb'
end
@@ -22,11 +25,11 @@
suite = env['SUITE']
pattern = env['PATTERN']
whitelist_pattern = !!env['RUBYSPECS']
excepting = []
- rubyspecs = File.read('spec/rubyspecs').lines.reject do |l|
+ rubyspecs = File.read('spec/ruby_specs').lines.reject do |l|
l.strip!
l.start_with?('#') || l.empty? || (l.start_with?('!') && excepting.push(l.sub('!', 'spec/') + '.rb'))
end.flat_map do |path|
path = "spec/#{path}"
File.directory?(path) ? Dir[path+'/*.rb'] : "#{path}.rb"
@@ -35,12 +38,19 @@
opalspecs = Dir['spec/{opal,lib/parser}/**/*_spec.rb'] + ['spec/lib/lexer_spec.rb']
userspecs = Dir[pattern] if pattern
userspecs &= rubyspecs if whitelist_pattern
opalspec_filters = Dir['spec/filters/**/*_opal.rb']
- rubyspec_filters = Dir['spec/filters/**/*.rb'] - opalspec_filters
+ if ENV['INVERT_RUNNING_MODE']
+ # When we run an inverted test suite we should run only 'bugs'.
+ # Unsupported features are not supported anyway
+ rubyspec_filters = Dir['spec/filters/bugs/*.rb'] - opalspec_filters
+ else
+ rubyspec_filters = Dir['spec/filters/**/*.rb'] - opalspec_filters
+ end
+
specs = []
add_specs = ->(name, new_specs) do
puts "Adding #{new_specs.size.to_s.rjust(3)} files (#{name})"
specs += new_specs
end
@@ -51,16 +61,16 @@
if pattern
add_specs["PATTERN=#{pattern}", userspecs]
elsif suite == 'opal'
add_specs['spec/opal', opalspecs]
- elsif suite == 'rubyspec'
- add_specs['spec/rubyspec', rubyspecs]
+ elsif suite == 'ruby'
+ add_specs['spec/ruby', rubyspecs]
else
warn 'Please provide at lease one of the following environment variables:'
- warn 'PATTERN # e.g. PATTERN=spec/rubyspec/core/numeric/**_spec.rb'
- warn 'SUITE # can be either SUITE=opal or SUITE=rubyspec'
+ warn 'PATTERN # e.g. PATTERN=spec/ruby/core/numeric/**_spec.rb'
+ warn 'SUITE # can be either SUITE=opal or SUITE=ruby'
exit 1
end
specs
end
@@ -73,10 +83,11 @@
end
File.write filename, <<-RUBY
require 'spec_helper'
require 'opal/platform'
+ OSpecRunner.main.will_start
#{enter_benchmarking_mode}
#{requires.join("\n ")}
OSpecFilter.main.unused_filters_message(list: #{!!ENV['LIST_UNUSED_FILTERS']})
OSpecRunner.main.did_finish
exit MSpec.exit_code
@@ -96,16 +107,16 @@
pattern_usage = <<-DESC
Use PATTERN environment variable to manually set the glob for specs:
# Will run all specs matching the specified pattern.
- # (Note: the rubyspecs filters will still apply)
- 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
+ # (Note: the ruby_specs filters will still apply)
+ bundle exec rake mspec_node PATTERN=spec/ruby/core/module/class_variable*_spec.rb
+ bundle exec rake mspec_node PATTERN=spec/ruby/core/numeric/**_spec.rb
DESC
-%w[rubyspec opal].each do |suite|
+%w[ruby opal].each do |suite|
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
@@ -158,13 +169,13 @@
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 :mspec_phantomjs => [:mspec_opal_phantomjs, :mspec_ruby_phantomjs]
+task :mspec_nodejs => [:mspec_opal_nodejs, :mspec_ruby_nodejs]
+task :mspec_sprockets_phantomjs => [:mspec_opal_sprockets_phantomjs, :mspec_ruby_sprockets_phantomjs]
task :jshint do
js_filename = 'tmp/jshint.js'
mkdir_p 'tmp'
@@ -195,9 +206,11 @@
test_dir = Pathname("#{__dir__}/../test/cruby/test")
files = %w[
benchmark/test_benchmark.rb
ruby/test_call.rb
opal/test_keyword.rb
+ base64/test_base64.rb
+ opal/unsupported_and_bugs.rb
].flat_map do |path|
if path.end_with?('.rb')
path
else
glob = test_dir.join(path+"/test_*.rb").to_s