Skip to content

Commit 539cd1a

Browse files
authored
Merge pull request #671 from cs136/staging
Staging (Bugfixes)
2 parents ae552d6 + 22ebd1f commit 539cd1a

File tree

11 files changed

+99
-79
lines changed

11 files changed

+99
-79
lines changed

src/collects/seashell-cli.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
(eprintf "Program passed the test.\n")
8080
(write-outputs stdout stderr #f)
8181
(exit 40)]
82-
[(list pid _ "error" exit-code stderr asan)
82+
[(list pid _ "error" exit-code stderr stdout asan)
8383
(if (= exit-code 134)
8484
(eprintf "Program failed an assertion.~n")
8585
(eprintf "Program crashed at runtime.~n"))

src/collects/seashell/backend/dispatch.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,12 @@
110110
[(and result (list pid test-name (and test-res (or "timeout" "killed" "passed")) stdout stderr))
111111
(send-message connection `#hash((id . -4) (success . #t)
112112
(result . #hash((pid . ,pid) (test_name . ,test-name) (result . ,test-res)))))]
113-
[(list pid test-name "error" exit-code stderr asan-output)
113+
[(list pid test-name "error" exit-code stderr stdout asan-output)
114114
(send-message connection `#hash((id . -4) (success . #t)
115115
(result . #hash((pid . ,pid) (test_name . ,test-name) (result . "error")
116116
(exit_code . ,exit-code)
117117
(stderr . ,(bytes->string/utf-8 stderr #\?))
118+
(stdout . ,(bytes->string/utf-8 stdout #\?))
118119
(asan_output . ,(bytes->string/utf-8 asan-output #\?))))))]
119120
[(list pid test-name "no-expect" stdout stderr asan-output)
120121
(send-message connection `#hash((id . -4) (success . #t)

src/collects/seashell/backend/runner.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
(define expected-lines (regexp-split #rx"\n" expected))
139139
;; hotfix: diff with empty because it's slow
140140
(write (serialize `(,pid ,test-name "failed" ,(list-diff expected-lines '()) ,stderr ,stdout ,asan-output)) out-stdout)])]
141-
[_ (write (serialize `(,pid ,test-name "error" ,(subprocess-status handle) ,stderr ,asan-output)) out-stdout)])
141+
[_ (write (serialize `(,pid ,test-name "error" ,(subprocess-status handle) ,stderr ,stdout ,asan-output)) out-stdout)])
142142
(logf 'debug "Done sending test results for program PID ~a." pid)
143143
(close)]
144144
[#f ;; Program timed out ('program-run-timeout seconds pass without any event)

src/frontend/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ html_compile(${CMAKE_CURRENT_SOURCE_DIR}/index.html)
8181
find_program(JS_LINTER jshint)
8282
if (JS_LINTER)
8383
message("JavaScript linter found: ${JS_LINTER}")
84-
add_custom_target(_lint ALL COMMAND ${JS_LINTER} --exclude "'js/lib/*'" . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
84+
# add_custom_target(_lint ALL COMMAND ${JS_LINTER} --exclude "'(js/lib|dist|node_modules)/*'" . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
8585
endif (JS_LINTER)
8686

8787
# Files to install.

src/frontend/frontend/console.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ angular.module('frontend-app')
203203
} else if(res.result==="error") {
204204
self.write('----------------------------------\n');
205205
self.write(sprintf("Test \"%s\" caused an error (with return code %d)!\n", res.test_name, res.exit_code));
206+
self.write('Produced output (stdout):\n');
207+
self.write(res.stdout);
208+
self.write('---\n');
206209
self.write('Produced output (stderr):\n');
207210
self.write(res.stderr);
208211
if(parsedASAN.raw_message !== "") {

src/frontend/frontend/css/common.css

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,32 @@
1414
body {
1515
position: relative; /* For scrollyspy */
1616
padding-top: 15px;
17+
height: 100vh;
1718
}
1819

1920
.container-fluid {
20-
padding-left: 5em;
21-
padding-right: 5em;
21+
padding-left: 30px;
22+
padding-right: 30px;
2223
}
24+
25+
#console-editor-container {
26+
padding: 0;
27+
margin: 10px 0px 10px 0px;
28+
}
29+
30+
@media (max-width: 1440px) {
31+
32+
#console-editor-container {
33+
padding: 0;
34+
margin: 10px -15px 0 -15px;
35+
}
36+
.container-fluid {
37+
padding-left: 15px;
38+
padding-right: 15px;
39+
}
40+
41+
}
42+
2343
.row {
2444
padding: 2px;
2545
}
@@ -76,9 +96,22 @@ body {
7696
}
7797

7898
#editor > .CodeMirror {
79-
height: 300px;
99+
height: calc(80vh + 4px);
100+
border: 1px solid;
101+
border-top: none;
102+
}
103+
104+
#console > .CodeMirror {
105+
height: 80vh;
80106
border: 1px solid;
81107
border-top: none;
108+
border-bottom: none;
109+
clear: both;
110+
}
111+
112+
#editor.console-narrow .CodeMirror,
113+
#console.console-narrow .CodeMirror {
114+
height: 66vh;
82115
}
83116

84117
#editor-controls > button {
@@ -261,6 +294,7 @@ div.tooltip .tooltip-inner {
261294
}
262295

263296
.question-link {
297+
margin-left: 1em;
264298
}
265299

266300
.question-link:hover, .question-link-active:hover {
@@ -288,8 +322,11 @@ div.tooltip .tooltip-inner {
288322
font-weight: 300;
289323
}
290324

291-
.questions-row-container {
292-
text-align: right;
325+
#questions-row-container {
326+
float: right;
327+
font-size: 18px;
328+
margin-top: 5px;
329+
padding: 0;
293330
}
294331

295332
#project-list table {
@@ -347,13 +384,6 @@ div.tooltip .tooltip-inner {
347384
border-top: none;
348385
}
349386

350-
#console > .CodeMirror {
351-
height: 299px;
352-
border: 1px solid;
353-
border-top: none;
354-
border-bottom: none;
355-
clear: both;
356-
}
357387

358388
#console > .CodeMirror .CodeMirror-lines {
359389
padding-bottom: 0;

src/frontend/frontend/errors.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@ angular.module('frontend-app')
4242
if (error) {
4343
console.error(error);
4444
self.errors.push({shorthand: shorthand, error: error, type: type});
45-
$timeout(function() {$rootScope.$broadcast('window-resized');}, 0);
4645
}
4746
};
4847

4948
// close the error message
5049
self.suppress = function (index) {
5150
self.errors.splice(index, 1);
52-
$timeout(function() {$rootScope.$broadcast('window-resized');}, 0);
5351
};
5452

5553
// returns a pretty string of self.logs

src/frontend/frontend/file.js

Lines changed: 44 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -101,52 +101,25 @@ angular.module('frontend-app')
101101
fn();
102102
}
103103
}
104+
104105
$scope.$on('run-when-saved', function (evt, fn) {
105106
runWhenSaved(fn);
106107
});
107-
self.activateResize = function(){
108+
109+
self.onResize = function() {
108110
settings.settings.force_narrow = !(settings.settings.force_narrow);
109111
settings.save();
110112
};
111-
// Resize on window size change
112-
function onResize() {
113-
var narrow = (settings.settings.force_narrow || $window.innerWidth < 992);
114-
var min_height = 500, margin_bottom = 30;
115-
var editor_elem = $window.document.querySelector("#editor > .CodeMirror");
116-
var console_elem = $window.document.querySelector("#console > .CodeMirror");
117-
// Run only when DOM is ready.
118-
if (editor_elem && console_elem) {
119-
var target_height = Math.max($window.innerHeight - editor_elem.getBoundingClientRect().top - margin_bottom, min_height);
120-
var file_control_height = $window.document.querySelector('#current-file-controls').offsetHeight;
121-
var console_input_height = $window.document.querySelector('#console-input').offsetHeight;
122-
if (editor_elem)
123-
editor_elem.style.height = sprintf("%fpx",
124-
(narrow ? target_height * 0.7 : target_height) - file_control_height);
125-
if (console_elem)
126-
console_elem.style.height = sprintf("%fpx",
127-
(narrow ? (target_height * 0.3 - file_control_height) : target_height) - console_input_height);
128-
if(self.editor)
129-
self.editor.refresh();
130-
if(self.consoleEditor)
131-
self.consoleEditor.refresh();
132-
// Force the font size at any rate (and font name)
133-
_.each($window.document.querySelectorAll('.CodeMirror'),
134-
function (elem) {
135-
elem.style['font-family'] = sprintf("%s, monospace", settings.settings.font);
136-
elem.style['font-size'] = sprintf("%dpt", parseInt(settings.settings.font_size));
137-
});
138-
}
139-
}
140-
$scope.$on('window-resized', onResize);
113+
141114
// Scope helper function follow.
142115
self.consoleLoad = function(console_cm) {
143116
self.consoleEditor = console_cm;
144117
self.consoleEditor.on("change", function() {
145118
var scr = self.consoleEditor.getScrollInfo();
146119
self.consoleEditor.scrollTo(scr.left, scr.height);
147120
});
148-
$timeout(onResize, 0);
149121
};
122+
150123
self.editorLoad = function(editor) {
151124
self.editor = editor;
152125
if (self.ext === "c" || self.ext === "h") {
@@ -248,51 +221,69 @@ angular.module('frontend-app')
248221
self.editor.on("cursorActivity", updateColNums);
249222
self.editor.on("focus", updateColNums);
250223
self.editor.on("blur", updateColNums);
251-
$timeout(onResize, 0);
252224
};
225+
253226
function betterTab(){
254227
if(self.editor.somethingSelected()){
255228
self.editor.indentSelection("add");
256229
} else {
257230
self.editor.replaceSelection(Array(self.editor.getOption("indentUnit") + 1).join(" "), "end", "+input");
258231
}
259232
}
233+
260234
function negTab(){
261235
if(self.editor.somethingSelected()){
262236
self.editor.indentSelection("subtract");
263237
}
264238
}
239+
265240
function toggleEditorFullscreen(evt) {
266241
evt.preventDefault();
267242
self.consoleEditor.setOption('fullScreen', false);
268243
self.editor.focus();
269244
self.editor.setOption('fullScreen', !self.editor.getOption('fullScreen'));
270245
}
246+
271247
function toggleConsoleFullscreen(evt) {
272248
evt.preventDefault();
273249
self.editor.setOption('fullScreen', false);
274250
self.consoleEditor.focus();
275251
self.consoleEditor.setOption('fullScreen', !self.consoleEditor.getOption('fullScreen'));
276252
}
253+
277254
function quitFullscreen(evt) {
278255
evt.preventDefault();
279256
self.editor.setOption('fullScreen', false);
280257
self.consoleEditor.setOption('fullScreen', false);
281258
}
259+
282260
function increaseFontSize(evt) {
283261
evt.preventDefault();
284-
settings.settings.font_size = Math.min(settings.settings.font_size + 2, 100);
262+
settings.settings.font_size = Math.min(settings.settings.font_size + 1, 50);
285263
settings.save();
286264
}
265+
287266
function decreaseFontSize(evt) {
288267
evt.preventDefault();
289-
settings.settings.font_size = Math.max(settings.settings.font_size - 2, 2);
268+
settings.settings.font_size = Math.max(settings.settings.font_size - 1, 1);
290269
settings.save();
291270
}
271+
292272
self.refreshSettings = function () {
293273
// var theme = settings.settings.theme_style === "light" ? "3024-day" : "3024-night";
294274
var theme = settings.settings.theme_style === "light" ? "default" : "3024-night";
295275
self.editorReadOnly = !self.ready || self.isBinaryFile || self.fileReadOnly;
276+
277+
var extraKeys = {
278+
"Ctrl-Space": "autocomplete",
279+
"Ctrl-I": self.indentAll,
280+
// capture save shortcuts and ignore in the editor
281+
"Ctrl-S": function() { },
282+
"Cmd-S": function() { },
283+
"Tab": betterTab,
284+
"Shift-Tab": negTab,
285+
};
286+
296287
self.editorOptions = {
297288
scrollbarStyle: "overlay",
298289
autofocus: true,
@@ -306,26 +297,19 @@ angular.module('frontend-app')
306297
onLoad: self.editorLoad,
307298
matchBrackets: true,
308299
rulers: [80],
309-
extraKeys: {
310-
"Ctrl-Space": "autocomplete",
311-
"Ctrl-I": self.indentAll,
312-
// capture save shortcuts and ignore in the editor
313-
"Ctrl-S": function() { },
314-
"Cmd-S": function() { },
315-
"Tab": betterTab,
316-
"Shift-Tab": negTab,
317-
}
300+
extraKeys: extraKeys
318301
};
302+
319303
self.consoleOptions = {
320304
scrollbarStyle: "overlay",
321305
lineWrapping: true,
322306
readOnly: true,
323307
mode: "text/plain",
324308
theme: theme,
325309
onLoad: self.consoleLoad,
326-
extraKeys: {
327-
},
310+
extraKeys: extraKeys
328311
};
312+
329313
var main_hotkeys = [{
330314
combo: 'ctrl+d',
331315
description: 'Sends EOF',
@@ -368,6 +352,7 @@ angular.module('frontend-app')
368352
allowIn: ['INPUT', 'SELECT', 'TEXTAREA'],
369353
callback: quitFullscreen
370354
}];
355+
371356
var vim_disabled_hotkeys = [{
372357
combo: 'ctrl+r',
373358
description: "Runs the program",
@@ -420,17 +405,25 @@ angular.module('frontend-app')
420405
for (var key in self.editorOptions) {
421406
self.editor.setOption(key, self.editorOptions[key]);
422407
}
408+
$("#editor .CodeMirror *").css({
409+
fontFamily: sprintf("%s, monospace", settings.settings.font),
410+
fontSize: sprintf("%dpt", parseInt(settings.settings.font_size))
411+
});
423412
self.editor.addKeyMap({'Tab': betterTab});
424413
self.editor.refresh();
425414
}
426415
if (self.consoleEditor) {
427416
for (var cKey in self.consoleOptions) {
428417
self.consoleEditor.setOption(cKey, self.consoleOptions[cKey]);
429418
}
419+
$("#console .CodeMirror *").css({
420+
fontFamily: sprintf("%s, monospace", settings.settings.font),
421+
fontSize: sprintf("%dpt", parseInt(settings.settings.font_size))
422+
});
430423
self.consoleEditor.refresh();
431424
}
432-
onResize();
433425
};
426+
434427
self.renameFile = function() {
435428
renameModal(self.project, self.question, self.folder, self.file, function(newName) {
436429
var path = newName.split("/");
@@ -441,7 +434,8 @@ angular.module('frontend-app')
441434
file:escape(path.length>2?path[2]:path[1])});
442435
});
443436
};
444-
self.copyFile = function() {
437+
438+
self.copyFile = function() {
445439
copyModal(self.project, self.question, self.folder, self.file, function(newName) {
446440
var path = newName.split("/");
447441
$scope.$parent.editView.refresh();
@@ -451,6 +445,7 @@ angular.module('frontend-app')
451445
file:escape(path.length>2?path[2]:path[1])});
452446
});
453447
};
448+
454449
self.deleteFile = function() {
455450
confirmModal("Delete File", "Are you sure you want to delete '"+self.file+"'?")
456451
.then(function() {
@@ -633,7 +628,7 @@ angular.module('frontend-app')
633628
};
634629

635630
// Initialization code goes here.
636-
var settings_key = settings.addWatcher(function () {self.refreshSettings();}, true);
631+
var settings_key = settings.addWatcher(self.refreshSettings, true);
637632
$scope.$on("$destroy", function() {
638633
if (self.timeout && self.ready) {
639634
$timeout.cancel(self.timeout);

src/frontend/frontend/frontend.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,4 @@ angular.module('frontend-app', ['seashell-websocket', 'seashell-projects', 'ngCo
170170
errors.report(error, 'Could not load settings!');
171171
});
172172
});
173-
// Set up resize
174-
$window.onresize = function () {
175-
$rootScope.$broadcast('window-resized');
176-
};
177173
}]);

0 commit comments

Comments
 (0)