-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathtest.rb
80 lines (69 loc) · 2.22 KB
/
test.rb
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
require 'rubygems'
RUNNER_DIR = Dir.pwd.gsub(/\/tests$/,"") + "/"
def execute(cmd)
`#{cmd}`
end
def runBg(cmd, linestomatch, genre, test_strings)
pid = Process.fork {
counter = 0
matched_counter = 0
IO.popen(cmd) {|io|
io.each {|line|
if line.match(/ran for/)
counter += 1
puts "[#{genre.upcase}] : " + line
test_strings.each do |test_string|
matched_counter += 1 if line.match(/#{test_string}/)
end
end
if counter >= linestomatch
if matched_counter != counter
puts "\n####\n#{genre.upcase} FAILED\n####\n"
end
execute("ps -ef | grep #{io.pid} | grep -v grep | awk '{print $2}' | xargs kill -9")
end
}
}
}
pid
end
class Test
def run_project(reponame, test_framework, passed_array, browser_url)
repo_path = "#{RUNNER_DIR}tests/external-repos/"
conf_path = "#{RUNNER_DIR}tests/conf/"
execute("cd #{repo_path}#{reponame} && npm install")
execute("cd #{repo_path}#{reponame} && cp #{conf_path}#{reponame}.json #{repo_path}#{reponame}/browserstack.json")
pid = runBg("cd #{repo_path}#{reponame} && ../../../bin/cli.js", 1, "#{test_framework}-#{reponame}", passed_array)
sleep(1)
execute("open http://localhost:8888/#{browser_url}")
Process.wait(pid)
sleep(1)
execute("cd #{repo_path}#{reponame} && git clean -f -d && git reset --hard")
end
def qunit
run_project("underscorejs", "qunit", ["631 passed"], "test/index.html")
run_project("Modernizr", "qunit", ["20 passed"], "test/index.html")
# https://github.com/bitovi/funcunit/
# https://github.com/twbs/bootstrap
end
def mocha
run_project("url.js", "mocha", ["35 passed"], "test.html")
# https://github.com/browserstack/microjungle
# https://github.com/dhimil/mocha
# https://github.com/auth0/auth0.js
end
def jasmine
run_project("mout", "jasmine", ["978 passed"], "tests/runner.html")
end
def jasmine2
run_project("Comparatorsjs", "jasmine2", ["6 passed"], "comparators.spec-runner.html")
end
def run
execute("cd #{RUNNER_DIR} && git submodule init && git submodule update")
qunit
mocha
jasmine
jasmine2
end
end
Test.new.run