lib/mspec/opal/rake_task.rb in opal-0.6.3 vs lib/mspec/opal/rake_task.rb in opal-0.7.0.beta1
- old
+ new
@@ -9,24 +9,27 @@
if File.exist?(target)
compiler.requires << target
end
- return fragment("nil")
+ push fragment("nil")
end
+ end
- nil
+ add_special :not_supported_on do
+ unless meth == :not_supported_on and arglist[1][1] == :opal
+ compile_default!
+ end
end
end
require 'rack'
require 'webrick'
module MSpec
module Opal
- DEFAULT_PATTERN = 'spec/{corelib,opal,stdlib}/**/*_spec.rb'
DEFAULT_BASEDIR = 'spec'
require 'rake'
require 'rake/tasklib'
class RakeTask < ::Rake::TaskLib
@@ -117,22 +120,25 @@
class Environment < ::Opal::Environment
attr_reader :basedir, :pattern
def initialize(basedir = nil, pattern = nil)
::Opal::Processor.arity_check_enabled = true
- ::Opal::Processor.dynamic_require_severity = :ignore
- super()
+ ::Opal::Processor.dynamic_require_severity = :error
+
@pattern = pattern
@basedir = basedir = File.expand_path(basedir || DEFAULT_BASEDIR)
- append_path basedir
- use_gem 'mspec'
+ ::Opal.append_path basedir
+ ::Opal.use_gem 'mspec'
+
stubs.each do |asset|
::Opal::Processor.stub_file asset
end
ENV['OPAL_SPEC'] ||= files_to_run(pattern).join(',')
+
+ super()
end
def stubs
# missing stdlib
stubs = %w[fileutils iconv yaml]
@@ -157,29 +163,27 @@
def files
@files ||= []
end
- def add_files specs
- puts "Adding #{specs.size} spec files..."
- files.concat specs.flatten
- end
-
- def paths_from_glob pattern
- Dir.glob(File.expand_path(pattern)).map do |s|
- s.sub(/^#{basedir}\//, '').sub(/\.rb$/, '')
- end
- end
-
- def rubyspec_paths
- rubyspec_white_list.map do |path|
+ def add_files specs, tag = ''
+ tag = "[#{tag}] "
+ puts "#{tag}Adding #{specs.size} spec files..."
+ specs = specs.flatten.map do |path|
dirname = File.join([basedir, path])
if File.directory? dirname
rubyspec_paths_in_dir(dirname, path)
else
path
end
+ end.flatten
+ files.concat specs
+ end
+
+ def paths_from_glob pattern
+ Dir.glob(File.expand_path(pattern)).map do |s|
+ s.sub(/^#{basedir}\//, '').sub(/\.rb$/, '')
end
end
def rubyspec_paths_in_dir(dirname, path)
Dir.entries(dirname).select do |spec|
@@ -195,22 +199,24 @@
end
end
def files_to_run(pattern=nil)
# add any filters in spec/filters of specs we dont want to run
- add_files paths_from_glob("#{basedir}/filters/**/*.rb")
+ add_files paths_from_glob("#{basedir}/filters/**/*.rb"), :filters
if pattern
# add custom opal specs from spec/
- add_files paths_from_glob(pattern) & rubyspec_paths
+ add_files paths_from_glob(pattern) & rubyspec_white_list, :rubyspec_custom_pattern
+ add_files paths_from_glob(pattern).grep(/(?!spec\/(corelib|stdlib)\/)/), :other_custom_pattern
else
# add opal specific specs
- add_files paths_from_glob("#{basedir}/{opal}/**/*_spec.rb")
+ add_files paths_from_glob("#{basedir}/opal/**/*_spec.rb"), 'opal/*'
+ add_files paths_from_glob("#{basedir}/lib/{lexer_spec.rb,parser/**/*_spec.rb}"), 'lib/{lexer,parser}'
# add any rubyspecs we want to run (defined in spec/rubyspecs)
- add_files rubyspec_paths
+ add_files rubyspec_white_list, :rubyspec_white_list
end
end
def build_specs file = "#{basedir}/build/specs.js"
code = specs.to_s
@@ -244,9 +250,10 @@
class Index
HTML = <<-HTML
<!DOCTYPE html>
<html>
<head>
+ <meta charset="UTF-8" />
<title>Opal Specs</title>
</head>
<body>
<script src="/mspec/opal/main.js"></script>
</body>