This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
qunit.js
89 lines (82 loc) · 2.26 KB
/
qunit.js
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
81
82
83
84
85
86
87
88
89
/* We want to be able to look in different places! */
var inc = new Array();
init_inc(inc);
safe_load("qunit.js");
safe_load("qunit-tap.js");
QUnit.init();
QUnit.config.blocking = false;
QUnit.config.autorun = true;
QUnit.config.updateRate = 0;
function plan(n) {
print("1.." + n);
}
function diag(msg) {
print("# " + msg);
}
function bootstrap(file) {
safe_load("env.rhino.js");
Envjs({
log: function(string) {
diag(string);
},
scriptTypes: {
'': true,
'text/javascript': true,
},
});
window.location = file;
}
function init_inc(inc) {
// What do we have here?
var cp = environment['java.class.path'];
// java.class.path: /Users/andremar/Projects/js/rhino/js.jar
if (cp.match('/usr/local/share/rhino')) {
// XXX: I hate hardcoding these, but blah!
inc.push('/usr/local/share/startsiden-javascript-qunit');
inc.push('/usr/local/share/startsiden-javascript-envjs');
}
var paths = getinc();
for (i in paths) {
inc.push(paths[i]);
}
}
function safe_load(lib) {
var found = 0;
for (dir in inc) {
// Need to check if our lib exists here
// XXX: Not working on windows with the whole / biz
dir = inc[dir];
if (!dir.match(environment['file.separator'] + "$")) {
dir = dir + environment['file.separator'];
}
var file = dir + lib;
if (!runCommand("test", "-f", file)) {
found++;
load(file);
// XXX: SHould exit loop here
}
}
if (found == 0) {
print("Could not find " + lib + " in our INC(" + inc.join(":") + ")");
} else if (found > 1) {
print("We found more than one version of "
+ lib + " in our INC(" + inc.join(":") + ")");
}
}
function getinc() {
var path = getenv("JSINC");
return path.split(':');
}
function getenv(key) {
var opt = {'output': ''};
// XXX: does not work on windows!
if (environment['os.name'].match('Mac OS X|Linux')) {
runCommand('printenv', key, opt);
print(opt.output);
} else {
print("Unsupported os.name: " + environment['os.name']);
quit();
}
var out = opt.output.replace("\n", "");
return out;
}