Skip to content

Commit a8cfbb3

Browse files
committed
test repos and script for qunit, mocha, jasmine
1 parent 8d59e9b commit a8cfbb3

File tree

8 files changed

+148
-0
lines changed

8 files changed

+148
-0
lines changed

.gitmodules

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[submodule "tests/external-repos/underscorejs"]
2+
path = tests/external-repos/underscorejs
3+
url = https://github.com/browserstack/underscore
4+
[submodule "tests/external-repos/Modernizr"]
5+
path = tests/external-repos/Modernizr
6+
url = https://github.com/browserstack/Modernizr
7+
[submodule "tests/external-repos/url.js"]
8+
path = tests/external-repos/url.js
9+
url = https://github.com/browserstack/url.js.git
10+
[submodule "tests/external-repos/mout"]
11+
path = tests/external-repos/mout
12+
url = https://github.com/browserstack/mout

bin/cli.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ function runTests() {
277277
});
278278
});
279279
});
280+
} else {
281+
launchServer();
280282
}
281283
}
282284

lib/_patch/browserstack.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
console.log = function (arguments) {
4343
post('/_log/', arguments, function () {});
4444
};
45+
console.warn = function (arguments) {
46+
post('/_log/', arguments, function () {});
47+
};
4548

4649
BrowserStack.post = post;
4750
BrowserStack.getParameterByName = getParameterByName;

tests/conf/Modernizr.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"username": "NakulAggarwal",
3+
"key": "1FKyBShTNysamxvJBG3UY",
4+
"test_path": "test/index.html",
5+
"debug": true,
6+
"build": "RahulNew",
7+
"browsers": [
8+
]
9+
}

tests/conf/mout.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"username": "NakulAggarwal",
3+
"key": "1FKyBShTNysamxvJBG3UY",
4+
"test_path": "tests/runner.html",
5+
"test_framework": "jasmine",
6+
"debug": true,
7+
"build": "RahulNew",
8+
"browsers": [
9+
]
10+
}

tests/conf/underscorejs.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"username": "NakulAggarwal",
3+
"key": "1FKyBShTNysamxvJBG3UY",
4+
"test_path": "test/index.html",
5+
"debug": true,
6+
"build": "RahulNew",
7+
"browsers": [
8+
]
9+
}

tests/conf/url.js.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"username": "NakulAggarwal",
3+
"key": "1FKyBShTNysamxvJBG3UY",
4+
"test_path": "test.html",
5+
"test_framework": "mocha",
6+
"debug": true,
7+
"build": "RahulNew",
8+
"browsers": [
9+
]
10+
}

tests/test.rb

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
require 'rubygems'
2+
3+
RUNNER_DIR = Dir.pwd.gsub(/\/tests$/,"") + "/"
4+
def execute(cmd)
5+
`#{cmd}`
6+
end
7+
8+
def runBg(cmd, linestomatch, genre, test_strings)
9+
pid = Process.fork {
10+
counter = 0
11+
matched_counter = 0
12+
IO.popen(cmd) {|io|
13+
io.each {|line|
14+
if line.match(/Completed in /)
15+
counter += 1
16+
puts "[#{genre.upcase}] : " + line
17+
test_strings.each do |test_string|
18+
matched_counter += 1 if line.match(/#{test_string}/)
19+
end
20+
end
21+
if counter >= linestomatch
22+
if matched_counter != counter
23+
puts "\n####\n#{genre.upcase} FAILED\n####\n"
24+
end
25+
execute("ps -ef | grep #{io.pid} | grep -v grep | awk '{print $2}' | xargs kill -9")
26+
end
27+
}
28+
}
29+
}
30+
pid
31+
end
32+
33+
class Test
34+
def run_project
35+
end
36+
37+
def qunit
38+
repo_path = "#{RUNNER_DIR}tests/external-repos/"
39+
conf_path = "#{RUNNER_DIR}tests/conf/"
40+
execute("cd #{repo_path}underscorejs && npm install")
41+
execute("cd #{repo_path}underscorejs && cp #{conf_path}underscorejs.json #{repo_path}underscorejs/browserstack.json")
42+
pid = runBg("cd #{repo_path}underscorejs && ../../../bin/cli.js", 1, "qunit-underscorejs", ["631 of 631 passed"])
43+
execute("open http://localhost:8888/test/index.html")
44+
Process.wait(pid)
45+
sleep(1)
46+
47+
execute("cd #{repo_path}Modernizr && npm install")
48+
execute("cd #{repo_path}Modernizr && cp #{conf_path}Modernizr.json #{repo_path}Modernizr/browserstack.json")
49+
pid2 = runBg("cd #{repo_path}Modernizr && ../../../bin/cli.js", 1, "qunit-Modernizr", ["20 of 41 passed"])
50+
execute("open http://localhost:8888/test/index.html")
51+
Process.wait(pid2)
52+
53+
# https://github.com/bitovi/funcunit/
54+
# https://github.com/twbs/bootstrap
55+
end
56+
57+
def mocha
58+
repo_path = "#{RUNNER_DIR}tests/external-repos/"
59+
conf_path = "#{RUNNER_DIR}tests/conf/"
60+
61+
execute("cd #{repo_path}url.js && npm install")
62+
execute("cd #{repo_path}url.js && cp #{conf_path}url.js.json #{repo_path}url.js/browserstack.json")
63+
pid = runBg("cd #{repo_path}url.js && ../../../bin/cli.js", 1, "mocha-urlJs", ["35 of 35 passed"])
64+
execute("open http://localhost:8888/test.html")
65+
Process.wait(pid)
66+
sleep(1)
67+
68+
# https://github.com/browserstack/microjungle
69+
# https://github.com/dhimil/mocha
70+
# https://github.com/auth0/auth0.js
71+
end
72+
73+
def jasmine
74+
repo_path = "#{RUNNER_DIR}tests/external-repos/"
75+
conf_path = "#{RUNNER_DIR}tests/conf/"
76+
77+
execute("cd #{repo_path}mout && npm install")
78+
execute("cd #{repo_path}mout && cp #{conf_path}mout.json #{repo_path}mout/browserstack.json")
79+
pid = runBg("cd #{repo_path}mout && ../../../bin/cli.js", 1, "jasmine-mout", ["978 of 978 passed"])
80+
execute("open http://localhost:8888/tests/runner.html")
81+
Process.wait(pid)
82+
sleep(1)
83+
end
84+
85+
def run
86+
execute("cd #{RUNNER_DIR} && git submodule init && git submodule update")
87+
qunit
88+
mocha
89+
jasmine
90+
end
91+
end
92+
93+
Test.new.run

0 commit comments

Comments
 (0)