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 3d3861cb24
commit d1da978e39
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:
* 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:
* 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:
* 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}`);
let stderr = "";
proc.stderr.on("data", chunk => stderr += chunk);
return proc.on("exit", function() {
return proc.on("exit", () => {
if (stderr.trim() === "0 (0)") {
// remove output diff if test matches expected image
fs.unlink(diff_file, function(err) {
fs.unlink(diff_file, (err) => {
if (err) {
throw err;
}
@ -67,7 +76,7 @@ const checkPdfInfo = function(pdfPath, callback) {
let stdout = "";
proc.stdout.on("data", chunk => stdout += chunk);
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/)) {
return callback(null, true);
} else {
@ -80,7 +89,7 @@ const compareMultiplePages = function(project_id, callback) {
if (callback == null) { callback = function(error) {}; }
var compareNext = function(page_no, callback) {
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) {
return callback();
} else {
@ -111,7 +120,7 @@ const comparePdf = function(project_id, example_dir, callback) {
return callback();
});
} else {
return compareMultiplePages(project_id, function(error) {
return compareMultiplePages(project_id, (error) => {
if (error != null) { throw error; }
return callback();
});
@ -138,8 +147,7 @@ const downloadAndComparePdf = function(project_id, example_dir, url, callback) {
Client.runServer(4242, fixturePath("examples"));
describe("Example Documents", function() {
before(done =>
ChildProcess.exec("rm test/acceptance/fixtures/tmp/*").on("exit", () => ClsiApp.ensureRunning(done))
before(function(done) { return 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:
* DS102: Remove unnecessary code created because of implicit returns
@ -40,7 +45,7 @@ Hello world
it("should provide the pdf for download", function(done) {
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);
return done();
});
@ -48,7 +53,7 @@ Hello world
return it("should provide the log for download", function(done) {
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);
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:
* DS102: Remove unnecessary code created because of implicit returns
@ -32,20 +37,18 @@ Hello world
});
});
describe("from code to pdf", () =>
it("should return the correct location", function(done) {
return Client.syncFromCode(this.project_id, "main.tex", 3, 5, function(error, pdfPositions) {
describe("from code to pdf", function() { return it("should return the correct location", function(done) {
return Client.syncFromCode(this.project_id, "main.tex", 3, 5, (error, pdfPositions) => {
if (error != null) { throw error; }
expect(pdfPositions).to.deep.equal({
pdf: [ { page: 1, h: 133.77, v: 134.76, height: 6.92, width: 343.71 } ]
});
return done();
});
})
}); }
);
return describe("from pdf to code", () =>
it("should return the correct location", function(done) {
return describe("from pdf to code", function() { return it("should return the correct location", function(done) {
return Client.syncFromPdf(this.project_id, 1, 100, 200, (error, codePositions) => {
if (error != null) { throw error; }
expect(codePositions).to.deep.equal({
@ -53,6 +56,6 @@ Hello world
});
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:
* DS102: Remove unnecessary code created because of implicit returns
@ -14,7 +19,7 @@ describe("Timed out compile", function() {
this.request = {
options: {
timeout: 10
}, //seconds
}, // seconds
resources: [{
path: "main.tex",
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:
* 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 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() {
@ -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() {
@ -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() {
@ -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() {
@ -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:
* DS102: Remove unnecessary code created because of implicit returns
@ -27,9 +32,8 @@ describe("Syncing", function() {
});
});
return describe("wordcount file", () =>
it("should return wordcount info", function(done) {
return Client.wordcount(this.project_id, "main.tex", function(error, result) {
return describe("wordcount file", function() { return it("should return wordcount info", function(done) {
return Client.wordcount(this.project_id, "main.tex", (error, result) => {
if (error != null) { throw error; }
expect(result).to.deep.equal({
texcount: {
@ -47,6 +51,6 @@ describe("Syncing", function() {
});
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:
* DS101: Remove unnecessary use of Array.from
@ -35,7 +42,7 @@ module.exports = (Client = {
},
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}`)) {
return file;
}
@ -48,7 +55,7 @@ module.exports = (Client = {
const app = express();
app.use(express.static(directory));
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);
return process.exit(1);
});
@ -64,7 +71,7 @@ module.exports = (Client = {
line,
column
}
}, function(error, response, body) {
}, (error, response, body) => {
if (error != null) { return callback(error); }
return callback(null, JSON.parse(body));
});
@ -78,7 +85,7 @@ module.exports = (Client = {
page,
h, v
}
}, function(error, response, body) {
}, (error, response, body) => {
if (error != null) { return callback(error); }
return callback(null, JSON.parse(body));
});
@ -93,7 +100,7 @@ module.exports = (Client = {
var entity = entities.pop();
const stat = fs.statSync(`${baseDirectory}/${directory}/${entity}`);
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") {
rootResourcePath = `${entity}/${subEntity}`;
}
@ -139,7 +146,7 @@ module.exports = (Client = {
qs: {
file
}
}, function(error, response, body) {
}, (error, response, body) => {
if (error != null) { return callback(error); }
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:
* DS101: Remove unnecessary use of Array.from