mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
1ddf9283f2
Adds a `flags` parameter to the request JSON, appearing under the `compile.options` key (alongside such stalwarts as `compiler`, `timeout`, etc.). This is primarily to support `-file-line-error` as an option, but could have other uses as well. `flags` should be an array of strings, or absent. If supplied, the listed arguments are added to the base latexmk command.
79 lines
2.3 KiB
CoffeeScript
79 lines
2.3 KiB
CoffeeScript
SandboxedModule = require('sandboxed-module')
|
|
sinon = require('sinon')
|
|
require('chai').should()
|
|
modulePath = require('path').join __dirname, '../../../app/js/LatexRunner'
|
|
Path = require "path"
|
|
|
|
describe "LatexRunner", ->
|
|
beforeEach ->
|
|
@LatexRunner = SandboxedModule.require modulePath, requires:
|
|
"settings-sharelatex": @Settings =
|
|
docker:
|
|
socketPath: "/var/run/docker.sock"
|
|
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
|
|
"./Metrics":
|
|
Timer: class Timer
|
|
done: () ->
|
|
"./CommandRunner": @CommandRunner = {}
|
|
|
|
@directory = "/local/compile/directory"
|
|
@mainFile = "main-file.tex"
|
|
@compiler = "pdflatex"
|
|
@image = "example.com/image"
|
|
@callback = sinon.stub()
|
|
@project_id = "project-id-123"
|
|
@env = {'foo': '123'}
|
|
|
|
describe "runLatex", ->
|
|
beforeEach ->
|
|
@CommandRunner.run = sinon.stub().callsArg(6)
|
|
|
|
describe "normally", ->
|
|
beforeEach ->
|
|
@LatexRunner.runLatex @project_id,
|
|
directory: @directory
|
|
mainFile: @mainFile
|
|
compiler: @compiler
|
|
timeout: @timeout = 42000
|
|
image: @image
|
|
environment: @env
|
|
@callback
|
|
|
|
it "should run the latex command", ->
|
|
@CommandRunner.run
|
|
.calledWith(@project_id, sinon.match.any, @directory, @image, @timeout, @env)
|
|
.should.equal true
|
|
|
|
describe "with an .Rtex main file", ->
|
|
beforeEach ->
|
|
@LatexRunner.runLatex @project_id,
|
|
directory: @directory
|
|
mainFile: "main-file.Rtex"
|
|
compiler: @compiler
|
|
image: @image
|
|
timeout: @timeout = 42000
|
|
@callback
|
|
|
|
it "should run the latex command on the equivalent .tex file", ->
|
|
command = @CommandRunner.run.args[0][1]
|
|
mainFile = command.slice(-1)[0]
|
|
mainFile.should.equal "$COMPILE_DIR/main-file.tex"
|
|
|
|
describe "with a flags option", ->
|
|
beforeEach ->
|
|
@LatexRunner.runLatex @project_id,
|
|
directory: @directory
|
|
mainFile: @mainFile
|
|
compiler: @compiler
|
|
image: @image
|
|
timeout: @timeout = 42000
|
|
flags: ["-file-line-error", "-halt-on-error"]
|
|
@callback
|
|
|
|
it "should include the flags in the command", ->
|
|
command = @CommandRunner.run.args[0][1]
|
|
flags = command.filter (arg) ->
|
|
(arg == "-file-line-error") || (arg == "-halt-on-error")
|
|
flags.length.should.equal 2
|
|
flags[0].should.equal "-file-line-error"
|
|
flags[1].should.equal "-halt-on-error"
|