decaffeinate: Run post-processing cleanups on BrokenLatexFileTests.coffee and 9 other files

This commit is contained in:
decaffeinate
2020-02-19 12:16:07 +01:00
committed by mserranom
parent 955749a7c4
commit 95854a3abb
10 changed files with 91 additions and 38 deletions

View File

@@ -1,3 +1,8 @@
/* eslint-disable
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/* /*
* decaffeinate suggestions: * decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns * DS102: Remove unnecessary code created because of implicit returns

View File

@@ -1,3 +1,8 @@
/* eslint-disable
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/* /*
* decaffeinate suggestions: * decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns * DS102: Remove unnecessary code created because of implicit returns

View File

@@ -1,3 +1,12 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-path-concat,
no-return-assign,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/* /*
* decaffeinate suggestions: * decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from * DS101: Remove unnecessary use of Array.from
@@ -45,10 +54,10 @@ const compare = function(originalPath, generatedPath, callback) {
const proc = ChildProcess.exec(`compare -metric mae ${fixturePath(originalPath)} ${fixturePath(generatedPath)} ${diff_file}`); const proc = ChildProcess.exec(`compare -metric mae ${fixturePath(originalPath)} ${fixturePath(generatedPath)} ${diff_file}`);
let stderr = ""; let stderr = "";
proc.stderr.on("data", chunk => stderr += chunk); proc.stderr.on("data", chunk => stderr += chunk);
return proc.on("exit", function() { return proc.on("exit", () => {
if (stderr.trim() === "0 (0)") { if (stderr.trim() === "0 (0)") {
// remove output diff if test matches expected image // remove output diff if test matches expected image
fs.unlink(diff_file, function(err) { fs.unlink(diff_file, (err) => {
if (err) { if (err) {
throw err; throw err;
} }
@@ -67,7 +76,7 @@ const checkPdfInfo = function(pdfPath, callback) {
let stdout = ""; let stdout = "";
proc.stdout.on("data", chunk => stdout += chunk); proc.stdout.on("data", chunk => stdout += chunk);
proc.stderr.on("data", chunk => console.log("STDERR", chunk.toString())); proc.stderr.on("data", chunk => console.log("STDERR", chunk.toString()));
return proc.on("exit", function() { return proc.on("exit", () => {
if (stdout.match(/Optimized:\s+yes/)) { if (stdout.match(/Optimized:\s+yes/)) {
return callback(null, true); return callback(null, true);
} else { } else {
@@ -80,7 +89,7 @@ const compareMultiplePages = function(project_id, callback) {
if (callback == null) { callback = function(error) {}; } if (callback == null) { callback = function(error) {}; }
var compareNext = function(page_no, callback) { var compareNext = function(page_no, callback) {
const path = `tmp/${project_id}-source-${page_no}.png`; const path = `tmp/${project_id}-source-${page_no}.png`;
return fs.stat(fixturePath(path), function(error, stat) { return fs.stat(fixturePath(path), (error, stat) => {
if (error != null) { if (error != null) {
return callback(); return callback();
} else { } else {
@@ -111,7 +120,7 @@ const comparePdf = function(project_id, example_dir, callback) {
return callback(); return callback();
}); });
} else { } else {
return compareMultiplePages(project_id, function(error) { return compareMultiplePages(project_id, (error) => {
if (error != null) { throw error; } if (error != null) { throw error; }
return callback(); return callback();
}); });
@@ -138,8 +147,7 @@ const downloadAndComparePdf = function(project_id, example_dir, url, callback) {
Client.runServer(4242, fixturePath("examples")); Client.runServer(4242, fixturePath("examples"));
describe("Example Documents", function() { describe("Example Documents", function() {
before(done => before(function(done) { return ChildProcess.exec("rm test/acceptance/fixtures/tmp/*").on("exit", () => ClsiApp.ensureRunning(done)); }
ChildProcess.exec("rm test/acceptance/fixtures/tmp/*").on("exit", () => ClsiApp.ensureRunning(done))
); );

View File

@@ -1,3 +1,8 @@
/* eslint-disable
handle-callback-err,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/* /*
* decaffeinate suggestions: * decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns * DS102: Remove unnecessary code created because of implicit returns
@@ -40,7 +45,7 @@ Hello world
it("should provide the pdf for download", function(done) { it("should provide the pdf for download", function(done) {
const pdf = Client.getOutputFile(this.body, "pdf"); const pdf = Client.getOutputFile(this.body, "pdf");
return request.get(pdf.url, function(error, res, body) { return request.get(pdf.url, (error, res, body) => {
res.statusCode.should.equal(200); res.statusCode.should.equal(200);
return done(); return done();
}); });
@@ -48,7 +53,7 @@ Hello world
return it("should provide the log for download", function(done) { return it("should provide the log for download", function(done) {
const log = Client.getOutputFile(this.body, "pdf"); const log = Client.getOutputFile(this.body, "pdf");
return request.get(log.url, function(error, res, body) { return request.get(log.url, (error, res, body) => {
res.statusCode.should.equal(200); res.statusCode.should.equal(200);
return done(); return done();
}); });

View File

@@ -1,3 +1,8 @@
/* eslint-disable
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/* /*
* decaffeinate suggestions: * decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns * DS102: Remove unnecessary code created because of implicit returns
@@ -32,20 +37,18 @@ Hello world
}); });
}); });
describe("from code to pdf", () => describe("from code to pdf", function() { return it("should return the correct location", function(done) {
it("should return the correct location", function(done) { return Client.syncFromCode(this.project_id, "main.tex", 3, 5, (error, pdfPositions) => {
return Client.syncFromCode(this.project_id, "main.tex", 3, 5, function(error, pdfPositions) {
if (error != null) { throw error; } if (error != null) { throw error; }
expect(pdfPositions).to.deep.equal({ expect(pdfPositions).to.deep.equal({
pdf: [ { page: 1, h: 133.77, v: 134.76, height: 6.92, width: 343.71 } ] pdf: [ { page: 1, h: 133.77, v: 134.76, height: 6.92, width: 343.71 } ]
}); });
return done(); return done();
}); });
}) }); }
); );
return describe("from pdf to code", () => return describe("from pdf to code", function() { return it("should return the correct location", function(done) {
it("should return the correct location", function(done) {
return Client.syncFromPdf(this.project_id, 1, 100, 200, (error, codePositions) => { return Client.syncFromPdf(this.project_id, 1, 100, 200, (error, codePositions) => {
if (error != null) { throw error; } if (error != null) { throw error; }
expect(codePositions).to.deep.equal({ expect(codePositions).to.deep.equal({
@@ -53,6 +56,6 @@ Hello world
}); });
return done(); return done();
}); });
}) }); }
); );
}); });

View File

@@ -1,3 +1,8 @@
/* eslint-disable
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/* /*
* decaffeinate suggestions: * decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns * DS102: Remove unnecessary code created because of implicit returns
@@ -14,7 +19,7 @@ describe("Timed out compile", function() {
this.request = { this.request = {
options: { options: {
timeout: 10 timeout: 10
}, //seconds }, // seconds
resources: [{ resources: [{
path: "main.tex", path: "main.tex",
content: `\ content: `\

View File

@@ -1,3 +1,9 @@
/* eslint-disable
no-path-concat,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/* /*
* decaffeinate suggestions: * decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns * DS102: Remove unnecessary code created because of implicit returns
@@ -63,7 +69,7 @@ describe("Url Caching", function() {
}); });
}); });
afterEach(() => Server.getFile.restore()); afterEach(function() { return Server.getFile.restore(); });
return it("should download the image", function() { return it("should download the image", function() {
return Server.getFile return Server.getFile
@@ -107,9 +113,9 @@ describe("Url Caching", function() {
}); });
}); });
after(() => Server.getFile.restore()); after(function() { return Server.getFile.restore(); });
return it("should not download the image again", () => Server.getFile.called.should.equal(false)); return it("should not download the image again", function() { return Server.getFile.called.should.equal(false); });
}); });
describe("When an image is in the cache and the last modified date is advanced", function() { describe("When an image is in the cache and the last modified date is advanced", function() {
@@ -148,9 +154,9 @@ describe("Url Caching", function() {
}); });
}); });
afterEach(() => Server.getFile.restore()); afterEach(function() { return Server.getFile.restore(); });
return it("should download the image again", () => Server.getFile.called.should.equal(true)); return it("should download the image again", function() { return Server.getFile.called.should.equal(true); });
}); });
describe("When an image is in the cache and the last modified date is further in the past", function() { describe("When an image is in the cache and the last modified date is further in the past", function() {
@@ -189,9 +195,9 @@ describe("Url Caching", function() {
}); });
}); });
afterEach(() => Server.getFile.restore()); afterEach(function() { return Server.getFile.restore(); });
return it("should not download the image again", () => Server.getFile.called.should.equal(false)); return it("should not download the image again", function() { return Server.getFile.called.should.equal(false); });
}); });
describe("When an image is in the cache and the last modified date is not specified", function() { describe("When an image is in the cache and the last modified date is not specified", function() {
@@ -230,9 +236,9 @@ describe("Url Caching", function() {
}); });
}); });
afterEach(() => Server.getFile.restore()); afterEach(function() { return Server.getFile.restore(); });
return it("should download the image again", () => Server.getFile.called.should.equal(true)); return it("should download the image again", function() { return Server.getFile.called.should.equal(true); });
}); });
return describe("After clearing the cache", function() { return describe("After clearing the cache", function() {
@@ -271,9 +277,9 @@ describe("Url Caching", function() {
}); });
}); });
afterEach(() => Server.getFile.restore()); afterEach(function() { return Server.getFile.restore(); });
return it("should download the image again", () => Server.getFile.called.should.equal(true)); return it("should download the image again", function() { return Server.getFile.called.should.equal(true); });
}); });
}); });

View File

@@ -1,3 +1,8 @@
/* eslint-disable
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/* /*
* decaffeinate suggestions: * decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns * DS102: Remove unnecessary code created because of implicit returns
@@ -27,9 +32,8 @@ describe("Syncing", function() {
}); });
}); });
return describe("wordcount file", () => return describe("wordcount file", function() { return it("should return wordcount info", function(done) {
it("should return wordcount info", function(done) { return Client.wordcount(this.project_id, "main.tex", (error, result) => {
return Client.wordcount(this.project_id, "main.tex", function(error, result) {
if (error != null) { throw error; } if (error != null) { throw error; }
expect(result).to.deep.equal({ expect(result).to.deep.equal({
texcount: { texcount: {
@@ -47,6 +51,6 @@ describe("Syncing", function() {
}); });
return done(); return done();
}); });
}) }); }
); );
}); });

View File

@@ -1,3 +1,10 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/* /*
* decaffeinate suggestions: * decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from * DS101: Remove unnecessary use of Array.from
@@ -35,7 +42,7 @@ module.exports = (Client = {
}, },
getOutputFile(response, type) { getOutputFile(response, type) {
for (let file of Array.from(response.compile.outputFiles)) { for (const file of Array.from(response.compile.outputFiles)) {
if ((file.type === type) && file.url.match(`output.${type}`)) { if ((file.type === type) && file.url.match(`output.${type}`)) {
return file; return file;
} }
@@ -48,7 +55,7 @@ module.exports = (Client = {
const app = express(); const app = express();
app.use(express.static(directory)); app.use(express.static(directory));
console.log("starting test server on", port, host); console.log("starting test server on", port, host);
return app.listen(port, host).on("error", function(error) { return app.listen(port, host).on("error", (error) => {
console.error("error starting server:", error.message); console.error("error starting server:", error.message);
return process.exit(1); return process.exit(1);
}); });
@@ -64,7 +71,7 @@ module.exports = (Client = {
line, line,
column column
} }
}, function(error, response, body) { }, (error, response, body) => {
if (error != null) { return callback(error); } if (error != null) { return callback(error); }
return callback(null, JSON.parse(body)); return callback(null, JSON.parse(body));
}); });
@@ -78,7 +85,7 @@ module.exports = (Client = {
page, page,
h, v h, v
} }
}, function(error, response, body) { }, (error, response, body) => {
if (error != null) { return callback(error); } if (error != null) { return callback(error); }
return callback(null, JSON.parse(body)); return callback(null, JSON.parse(body));
}); });
@@ -93,7 +100,7 @@ module.exports = (Client = {
var entity = entities.pop(); var entity = entities.pop();
const stat = fs.statSync(`${baseDirectory}/${directory}/${entity}`); const stat = fs.statSync(`${baseDirectory}/${directory}/${entity}`);
if (stat.isDirectory()) { if (stat.isDirectory()) {
entities = entities.concat(fs.readdirSync(`${baseDirectory}/${directory}/${entity}`).map(function(subEntity) { entities = entities.concat(fs.readdirSync(`${baseDirectory}/${directory}/${entity}`).map((subEntity) => {
if (subEntity === "main.tex") { if (subEntity === "main.tex") {
rootResourcePath = `${entity}/${subEntity}`; rootResourcePath = `${entity}/${subEntity}`;
} }
@@ -139,7 +146,7 @@ module.exports = (Client = {
qs: { qs: {
file file
} }
}, function(error, response, body) { }, (error, response, body) => {
if (error != null) { return callback(error); } if (error != null) { return callback(error); }
return callback(null, JSON.parse(body)); return callback(null, JSON.parse(body));
}); });

View File

@@ -1,3 +1,8 @@
/* eslint-disable
handle-callback-err,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/* /*
* decaffeinate suggestions: * decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from * DS101: Remove unnecessary use of Array.from