2011-02-06 15:22:40 -05:00
|
|
|
require "rake/testtask"
|
|
|
|
|
|
|
|
task :default => :test
|
|
|
|
|
2011-06-01 11:49:54 -04:00
|
|
|
$:.unshift File.expand_path("../lib", __FILE__)
|
|
|
|
require "execjs/runtimes"
|
|
|
|
|
|
|
|
tests = namespace :test do |tests|
|
|
|
|
ExecJS::Runtimes.names.each do |name|
|
2012-05-15 10:16:57 -04:00
|
|
|
next if (name == :Disabled || name == "Disabled")
|
2012-04-26 17:35:01 -04:00
|
|
|
|
2011-06-01 11:49:54 -04:00
|
|
|
task(name.downcase) do
|
2011-06-01 22:29:05 -04:00
|
|
|
ENV["EXECJS_RUNTIME"] = name.to_s
|
2011-06-01 11:49:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
Rake::TestTask.new(name.downcase) do |t|
|
|
|
|
t.libs << "test"
|
|
|
|
t.warning = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def banner(text)
|
|
|
|
warn ""
|
|
|
|
warn "=" * Rake.application.terminal_width
|
|
|
|
warn text
|
|
|
|
warn "=" * Rake.application.terminal_width
|
|
|
|
warn ""
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Run tests for all installed runtimes"
|
|
|
|
task :test do
|
|
|
|
passed = []
|
|
|
|
failed = []
|
|
|
|
skipped = []
|
|
|
|
|
|
|
|
tests.tasks.each do |task|
|
|
|
|
banner "Running #{task.name}"
|
|
|
|
|
|
|
|
begin
|
|
|
|
task.invoke
|
|
|
|
rescue Exception => e
|
|
|
|
if e.message[/Command failed with status \((\d+)\)/, 1] == "2"
|
|
|
|
skipped << task.name
|
|
|
|
else
|
|
|
|
failed << task.name
|
|
|
|
end
|
|
|
|
else
|
|
|
|
passed << task.name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-06-01 22:29:15 -04:00
|
|
|
messages = ["PASSED: #{passed.join(", ")}"]
|
2011-06-01 11:49:54 -04:00
|
|
|
messages << "SKIPPED: #{skipped.join(", ")}" if skipped.any?
|
2011-06-01 22:29:15 -04:00
|
|
|
messages << "FAILED: #{failed.join(", ")}" if failed.any?
|
2011-06-01 11:49:54 -04:00
|
|
|
banner messages.join("\n")
|
|
|
|
|
|
|
|
raise "test failures" if failed.any?
|
2012-05-17 07:42:26 -04:00
|
|
|
raise "all tests skipped" if !passed.any?
|
2011-02-06 15:22:40 -05:00
|
|
|
end
|