Skip to content
This repository has been archived by the owner on Aug 14, 2022. It is now read-only.

Commit

Permalink
Handle missing output file info in log files
Browse files Browse the repository at this point in the history
This is an attempt to fix #46 (and related issues) which are caused
by "Output written on .." text missing in log files. This caused
problems due to `outputFilePath` being set to `null` yet the status code
was 0, thus the build was treated as a success, but paths ended up
with an invalid "null" segment.

Added a regression style test that should (hopefully) ensure this
problem does not get re-introduced.
  • Loading branch information
thomasjo committed Feb 6, 2015
1 parent 5455a2d commit 573d9eb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 21 deletions.
49 changes: 28 additions & 21 deletions lib/latex.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,15 @@ module.exports =
proc = builder.run args, (statusCode) =>
@destroyProgressIndicator()
result = builder.parseLogFile(rootFilePath)
switch statusCode
when 0
@pdfFile = result.outputFilePath
@moveResult(result, rootFilePath) if @shouldMoveResult()
@showResult(result)
when 127 then @showError \
"""
TeXification failed! Builder executable not found.
latex.texPath
as configured: #{atom.config.get('latex.texPath')}
when resolved: #{builder.constructPath()}
Make sure latex.texPath is configured correctly; either adjust it \
via the settings view, or directly in your config.cson file.
"""
else @showError \
"""
TeXification failed with status code #{statusCode}! \
Check the log file for more info...
"""

unless result.outputFilePath?
error = @constructError(statusCode, builder)
@showError(error)
return false

@pdfFile = result.outputFilePath
@moveResult(result, rootFilePath) if @shouldMoveResult()
@showResult(result)

return true

Expand Down Expand Up @@ -202,3 +190,22 @@ module.exports =
destroyErrorIndicator: ->
@errorIndicator?.destroy()
@errorIndicator = null

constructError: (statusCode, builder) ->
switch statusCode
when 127
"""
TeXification failed! Builder executable not found.
latex.texPath
as configured: #{atom.config.get('latex.texPath')}
when resolved: #{builder.constructPath()}
Make sure latex.texPath is configured correctly; either adjust it \
via the settings view, or directly in your config.cson file.
"""
else
"""
TeXification failed with status code #{statusCode}! \
Check the log file for more info...
"""
24 changes: 24 additions & 0 deletions spec/latex-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ helpers = require './spec-helpers'
fs = require 'fs-plus'
path = require 'path'
latex = require '../lib/latex'
LatexmkBuilder = require '../lib/builders/latexmk'

describe "Latex", ->
[fixturesPath] = []
Expand Down Expand Up @@ -119,6 +120,29 @@ describe "Latex", ->
warnings: []
}

it "treats missing output file data in log file as an error", ->
class MockBuilder extends LatexmkBuilder
parseLogFile: (texFilePath) ->
result =
outputFilePath: null
errors: []
warnings: []

spyOn(latex, 'getBuilder').andReturn(new MockBuilder())
spyOn(latex, 'showError').andCallThrough()

waitsForPromise ->
atom.workspace.open('file.tex')

runs ->
latex.build()

waitsFor ->
latex.showError.callCount == 1

runs ->
expect(latex.showError).toHaveBeenCalled()

describe "getOpener", ->
originalPlatform = process.platform

Expand Down

0 comments on commit 573d9eb

Please sign in to comment.