This repository has been archived by the owner on Jun 10, 2018. It is now read-only.
forked from rails/execjs
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Rakefile
66 lines (55 loc) · 1.4 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require "rake/testtask"
task :default => :test
$:.unshift File.expand_path("../lib", __FILE__)
require "execjs/runtimes"
tests = namespace :test do |tests|
ExecJS::Runtimes.names.each do |name|
next if ExecJS::Runtimes.const_get(name).deprecated?
task(name.downcase) do
ENV["EXECJS_RUNTIME"] = name.to_s
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 SignalException => e
if e.message == "2"
skipped << task.name
else
failed << task.name
end
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
messages = ["PASSED: #{passed.join(", ")}"]
messages << "SKIPPED: #{skipped.join(", ")}" if skipped.any?
messages << "FAILED: #{failed.join(", ")}" if failed.any?
banner messages.join("\n")
raise "test failures" if failed.any?
raise "all tests skipped" if !passed.any?
end