forked from bitovi/funcunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.js
107 lines (95 loc) · 2.56 KB
/
loader.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// This code is always run ...
steal.then(function(){
if (typeof FuncUnit == 'undefined') {
FuncUnit = {};
}
// these are the
steal.extend(FuncUnit,{
testStart: function(name){
print("--" + name + "--")
},
log: function(result, message){
if (!message)
message = ""
print((result ? " PASS " : " FAIL ") + message)
},
testDone: function(name, failures, total){
print(" done - fail " + failures + ", pass " + total + "\n")
},
moduleStart: function(name){
print("MODULE " + name + "\n")
},
moduleDone: function(name, failures, total){
},
browserStart : function(name){
print("BROWSER " + name + " ===== \n")
},
browserDone : function(name, failures, total){
print("\n"+name+" DONE " + failures + ", " + total + (FuncUnit.showTimestamps? (' - '
+ formattedtime + ' seconds'): ""))
},
done: function(failures, total){
print("\nALL DONE - fail " + failures + ", pass " + total)
}
});
/**
* Loads the FuncUnit page in EnvJS. This loads FuncUnit, but we probably want settings
* on it already ....
*
* 2 ways to include settings.js:
* 1. Manually before funcunit.js
* 2. FuncUnit.load will try to load settings.js if there hasn't been one loaded
*/
FuncUnit.load = function(page){
//clear out steal ... you are done with it...
var extend = steal.extend;
steal = undefined;
load('steal/rhino/env.js');
if (!navigator.userAgent.match(/Rhino/)){
return;
}
var dirArr = page.split("/"),
dir = dirArr.slice(0, dirArr.length - 1).join("/"),
settingsPath = dir + "/settings.js";
// if settings.js was already loaded, don't try to load it again
if (FuncUnit.browsers === undefined) {
//this gets the global object, even in rhino
var window = (function(){return this}).call(null),
backupFunc = window.FuncUnit;
if(readFile('funcunit/settings.js')){
load('funcunit/settings.js')
}
// try to load a local settings
var foundSettings = false;
if(/^http/.test(settingsPath)){
try {
readUrl(settingsPath)
foundSettings = true;
}
catch (e) {}
}else{
if(readFile(settingsPath)){
foundSettings = true;
}
}
if (foundSettings) {
print("Reading Settings From "+settingsPath)
load(settingsPath)
}else{
print("Using Default Settings")
}
extend(FuncUnit, backupFunc)
}
Envjs(page, {
scriptTypes: {
"text/javascript": true,
"text/envjs": true,
"": true
},
fireLoad: true,
logLevel: 2,
dontPrintUserAgent: true,
exitOnError : FuncUnit.exitOnError
});
}
})