|
@@ -4,15 +4,21 @@ require("chai").should()
|
|
|
fs = require "fs"
|
|
fs = require "fs"
|
|
|
ChildProcess = require "child_process"
|
|
ChildProcess = require "child_process"
|
|
|
ClsiApp = require "./helpers/ClsiApp"
|
|
ClsiApp = require "./helpers/ClsiApp"
|
|
|
-
|
|
|
|
|
-fixturePath = (path) -> __dirname + "/../fixtures/" + path
|
|
|
|
|
-
|
|
|
|
|
|
|
+logger = require("logger-sharelatex")
|
|
|
|
|
+Path = require("path")
|
|
|
|
|
+fixturePath = (path) -> Path.normalize(__dirname + "/../fixtures/" + path)
|
|
|
|
|
+process = require "process"
|
|
|
|
|
+console.log process.pid, process.ppid, process.getuid(),process.getgroups(), "PID"
|
|
|
try
|
|
try
|
|
|
|
|
+ console.log "creating tmp directory", fixturePath("tmp")
|
|
|
fs.mkdirSync(fixturePath("tmp"))
|
|
fs.mkdirSync(fixturePath("tmp"))
|
|
|
-catch e
|
|
|
|
|
|
|
+catch err
|
|
|
|
|
+ console.log err, fixturePath("tmp"), "unable to create fixture tmp path"
|
|
|
|
|
|
|
|
convertToPng = (pdfPath, pngPath, callback = (error) ->) ->
|
|
convertToPng = (pdfPath, pngPath, callback = (error) ->) ->
|
|
|
command = "convert #{fixturePath(pdfPath)} #{fixturePath(pngPath)}"
|
|
command = "convert #{fixturePath(pdfPath)} #{fixturePath(pngPath)}"
|
|
|
|
|
+ console.log "COMMAND"
|
|
|
|
|
+ console.log command
|
|
|
convert = ChildProcess.exec command
|
|
convert = ChildProcess.exec command
|
|
|
stdout = ""
|
|
stdout = ""
|
|
|
convert.stdout.on "data", (chunk) -> console.log "STDOUT", chunk.toString()
|
|
convert.stdout.on "data", (chunk) -> console.log "STDOUT", chunk.toString()
|
|
@@ -58,6 +64,8 @@ compareMultiplePages = (project_id, callback = (error) ->) ->
|
|
|
compareNext 0, callback
|
|
compareNext 0, callback
|
|
|
|
|
|
|
|
comparePdf = (project_id, example_dir, callback = (error) ->) ->
|
|
comparePdf = (project_id, example_dir, callback = (error) ->) ->
|
|
|
|
|
+ console.log "CONVERT"
|
|
|
|
|
+ console.log "tmp/#{project_id}.pdf", "tmp/#{project_id}-generated.png"
|
|
|
convertToPng "tmp/#{project_id}.pdf", "tmp/#{project_id}-generated.png", (error) =>
|
|
convertToPng "tmp/#{project_id}.pdf", "tmp/#{project_id}-generated.png", (error) =>
|
|
|
throw error if error?
|
|
throw error if error?
|
|
|
convertToPng "examples/#{example_dir}/output.pdf", "tmp/#{project_id}-source.png", (error) =>
|
|
convertToPng "examples/#{example_dir}/output.pdf", "tmp/#{project_id}-source.png", (error) =>
|
|
@@ -76,6 +84,7 @@ comparePdf = (project_id, example_dir, callback = (error) ->) ->
|
|
|
downloadAndComparePdf = (project_id, example_dir, url, callback = (error) ->) ->
|
|
downloadAndComparePdf = (project_id, example_dir, url, callback = (error) ->) ->
|
|
|
writeStream = fs.createWriteStream(fixturePath("tmp/#{project_id}.pdf"))
|
|
writeStream = fs.createWriteStream(fixturePath("tmp/#{project_id}.pdf"))
|
|
|
request.get(url).pipe(writeStream)
|
|
request.get(url).pipe(writeStream)
|
|
|
|
|
+ console.log("writing file out", fixturePath("tmp/#{project_id}.pdf"))
|
|
|
writeStream.on "close", () =>
|
|
writeStream.on "close", () =>
|
|
|
checkPdfInfo "tmp/#{project_id}.pdf", (error, optimised) =>
|
|
checkPdfInfo "tmp/#{project_id}.pdf", (error, optimised) =>
|
|
|
throw error if error?
|
|
throw error if error?
|