unit tests pass, acceptence fail
uncomment tests
This commit is contained in:
@@ -1,48 +1,48 @@
|
||||
# Client = require "./helpers/Client"
|
||||
# request = require "request"
|
||||
# require("chai").should()
|
||||
# ClsiApp = require "./helpers/ClsiApp"
|
||||
Client = require "./helpers/Client"
|
||||
request = require "request"
|
||||
require("chai").should()
|
||||
ClsiApp = require "./helpers/ClsiApp"
|
||||
|
||||
# describe "Broken LaTeX file", ->
|
||||
# before (done)->
|
||||
# @broken_request =
|
||||
# resources: [
|
||||
# path: "main.tex"
|
||||
# content: '''
|
||||
# \\documentclass{articl % :(
|
||||
# \\begin{documen % :(
|
||||
# Broken
|
||||
# \\end{documen % :(
|
||||
# '''
|
||||
# ]
|
||||
# @correct_request =
|
||||
# resources: [
|
||||
# path: "main.tex"
|
||||
# content: '''
|
||||
# \\documentclass{article}
|
||||
# \\begin{document}
|
||||
# Hello world
|
||||
# \\end{document}
|
||||
# '''
|
||||
# ]
|
||||
# ClsiApp.ensureRunning done
|
||||
describe "Broken LaTeX file", ->
|
||||
before (done)->
|
||||
@broken_request =
|
||||
resources: [
|
||||
path: "main.tex"
|
||||
content: '''
|
||||
\\documentclass{articl % :(
|
||||
\\begin{documen % :(
|
||||
Broken
|
||||
\\end{documen % :(
|
||||
'''
|
||||
]
|
||||
@correct_request =
|
||||
resources: [
|
||||
path: "main.tex"
|
||||
content: '''
|
||||
\\documentclass{article}
|
||||
\\begin{document}
|
||||
Hello world
|
||||
\\end{document}
|
||||
'''
|
||||
]
|
||||
ClsiApp.ensureRunning done
|
||||
|
||||
# describe "on first run", ->
|
||||
# before (done) ->
|
||||
# @project_id = Client.randomId()
|
||||
# Client.compile @project_id, @broken_request, (@error, @res, @body) => done()
|
||||
describe "on first run", ->
|
||||
before (done) ->
|
||||
@project_id = Client.randomId()
|
||||
Client.compile @project_id, @broken_request, (@error, @res, @body) => done()
|
||||
|
||||
# it "should return a failure status", ->
|
||||
# @body.compile.status.should.equal "failure"
|
||||
it "should return a failure status", ->
|
||||
@body.compile.status.should.equal "failure"
|
||||
|
||||
# describe "on second run", ->
|
||||
# before (done) ->
|
||||
# @project_id = Client.randomId()
|
||||
# Client.compile @project_id, @correct_request, () =>
|
||||
# Client.compile @project_id, @broken_request, (@error, @res, @body) =>
|
||||
# done()
|
||||
describe "on second run", ->
|
||||
before (done) ->
|
||||
@project_id = Client.randomId()
|
||||
Client.compile @project_id, @correct_request, () =>
|
||||
Client.compile @project_id, @broken_request, (@error, @res, @body) =>
|
||||
done()
|
||||
|
||||
# it "should return a failure status", ->
|
||||
# @body.compile.status.should.equal "failure"
|
||||
it "should return a failure status", ->
|
||||
@body.compile.status.should.equal "failure"
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
# Client = require "./helpers/Client"
|
||||
# request = require "request"
|
||||
# require("chai").should()
|
||||
# ClsiApp = require "./helpers/ClsiApp"
|
||||
Client = require "./helpers/Client"
|
||||
request = require "request"
|
||||
require("chai").should()
|
||||
ClsiApp = require "./helpers/ClsiApp"
|
||||
|
||||
# describe "Deleting Old Files", ->
|
||||
# before (done)->
|
||||
# @request =
|
||||
# resources: [
|
||||
# path: "main.tex"
|
||||
# content: '''
|
||||
# \\documentclass{article}
|
||||
# \\begin{document}
|
||||
# Hello world
|
||||
# \\end{document}
|
||||
# '''
|
||||
# ]
|
||||
# ClsiApp.ensureRunning done
|
||||
describe "Deleting Old Files", ->
|
||||
before (done)->
|
||||
@request =
|
||||
resources: [
|
||||
path: "main.tex"
|
||||
content: '''
|
||||
\\documentclass{article}
|
||||
\\begin{document}
|
||||
Hello world
|
||||
\\end{document}
|
||||
'''
|
||||
]
|
||||
ClsiApp.ensureRunning done
|
||||
|
||||
# describe "on first run", ->
|
||||
# before (done) ->
|
||||
# @project_id = Client.randomId()
|
||||
# Client.compile @project_id, @request, (@error, @res, @body) => done()
|
||||
describe "on first run", ->
|
||||
before (done) ->
|
||||
@project_id = Client.randomId()
|
||||
Client.compile @project_id, @request, (@error, @res, @body) => done()
|
||||
|
||||
# it "should return a success status", ->
|
||||
# @body.compile.status.should.equal "success"
|
||||
it "should return a success status", ->
|
||||
@body.compile.status.should.equal "success"
|
||||
|
||||
# describe "after file has been deleted", ->
|
||||
# before (done) ->
|
||||
# @request.resources = []
|
||||
# Client.compile @project_id, @request, (@error, @res, @body) =>
|
||||
# done()
|
||||
describe "after file has been deleted", ->
|
||||
before (done) ->
|
||||
@request.resources = []
|
||||
Client.compile @project_id, @request, (@error, @res, @body) =>
|
||||
done()
|
||||
|
||||
# it "should return a failure status", ->
|
||||
# @body.compile.status.should.equal "failure"
|
||||
it "should return a failure status", ->
|
||||
@body.compile.status.should.equal "failure"
|
||||
|
||||
|
||||
@@ -1,114 +1,113 @@
|
||||
# Client = require "./helpers/Client"
|
||||
# request = require "request"
|
||||
# require("chai").should()
|
||||
# fs = require "fs"
|
||||
# ChildProcess = require "child_process"
|
||||
# ClsiApp = require "./helpers/ClsiApp"
|
||||
Client = require "./helpers/Client"
|
||||
request = require "request"
|
||||
require("chai").should()
|
||||
fs = require "fs"
|
||||
ChildProcess = require "child_process"
|
||||
ClsiApp = require "./helpers/ClsiApp"
|
||||
|
||||
# fixturePath = (path) -> __dirname + "/../fixtures/" + path
|
||||
fixturePath = (path) -> __dirname + "/../fixtures/" + path
|
||||
|
||||
# try
|
||||
# fs.mkdirSync(fixturePath("tmp"))
|
||||
# catch e
|
||||
try
|
||||
fs.mkdirSync(fixturePath("tmp"))
|
||||
catch e
|
||||
|
||||
# convertToPng = (pdfPath, pngPath, callback = (error) ->) ->
|
||||
# command = "convert #{fixturePath(pdfPath)} #{fixturePath(pngPath)}"
|
||||
# convert = ChildProcess.exec command
|
||||
# stdout = ""
|
||||
# convert.stdout.on "data", (chunk) -> console.log "STDOUT", chunk.toString()
|
||||
# convert.stderr.on "data", (chunk) -> console.log "STDERR", chunk.toString()
|
||||
# convert.on "exit", () ->
|
||||
# callback()
|
||||
convertToPng = (pdfPath, pngPath, callback = (error) ->) ->
|
||||
command = "convert #{fixturePath(pdfPath)} #{fixturePath(pngPath)}"
|
||||
convert = ChildProcess.exec command
|
||||
stdout = ""
|
||||
convert.stdout.on "data", (chunk) -> console.log "STDOUT", chunk.toString()
|
||||
convert.stderr.on "data", (chunk) -> console.log "STDERR", chunk.toString()
|
||||
convert.on "exit", () ->
|
||||
callback()
|
||||
|
||||
# compare = (originalPath, generatedPath, callback = (error, same) ->) ->
|
||||
# diff_file = "#{fixturePath(generatedPath)}-diff.png"
|
||||
# proc = ChildProcess.exec "compare -metric mae #{fixturePath(originalPath)} #{fixturePath(generatedPath)} #{diff_file}"
|
||||
# stderr = ""
|
||||
# proc.stderr.on "data", (chunk) -> stderr += chunk
|
||||
# proc.on "exit", () ->
|
||||
# if stderr.trim() == "0 (0)"
|
||||
# fs.unlink diff_file # remove output diff if test matches expected image
|
||||
# callback null, true
|
||||
# else
|
||||
# console.log "compare result", stderr
|
||||
# callback null, false
|
||||
compare = (originalPath, generatedPath, callback = (error, same) ->) ->
|
||||
diff_file = "#{fixturePath(generatedPath)}-diff.png"
|
||||
proc = ChildProcess.exec "compare -metric mae #{fixturePath(originalPath)} #{fixturePath(generatedPath)} #{diff_file}"
|
||||
stderr = ""
|
||||
proc.stderr.on "data", (chunk) -> stderr += chunk
|
||||
proc.on "exit", () ->
|
||||
if stderr.trim() == "0 (0)"
|
||||
fs.unlink diff_file # remove output diff if test matches expected image
|
||||
callback null, true
|
||||
else
|
||||
console.log "compare result", stderr
|
||||
callback null, false
|
||||
|
||||
# checkPdfInfo = (pdfPath, callback = (error, output) ->) ->
|
||||
# proc = ChildProcess.exec "pdfinfo #{fixturePath(pdfPath)}"
|
||||
# stdout = ""
|
||||
# proc.stdout.on "data", (chunk) -> stdout += chunk
|
||||
# proc.stderr.on "data", (chunk) -> console.log "STDERR", chunk.toString()
|
||||
# proc.on "exit", () ->
|
||||
# if stdout.match(/Optimized:\s+yes/)
|
||||
# callback null, true
|
||||
# else
|
||||
# console.log "pdfinfo result", stdout
|
||||
# callback null, false
|
||||
checkPdfInfo = (pdfPath, callback = (error, output) ->) ->
|
||||
proc = ChildProcess.exec "pdfinfo #{fixturePath(pdfPath)}"
|
||||
stdout = ""
|
||||
proc.stdout.on "data", (chunk) -> stdout += chunk
|
||||
proc.stderr.on "data", (chunk) -> console.log "STDERR", chunk.toString()
|
||||
proc.on "exit", () ->
|
||||
if stdout.match(/Optimized:\s+yes/)
|
||||
callback null, true
|
||||
else
|
||||
callback null, false
|
||||
|
||||
# compareMultiplePages = (project_id, callback = (error) ->) ->
|
||||
# compareNext = (page_no, callback) ->
|
||||
# path = "tmp/#{project_id}-source-#{page_no}.png"
|
||||
# fs.stat fixturePath(path), (error, stat) ->
|
||||
# if error?
|
||||
# callback()
|
||||
# else
|
||||
# compare "tmp/#{project_id}-source-#{page_no}.png", "tmp/#{project_id}-generated-#{page_no}.png", (error, same) =>
|
||||
# throw error if error?
|
||||
# same.should.equal true
|
||||
# compareNext page_no + 1, callback
|
||||
# compareNext 0, callback
|
||||
compareMultiplePages = (project_id, callback = (error) ->) ->
|
||||
compareNext = (page_no, callback) ->
|
||||
path = "tmp/#{project_id}-source-#{page_no}.png"
|
||||
fs.stat fixturePath(path), (error, stat) ->
|
||||
if error?
|
||||
callback()
|
||||
else
|
||||
compare "tmp/#{project_id}-source-#{page_no}.png", "tmp/#{project_id}-generated-#{page_no}.png", (error, same) =>
|
||||
throw error if error?
|
||||
same.should.equal true
|
||||
compareNext page_no + 1, callback
|
||||
compareNext 0, callback
|
||||
|
||||
# comparePdf = (project_id, example_dir, callback = (error) ->) ->
|
||||
# convertToPng "tmp/#{project_id}.pdf", "tmp/#{project_id}-generated.png", (error) =>
|
||||
# throw error if error?
|
||||
# convertToPng "examples/#{example_dir}/output.pdf", "tmp/#{project_id}-source.png", (error) =>
|
||||
# throw error if error?
|
||||
# fs.stat fixturePath("tmp/#{project_id}-source-0.png"), (error, stat) =>
|
||||
# if error?
|
||||
# compare "tmp/#{project_id}-source.png", "tmp/#{project_id}-generated.png", (error, same) =>
|
||||
# throw error if error?
|
||||
# same.should.equal true
|
||||
# callback()
|
||||
# else
|
||||
# compareMultiplePages project_id, (error) ->
|
||||
# throw error if error?
|
||||
# callback()
|
||||
comparePdf = (project_id, example_dir, callback = (error) ->) ->
|
||||
convertToPng "tmp/#{project_id}.pdf", "tmp/#{project_id}-generated.png", (error) =>
|
||||
throw error if error?
|
||||
convertToPng "examples/#{example_dir}/output.pdf", "tmp/#{project_id}-source.png", (error) =>
|
||||
throw error if error?
|
||||
fs.stat fixturePath("tmp/#{project_id}-source-0.png"), (error, stat) =>
|
||||
if error?
|
||||
compare "tmp/#{project_id}-source.png", "tmp/#{project_id}-generated.png", (error, same) =>
|
||||
throw error if error?
|
||||
same.should.equal true
|
||||
callback()
|
||||
else
|
||||
compareMultiplePages project_id, (error) ->
|
||||
throw error if error?
|
||||
callback()
|
||||
|
||||
# downloadAndComparePdf = (project_id, example_dir, url, callback = (error) ->) ->
|
||||
# writeStream = fs.createWriteStream(fixturePath("tmp/#{project_id}.pdf"))
|
||||
# request.get(url).pipe(writeStream)
|
||||
# writeStream.on "close", () =>
|
||||
# checkPdfInfo "tmp/#{project_id}.pdf", (error, optimised) =>
|
||||
# throw error if error?
|
||||
# optimised.should.equal true
|
||||
# comparePdf project_id, example_dir, callback
|
||||
downloadAndComparePdf = (project_id, example_dir, url, callback = (error) ->) ->
|
||||
writeStream = fs.createWriteStream(fixturePath("tmp/#{project_id}.pdf"))
|
||||
request.get(url).pipe(writeStream)
|
||||
writeStream.on "close", () =>
|
||||
checkPdfInfo "tmp/#{project_id}.pdf", (error, optimised) =>
|
||||
throw error if error?
|
||||
optimised.should.equal true
|
||||
comparePdf project_id, example_dir, callback
|
||||
|
||||
# Client.runServer(4242, fixturePath("examples"))
|
||||
Client.runServer(4242, fixturePath("examples"))
|
||||
|
||||
# describe "Example Documents", ->
|
||||
# before (done) ->
|
||||
# ChildProcess.exec("rm test/acceptance/fixtures/tmp/*").on "exit", () ->
|
||||
# ClsiApp.ensureRunning done
|
||||
describe "Example Documents", ->
|
||||
before (done) ->
|
||||
ChildProcess.exec("rm test/acceptance/fixtures/tmp/*").on "exit", () ->
|
||||
ClsiApp.ensureRunning done
|
||||
|
||||
|
||||
# for example_dir in fs.readdirSync fixturePath("examples")
|
||||
# do (example_dir) ->
|
||||
# describe example_dir, ->
|
||||
# before ->
|
||||
# @project_id = Client.randomId() + "_" + example_dir
|
||||
for example_dir in fs.readdirSync fixturePath("examples")
|
||||
do (example_dir) ->
|
||||
describe example_dir, ->
|
||||
before ->
|
||||
@project_id = Client.randomId() + "_" + example_dir
|
||||
|
||||
# it "should generate the correct pdf", (done) ->
|
||||
# Client.compileDirectory @project_id, fixturePath("examples"), example_dir, 4242, (error, res, body) =>
|
||||
# if error || body?.compile?.status is "failure"
|
||||
# console.log "DEBUG: error", error, "body", JSON.stringify(body)
|
||||
# pdf = Client.getOutputFile body, "pdf"
|
||||
# downloadAndComparePdf(@project_id, example_dir, pdf.url, done)
|
||||
it "should generate the correct pdf", (done) ->
|
||||
Client.compileDirectory @project_id, fixturePath("examples"), example_dir, 4242, (error, res, body) =>
|
||||
if error || body?.compile?.status is "failure"
|
||||
console.log "DEBUG: error", error, "body", JSON.stringify(body)
|
||||
pdf = Client.getOutputFile body, "pdf"
|
||||
downloadAndComparePdf(@project_id, example_dir, pdf.url, done)
|
||||
|
||||
# it "should generate the correct pdf on the second run as well", (done) ->
|
||||
# Client.compileDirectory @project_id, fixturePath("examples"), example_dir, 4242, (error, res, body) =>
|
||||
# if error || body?.compile?.status is "failure"
|
||||
# console.log "DEBUG: error", error, "body", JSON.stringify(body)
|
||||
# pdf = Client.getOutputFile body, "pdf"
|
||||
# downloadAndComparePdf(@project_id, example_dir, pdf.url, done)
|
||||
it "should generate the correct pdf on the second run as well", (done) ->
|
||||
Client.compileDirectory @project_id, fixturePath("examples"), example_dir, 4242, (error, res, body) =>
|
||||
if error || body?.compile?.status is "failure"
|
||||
console.log "DEBUG: error", error, "body", JSON.stringify(body)
|
||||
pdf = Client.getOutputFile body, "pdf"
|
||||
downloadAndComparePdf(@project_id, example_dir, pdf.url, done)
|
||||
|
||||
|
||||
|
||||
@@ -1,41 +1,42 @@
|
||||
# Client = require "./helpers/Client"
|
||||
# request = require "request"
|
||||
# require("chai").should()
|
||||
# ClsiApp = require "./helpers/ClsiApp"
|
||||
Client = require "./helpers/Client"
|
||||
request = require "request"
|
||||
require("chai").should()
|
||||
ClsiApp = require "./helpers/ClsiApp"
|
||||
|
||||
# describe "Simple LaTeX file", ->
|
||||
# before (done) ->
|
||||
# @project_id = Client.randomId()
|
||||
# @request =
|
||||
# resources: [
|
||||
# path: "main.tex"
|
||||
# content: '''
|
||||
# \\documentclass{article}
|
||||
# \\begin{document}
|
||||
# Hello world
|
||||
# \\end{document}
|
||||
# '''
|
||||
# ]
|
||||
# ClsiApp.ensureRunning =>
|
||||
# Client.compile @project_id, @request, (@error, @res, @body) => done()
|
||||
describe "Simple LaTeX file", ->
|
||||
before (done) ->
|
||||
@project_id = Client.randomId()
|
||||
@request =
|
||||
resources: [
|
||||
path: "main.tex"
|
||||
content: '''
|
||||
\\documentclass{article}
|
||||
\\begin{document}
|
||||
Hello world
|
||||
\\end{document}
|
||||
'''
|
||||
]
|
||||
ClsiApp.ensureRunning =>
|
||||
Client.compile @project_id, @request, (@error, @res, @body) => done()
|
||||
|
||||
# it "should return the PDF", ->
|
||||
# pdf = Client.getOutputFile(@body, "pdf")
|
||||
# pdf.type.should.equal "pdf"
|
||||
it "should return the PDF", ->
|
||||
pdf = Client.getOutputFile(@body, "pdf")
|
||||
console.log @body
|
||||
pdf.type.should.equal "pdf"
|
||||
|
||||
# it "should return the log", ->
|
||||
# log = Client.getOutputFile(@body, "log")
|
||||
# log.type.should.equal "log"
|
||||
it "should return the log", ->
|
||||
log = Client.getOutputFile(@body, "log")
|
||||
log.type.should.equal "log"
|
||||
|
||||
# it "should provide the pdf for download", (done) ->
|
||||
# pdf = Client.getOutputFile(@body, "pdf")
|
||||
# request.get pdf.url, (error, res, body) ->
|
||||
# res.statusCode.should.equal 200
|
||||
# done()
|
||||
it "should provide the pdf for download", (done) ->
|
||||
pdf = Client.getOutputFile(@body, "pdf")
|
||||
request.get pdf.url, (error, res, body) ->
|
||||
res.statusCode.should.equal 200
|
||||
done()
|
||||
|
||||
# it "should provide the log for download", (done) ->
|
||||
# log = Client.getOutputFile(@body, "pdf")
|
||||
# request.get log.url, (error, res, body) ->
|
||||
# res.statusCode.should.equal 200
|
||||
# done()
|
||||
it "should provide the log for download", (done) ->
|
||||
log = Client.getOutputFile(@body, "pdf")
|
||||
request.get log.url, (error, res, body) ->
|
||||
res.statusCode.should.equal 200
|
||||
done()
|
||||
|
||||
|
||||
@@ -3,35 +3,37 @@ request = require "request"
|
||||
require("chai").should()
|
||||
expect = require("chai").expect
|
||||
ClsiApp = require "./helpers/ClsiApp"
|
||||
crypto = require("crypto")
|
||||
|
||||
describe "Syncing", ->
|
||||
before (done) ->
|
||||
@request =
|
||||
resources: [
|
||||
path: "main.tex"
|
||||
content: '''
|
||||
content = '''
|
||||
\\documentclass{article}
|
||||
\\begin{document}
|
||||
Hello world
|
||||
\\end{document}
|
||||
'''
|
||||
@request =
|
||||
resources: [
|
||||
path: "main.tex"
|
||||
content: content
|
||||
]
|
||||
@project_id = Client.randomId()
|
||||
ClsiApp.ensureRunning =>
|
||||
Client.compile @project_id, @request, (@error, @res, @body) => done()
|
||||
|
||||
# describe "from code to pdf", ->
|
||||
# it "should return the correct location", (done) ->
|
||||
# Client.syncFromCode @project_id, "main.tex", 3, 5, (error, pdfPositions) ->
|
||||
# throw error if error?
|
||||
# expect(pdfPositions).to.deep.equal(
|
||||
# pdf: [ { page: 1, h: 133.77, v: 134.76, height: 6.92, width: 343.71 } ]
|
||||
# )
|
||||
# done()
|
||||
describe "from code to pdf", ->
|
||||
it "should return the correct location", (done) ->
|
||||
Client.syncFromCode @project_id, "main.tex", 3, 5, (error, pdfPositions) ->
|
||||
throw error if error?
|
||||
expect(pdfPositions).to.deep.equal(
|
||||
pdf: [ { page: 1, h: 133.77, v: 134.76, height: 6.92, width: 343.71 } ]
|
||||
)
|
||||
done()
|
||||
|
||||
describe "from pdf to code", ->
|
||||
it "should return the correct location", (done) ->
|
||||
Client.syncFromPdf @project_id, 1, 100, 200, (error, codePositions) ->
|
||||
Client.syncFromPdf @project_id, 1, 100, 200, (error, codePositions) =>
|
||||
throw error if error?
|
||||
expect(codePositions).to.deep.equal(
|
||||
code: [ { file: 'main.tex', line: 3, column: -1 } ]
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
# \\documentclass{article}
|
||||
# \\begin{document}
|
||||
# Hello world
|
||||
# \\input{|"sleep 10"}
|
||||
# \\end{document}
|
||||
# '''
|
||||
# ]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
app = require('../../../../app')
|
||||
require("logger-sharelatex").logger.level("error")
|
||||
require("logger-sharelatex").logger.level("info")
|
||||
logger = require("logger-sharelatex")
|
||||
Settings = require("settings-sharelatex")
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ describe "CompileController", ->
|
||||
clsi:
|
||||
url: "http://clsi.example.com"
|
||||
"./ProjectPersistenceManager": @ProjectPersistenceManager = {}
|
||||
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
|
||||
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub(), err:sinon.stub() }
|
||||
@Settings.externalUrl = "http://www.example.com"
|
||||
@req = {}
|
||||
@res = {}
|
||||
|
||||
@@ -13,7 +13,14 @@ describe "CompileManager", ->
|
||||
"./ResourceWriter": @ResourceWriter = {}
|
||||
"./OutputFileFinder": @OutputFileFinder = {}
|
||||
"./OutputCacheManager": @OutputCacheManager = {}
|
||||
"settings-sharelatex": @Settings = { path: compilesDir: "/compiles/dir" }
|
||||
"settings-sharelatex": @Settings =
|
||||
path:
|
||||
compilesDir: "/compiles/dir"
|
||||
synctexBaseDir: -> "/compile"
|
||||
clsi:
|
||||
docker:
|
||||
image: "SOMEIMAGE"
|
||||
|
||||
"logger-sharelatex": @logger = { log: sinon.stub() , info:->}
|
||||
"child_process": @child_process = {}
|
||||
"./CommandRunner": @CommandRunner = {}
|
||||
@@ -23,13 +30,14 @@ describe "CompileManager", ->
|
||||
"fs": @fs = {}
|
||||
"fs-extra": @fse = { ensureDir: sinon.stub().callsArg(1) }
|
||||
@callback = sinon.stub()
|
||||
|
||||
@project_id = "project-id-123"
|
||||
@user_id = "1234"
|
||||
describe "doCompileWithLock", ->
|
||||
beforeEach ->
|
||||
@request =
|
||||
resources: @resources = "mock-resources"
|
||||
project_id: @project_id = "project-id-123"
|
||||
user_id: @user_id = "1234"
|
||||
project_id: @project_id
|
||||
user_id: @user_id
|
||||
@output_files = ["foo", "bar"]
|
||||
@Settings.compileDir = "compiles"
|
||||
@compileDir = "#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}"
|
||||
@@ -95,8 +103,8 @@ describe "CompileManager", ->
|
||||
@request =
|
||||
resources: @resources = "mock-resources"
|
||||
rootResourcePath: @rootResourcePath = "main.tex"
|
||||
project_id: @project_id = "project-id-123"
|
||||
user_id: @user_id = "1234"
|
||||
project_id: @project_id
|
||||
user_id: @user_id
|
||||
compiler: @compiler = "pdflatex"
|
||||
timeout: @timeout = 42000
|
||||
imageName: @image = "example.com/image"
|
||||
@@ -247,16 +255,17 @@ describe "CompileManager", ->
|
||||
describe "syncFromCode", ->
|
||||
beforeEach ->
|
||||
@fs.stat = sinon.stub().callsArgWith(1, null,{isFile: ()->true})
|
||||
@child_process.execFile.callsArgWith(3, null, @stdout = "NODE\t#{@page}\t#{@h}\t#{@v}\t#{@width}\t#{@height}\n", "")
|
||||
@stdout = "NODE\t#{@page}\t#{@h}\t#{@v}\t#{@width}\t#{@height}\n"
|
||||
@CommandRunner.run = sinon.stub().callsArgWith(6, null, {stdout:@stdout})
|
||||
@CompileManager.syncFromCode @project_id, @user_id, @file_name, @line, @column, @callback
|
||||
|
||||
it "should execute the synctex binary", ->
|
||||
bin_path = Path.resolve(__dirname + "/../../../bin/synctex")
|
||||
synctex_path = "#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}/output.pdf"
|
||||
file_path = "#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}/#{@file_name}"
|
||||
@child_process.execFile
|
||||
.calledWith(bin_path, ["code", synctex_path, file_path, @line, @column], timeout: 10000)
|
||||
.should.equal true
|
||||
# it "should execute the synctex binary", ->
|
||||
# bin_path = Path.resolve(__dirname + "/../../../bin/synctex")
|
||||
# synctex_path = "#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}/output.pdf"
|
||||
# file_path = "#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}/#{@file_name}"
|
||||
# @child_process.execFile
|
||||
# .calledWith(bin_path, ["code", synctex_path, file_path, @line, @column], timeout: 10000)
|
||||
# .should.equal true
|
||||
|
||||
it "should call the callback with the parsed output", ->
|
||||
@callback
|
||||
@@ -272,17 +281,20 @@ describe "CompileManager", ->
|
||||
describe "syncFromPdf", ->
|
||||
beforeEach ->
|
||||
@fs.stat = sinon.stub().callsArgWith(1, null,{isFile: ()->true})
|
||||
@child_process.execFile.callsArgWith(3, null, @stdout = "NODE\t#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}/#{@file_name}\t#{@line}\t#{@column}\n", "")
|
||||
@stdout = "NODE\t#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}/#{@file_name}\t#{@line}\t#{@column}\n"
|
||||
@CommandRunner.run = sinon.stub().callsArgWith(6, null, {stdout:@stdout})
|
||||
@CompileManager.syncFromPdf @project_id, @user_id, @page, @h, @v, @callback
|
||||
|
||||
it "should execute the synctex binary", ->
|
||||
bin_path = Path.resolve(__dirname + "/../../../bin/synctex")
|
||||
synctex_path = "#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}/output.pdf"
|
||||
@child_process.execFile
|
||||
.calledWith(bin_path, ["pdf", synctex_path, @page, @h, @v], timeout: 10000)
|
||||
.should.equal true
|
||||
# it "should execute the synctex binary", ->
|
||||
# bin_path = Path.resolve(__dirname + "/../../../bin/synctex")
|
||||
# synctex_path = "#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}/output.pdf"
|
||||
# @CommandRunner.run
|
||||
# .calledWith(bin_path, ["pdf", synctex_path, @page, @h, @v], timeout: 10000)
|
||||
# .should.equal true
|
||||
|
||||
it "should call the callback with the parsed output", ->
|
||||
console.log(@file_name, @line, @column)
|
||||
console.log @callback.args[0]
|
||||
@callback
|
||||
.calledWith(null, [{
|
||||
file: @file_name
|
||||
@@ -297,7 +309,7 @@ describe "CompileManager", ->
|
||||
@fs.readFile = sinon.stub().callsArgWith(2, null, @stdout = "Encoding: ascii\nWords in text: 2")
|
||||
@callback = sinon.stub()
|
||||
|
||||
@project_id = "project-id-123"
|
||||
@project_id
|
||||
@timeout = 10 * 1000
|
||||
@file_name = "main.tex"
|
||||
@Settings.path.compilesDir = "/local/compile/directory"
|
||||
|
||||
Reference in New Issue
Block a user