From 14837a57ecacbcdc437d1fe00c3e1fa03113a518 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 26 Jul 2016 16:22:38 +0100 Subject: [PATCH] run chktex when request has check:true --- app/coffee/CommandRunner.coffee | 4 ++++ app/coffee/CompileController.coffee | 2 ++ app/coffee/CompileManager.coffee | 8 ++++---- app/coffee/RequestParser.coffee | 3 +++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/coffee/CommandRunner.coffee b/app/coffee/CommandRunner.coffee index 298a495..11bbff8 100644 --- a/app/coffee/CommandRunner.coffee +++ b/app/coffee/CommandRunner.coffee @@ -27,6 +27,10 @@ module.exports = CommandRunner = err = new Error("terminated") err.terminated = true return callback(err) + else if code + err = new Error("exit") + err.code = code + return callback(err) else callback() diff --git a/app/coffee/CompileController.coffee b/app/coffee/CompileController.coffee index 38d53f9..3c9af67 100644 --- a/app/coffee/CompileController.coffee +++ b/app/coffee/CompileController.coffee @@ -17,6 +17,8 @@ module.exports = CompileController = CompileManager.doCompile request, (error, outputFiles = []) -> if error?.terminated status = "terminated" + else if error?.code is 1 + status = "exited" else if error? logger.error err: error, project_id: request.project_id, "error running compile" if error.timedout diff --git a/app/coffee/CompileManager.coffee b/app/coffee/CompileManager.coffee index 81c2c03..3b19cec 100644 --- a/app/coffee/CompileManager.coffee +++ b/app/coffee/CompileManager.coffee @@ -44,9 +44,9 @@ module.exports = CompileManager = # set up environment variables for chktex env = {} - if request.chktex? - env['CHKTEX_OPTIONS'] = '-nall -e9 -e10 -e15 -e16 -e27' - if request.chktex is 'error' + if request.check? + env['CHKTEX_OPTIONS'] = '-nall -e9 -e10 -w15 -w16 -w27' + if request.check is 'error' env['CHKTEX_EXIT_ON_ERROR'] = 1 injectDraftModeIfRequired (error) -> @@ -67,7 +67,7 @@ module.exports = CompileManager = environment: env }, (error, output, stats, timings) -> # compile was killed by user - if error?.terminated + if error?.terminated or error?.code is 1 OutputFileFinder.findOutputFiles request.resources, compileDir, (err, outputFiles) -> return callback(err) if err? callback(error, outputFiles) # return output files so user can check logs diff --git a/app/coffee/RequestParser.coffee b/app/coffee/RequestParser.coffee index bd081fd..5979c75 100644 --- a/app/coffee/RequestParser.coffee +++ b/app/coffee/RequestParser.coffee @@ -28,6 +28,9 @@ module.exports = RequestParser = compile.options.draft, default: false, type: "boolean" + response.check = @_parseAttribute "check", + compile.options.check, + type: "string" if response.timeout > RequestParser.MAX_TIMEOUT response.timeout = RequestParser.MAX_TIMEOUT