-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_runner.html
130 lines (102 loc) · 3.48 KB
/
test_runner.html
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html>
<head>
<title>JSIL Test Runner</title>
<style>
body, button, input {
font-family: Calibri, Tahoma, Verdana, sans-serif;
font-size: 14pt;
}
label {
font-weight: bold;
display: inline-block;
width: 10em;
}
input[type="text"] {
width: 20em;
}
button {
width: 10em;
}
</style>
</head>
<body onload="onLoadFixture();">
<script>
var jsilConfig = {
libraryRoot: "Libraries/"
};
</script>
<script src="Libraries/JSIL.js" type="text/javascript"></script>
<label for="scriptname">Test Script To Run:</label> <input type="text" name="scriptname" id="scriptname" value="Tests/SimpleTestCases/If.js"></input><br>
<button id="runscript" name="runscript">Run</button>
<hr>
<h3>Log</h3>
<div id="log">
</div>
<script type="text/javascript">
var _started = Date.now();
function print (text) {
console.log(text);
}
function timeout (t) {
// no-op
}
function elapsed (t) {
return Date.now() - _started;
}
function runScript () {
document.getElementById("runscript").disabled = true;
var scriptname = document.getElementById("scriptname").value;
window.location.hash = "#" + scriptname;
contentManifest["TestRunner"] = [
["Script", scriptname]
];
onLoad();
}
function runMain () {
JSIL.Host.logWriteLine("// Test output begins here //");
var elapsed = runTestCase(function () { }, Date.now);
JSIL.Host.logWriteLine("// Test output ends here //");
JSIL.Host.logWriteLine("// Test completed in " + (elapsed / 1000) + " second(s)");
}
var lastHash = null;
function checkHash () {
var currentHash = null;
if ((typeof (window.location.hash) === "string") && (window.location.hash.length > 1)) {
currentHash = window.location.hash.substr(1);
}
if (currentHash !== lastHash) {
lastHash = currentHash;
document.getElementById("scriptname").value = currentHash;
}
}
function onLoadFixture () {
var button = document.getElementById("runscript");
checkHash();
setInterval(checkHash, 100);
button.removeAttribute("disabled");
button.addEventListener("click", runScript, true);
}
// UGH
JSIL.Shell = {};
JSIL.Shell.TestPrologue = function (timeoutDuration, assemblyName, typeName, methodName, args) {
return function runTestCase () {
JSIL.ThrowOnUnimplementedExternals = true;
var started = Date.now();
var testAssembly = JSIL.GetAssembly(assemblyName, true);
if (!testAssembly)
throw new Error("No assembly named '" + assemblyName + "'");
var parsedTypeName = JSIL.ParseTypeName(typeName);
var testType = JSIL.GetTypeInternal(parsedTypeName, testAssembly, true);
var testTypePublicInterface = testType.__PublicInterface__;
var testMethod = testTypePublicInterface[methodName];
if (!testMethod)
throw new Error("No method named '" + methodName + "'");
testMethod.call(testTypePublicInterface, args);
var ended = Date.now();
return (ended - started);
};
};
</script>
</body>
</html>