forked from sinonjs/sinon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
step-tests
executable file
·49 lines (42 loc) · 1.09 KB
/
step-tests
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
#!/usr/bin/env ruby
#
# Sometimes massive failure can cause JsTestDriver to hang
# To debug those cases, it's easier to run test cases one by one
# to track which test case is causing trouble.
#
# This script also helps test less capable browsers such as IE6,
# which can get overwhelmed while trying to run too many tests too
# rapidly.
#
def red(msg)
"\033[31m#{msg}\033[39m"
end
def green(msg)
"\033[32m#{msg}\033[39m"
end
def ok
green("OK")
end
problems = []
server = ARGV.length > 0 ? " --server #{ARGV[0]}" : ""
print "Resetting"
`jstestdriver --reset#{server}`
print " - #{ok}\n"
(Dir.glob("test/**/*.js").collect do |test|
File.read(test).scan(/estCase\("(.+)"/)
end).flatten.each do |testCase|
print testCase
`jstestdriver --tests #{testCase}#{server}` =~ /Fails: (\d+); Errors: (\d+)/
if $1.to_i > 0 || $2.to_i > 0
problems << testCase
print " - " + red("#{$1} failures, #{$2} errors") + "\n"
else
print " - #{ok}\n"
end
end
if problems.count > 0
puts red("Some test cases had failures and/or errors")
puts problems.join("\n")
else
puts green("No problems")
end