Skip to content

Commit e0c3861

Browse files
committed
bam
1 parent 467b433 commit e0c3861

1 file changed

Lines changed: 24 additions & 26 deletions

File tree

‎v3/js/opt-testcases.js‎

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -160,32 +160,24 @@ function addTestcase(id) {
160160
s.setMode("ace/mode/" + mod);
161161

162162

163-
$('#runTestCase_' + id).click(function() {
164-
$(this).html("Running ...");
165-
startRunningTest(id);
166-
var dat = getCombinedCode(id);
167-
console.log(dat.cod);
168-
console.log(dat.firstTestLine);
169-
170-
// adapted from executeCode in opt-frontend.js
171-
var backend_script = langToBackendScript($('#pythonVersionSelector').val());
172-
var backendOptionsObj = getBaseBackendOptionsObj();
173-
backendOptionsObj.run_test_case = true; // just so we can see this in server logs
174-
var frontendOptionsObj = getBaseFrontendOptionsObj();
175-
frontendOptionsObj.jumpToEnd = true;
176-
});
163+
function runOrVizTestCase(isViz /* true for visualize, false for run */) {
164+
if (isViz) {
165+
$('#vizTestCase_' + id).html("Visualizing ...");
166+
} else {
167+
$('#runTestCase_' + id).html("Running ...");
168+
}
177169

178-
$('#vizTestCase_' + id).click(function() {
179-
$(this).html("Visualizing ...");
180170
startRunningTest(id);
181171
var dat = getCombinedCode(id);
182-
console.log(dat.cod);
183-
console.log(dat.firstTestLine);
184172

185173
// adapted from executeCode in opt-frontend.js
186174
var backend_script = langToBackendScript($('#pythonVersionSelector').val());
187175
var backendOptionsObj = getBaseBackendOptionsObj();
188-
backendOptionsObj.viz_test_case = true; // just so we can see this in server logs
176+
if (isViz) {
177+
backendOptionsObj.viz_test_case = true; // just so we can see this in server logs
178+
} else {
179+
backendOptionsObj.run_test_case = true; // just so we can see this in server logs
180+
}
189181
var frontendOptionsObj = getBaseFrontendOptionsObj();
190182
frontendOptionsObj.jumpToEnd = true;
191183

@@ -210,14 +202,20 @@ function addTestcase(id) {
210202
doneRunningTest();
211203
}
212204

213-
executeCodeAndCreateViz(dat.cod,
214-
backend_script, backendOptionsObj,
215-
frontendOptionsObj,
216-
'pyOutputPane',
217-
runTestFinishSuccessfulExecution,
218-
runTestHandleUncaughtExceptionFunc);
219-
});
205+
if (isViz) {
206+
executeCodeAndCreateViz(dat.cod,
207+
backend_script, backendOptionsObj,
208+
frontendOptionsObj,
209+
'pyOutputPane',
210+
runTestFinishSuccessfulExecution,
211+
runTestHandleUncaughtExceptionFunc);
212+
} else {
213+
// TODO
214+
}
215+
}
220216

217+
$('#runTestCase_' + id).click(runOrVizTestCase.bind(null, false));
218+
$('#vizTestCase_' + id).click(runOrVizTestCase.bind(null, true));
221219

222220
$('#delTestCase_' + id).click(function() {
223221
var res = confirm("Press OK to delete this test.");

0 commit comments

Comments
 (0)