mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
eb5fea40a4
In cases where the MatchData object is not used, this provides a speed-up: https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
76 lines
1.6 KiB
Ruby
76 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "rake/testtask"
|
|
require "pathname"
|
|
require "open3"
|
|
require "action_cable"
|
|
|
|
task default: :test
|
|
|
|
task package: %w( assets:compile assets:verify )
|
|
|
|
Rake::TestTask.new do |t|
|
|
t.libs << "test"
|
|
t.test_files = Dir.glob("#{__dir__}/test/**/*_test.rb")
|
|
t.warning = true
|
|
t.verbose = true
|
|
t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION)
|
|
end
|
|
|
|
namespace :test do
|
|
task :isolated do
|
|
Dir.glob("test/**/*_test.rb").all? do |file|
|
|
sh(Gem.ruby, "-w", "-Ilib:test", file)
|
|
end || raise("Failures")
|
|
end
|
|
|
|
task :integration do
|
|
require "blade"
|
|
if ENV["CI"]
|
|
Blade.start(interface: :ci)
|
|
else
|
|
Blade.start(interface: :runner)
|
|
end
|
|
end
|
|
end
|
|
|
|
namespace :assets do
|
|
desc "Compile Action Cable assets"
|
|
task :compile do
|
|
require "blade"
|
|
require "sprockets"
|
|
require "sprockets/export"
|
|
Blade.build
|
|
end
|
|
|
|
desc "Verify compiled Action Cable assets"
|
|
task :verify do
|
|
file = "lib/assets/compiled/action_cable.js"
|
|
pathname = Pathname.new("#{__dir__}/#{file}")
|
|
|
|
print "[verify] #{file} exists "
|
|
if pathname.exist?
|
|
puts "[OK]"
|
|
else
|
|
$stderr.puts "[FAIL]"
|
|
fail
|
|
end
|
|
|
|
print "[verify] #{file} is a UMD module "
|
|
if /module\.exports.*define\.amd/m.match?(pathname.read)
|
|
puts "[OK]"
|
|
else
|
|
$stderr.puts "[FAIL]"
|
|
fail
|
|
end
|
|
|
|
print "[verify] #{__dir__} can be required as a module "
|
|
_, stderr, status = Open3.capture3("node", "--print", "window = {}; require('#{__dir__}');")
|
|
if status.success?
|
|
puts "[OK]"
|
|
else
|
|
$stderr.puts "[FAIL]\n#{stderr}"
|
|
fail
|
|
end
|
|
end
|
|
end
|