diff --git a/src/worker/workermain.js b/src/worker/workermain.js index ed1149d1..71e70e54 100644 --- a/src/worker/workermain.js +++ b/src/worker/workermain.js @@ -338,7 +338,7 @@ function makeErrorMatcher(errors, regex, iline, imsg) { msg:matches[imsg] }); } else { - console.log(s); + console.log("??? "+s); } } } @@ -603,12 +603,13 @@ function linkLD65(step) { var binpath = "main"; if (staleFiles(step, [binpath])) { var errors = []; + var errmsg = ''; var LD65 = ld65({ wasmBinary: wasmBlob['ld65'], noInitialRun:true, //logReadFiles:true, print:print_fn, - printErr:makeErrorMatcher(errors, /[(](\d+)[)]: (.+)/, 1, 2), + printErr:function(s) { errmsg += s + '\n'; } }); var FS = LD65['FS']; var cfgfile = '/' + platform + '.cfg'; @@ -625,6 +626,8 @@ function linkLD65(step) { '-o', 'main', '-m', 'main.map'].concat(step.args, libargs); //console.log(args); execMain(step, LD65, args); + if (errmsg.length) + errors.push({line:0, msg:errmsg}); if (errors.length) return {errors:errors}; var aout = FS.readFile("main", {encoding:'binary'}); diff --git a/test/cli/testworker.js b/test/cli/testworker.js index 12bf951b..020dc27e 100644 --- a/test/cli/testworker.js +++ b/test/cli/testworker.js @@ -85,9 +85,12 @@ describe('Worker', function() { it('should compile CC65', function(done) { compile('cc65', 'int main() {\nint x=1;\nreturn x+2;\n}', 'nes-conio', done, 40976, 3); }); - it('should NOT compile CC65', function(done) { + it('should NOT compile CC65 (compile error)', function(done) { compile('cc65', 'int main() {\nint x=1;\nprintf("%d",x);\nreturn x+2;\n}', 'nes-conio', done, 0, 0, 1); }); + it('should NOT compile CC65 (link error)', function(done) { + compile('cc65', 'extern void bad();\nint main() {\nbad();\nreturn 0;\n}', 'nes-conio', done, 0, 0, 1); + }); it('should assemble CA65', function(done) { compile('ca65', '\t.segment "HEADER"\n\t.segment "STARTUP"\n\t.segment "CHARS"\n\t.segment "VECTORS"\n\tlda #0\n\tsta $1\n', 'nes-conio', done, 40976, 2); });