| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562 |
- define([
- '../src/js/latex-log-parser',
- '../src/js/bib-log-parser',
- 'text!logs/errors.log',
- 'text!logs/warnings.log',
- 'text!logs/bad-boxes.log',
- 'text!logs/biber-warnings.log',
- 'text!logs/natbib-warnings.log',
- 'text!logs/geometry-warnings.log',
- 'text!logs/caption-warnings.log',
- 'text!logs/runaway-arguments.log',
- 'text!logs/filenames.log',
- 'text!logs/file-line-error.log',
- 'text!logs/biber.blg',
- 'text!logs/bibtex.blg',
- ], function (
- LatexParser,
- BibLogParser,
- errorLog,
- warningLog,
- badBoxesLog,
- biberWarningsLog,
- natbibWarningsLog,
- geometryWarningsLog,
- captionWarningsLog,
- runawayArgumentsLog,
- filenamesLog,
- fileLineErrorLog,
- biberBlg,
- bibtexBlg
- ) {
- function prettyFileList(files, depth) {
- depth = depth || ' '
- for (var i = 0; i < files.length; i++) {
- console.log(depth + files[i].path)
- prettyFileList(files[i].files, depth + ' ')
- }
- }
- module('Errors')
- test('Error parsing', function () {
- var errors = LatexParser.parse(errorLog, {
- ignoreDuplicates: true,
- }).errors
- var expectedErrors = [
- [29, 'Undefined control sequence.'] + '',
- [
- 30,
- 'LaTeX Error: \\begin{equation} on input line 28 ended by \\end{equaion}.',
- ] + '',
- [30, 'Missing $ inserted.'] + '',
- [30, 'Display math should end with $$.'] + '',
- [46, 'Extra }, or forgotten \\right.'] + '',
- [46, 'Missing \\right. inserted.'] + '',
- [46, 'Missing } inserted.'] + '',
- ]
- expect(expectedErrors.length)
- for (var i = 0; i < errors.length; i++) {
- if (
- expectedErrors.indexOf([errors[i].line, errors[i].message] + '') > -1
- ) {
- ok(true, 'Found error: ' + errors[i].message)
- }
- }
- })
- module('Bad boxes')
- test('Badbox parsing', function () {
- var errors = LatexParser.parse(badBoxesLog).typesetting
- var expectedErrors = [
- [9, 'Overfull \\hbox (29.11179pt too wide) in paragraph at lines 9--10'] +
- '',
- [11, 'Underfull \\hbox (badness 10000) in paragraph at lines 11--13'] +
- '',
- [27, 'Overfull \\vbox (12.00034pt too high) detected at line 27'] + '',
- [46, 'Underfull \\vbox (badness 10000) detected at line 46'] + '',
- [54, 'Underfull \\hbox (badness 10000) in paragraph at lines 54--55'] +
- '',
- [58, 'Underfull \\hbox (badness 10000) in paragraph at lines 58--60'] +
- '',
- ]
- expect(expectedErrors.length)
- for (var i = 0; i < errors.length; i++) {
- if (
- expectedErrors.indexOf([errors[i].line, errors[i].message] + '') > -1
- ) {
- ok(true, 'Found error: ' + errors[i].message)
- }
- }
- })
- module('Warnings')
- test('Warning parsing', function () {
- var errors = LatexParser.parse(warningLog).warnings
- var expectedErrors = [
- [
- 7,
- "Citation `Lambert:2010iw' on page 1 undefined on input line 7.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/introduction.tex',
- ] + '',
- [
- 7,
- "Citation `Lambert:2010iw' on page 1 undefined on input line 7.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/introduction.tex',
- ] + '',
- [
- 72,
- "Citation `Manton:2004tk' on page 3 undefined on input line 72.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/instantons.tex',
- ] + '',
- [
- 108,
- "Citation `Atiyah1978' on page 4 undefined on input line 108.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/instantons.tex',
- ] + '',
- [
- 176,
- "Citation `Dorey:1996hu' on page 5 undefined on input line 176.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/instantons.tex',
- ] + '',
- [
- 3,
- "Citation `Manton1982' on page 8 undefined on input line 3.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/moduli_space_approximation.tex',
- ] + '',
- [
- 21,
- "Citation `Weinberg:2006rq' on page 9 undefined on input line 21.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/moduli_space_approximation.tex',
- ] + '',
- [
- 192,
- "Citation `Bak:1999sv' on page 12 undefined on input line 192.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/moduli_space_approximation.tex',
- ] + '',
- [
- 9,
- "Citation `Peeters:2001np' on page 13 undefined on input line 9.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/dynamics_of_single_instanton.tex',
- ] + '',
- [
- 27,
- "Citation `Osborn:1981yf' on page 15 undefined on input line 27.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/dynamics_of_two_instantons.tex',
- ] + '',
- [
- 27,
- "Citation `Peeters:2001np' on page 15 undefined on input line 27.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/dynamics_of_two_instantons.tex',
- ] + '',
- [
- 20,
- "Citation `Osborn:1981yf' on page 22 undefined on input line 20.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/appendices.tex',
- ] + '',
- [
- 103,
- "Citation `Osborn:1981yf' on page 23 undefined on input line 103.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/appendices.tex',
- ] + '',
- [
- 103,
- "Citation `Peeters:2001np' on page 23 undefined on input line 103.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/appendices.tex',
- ] + '',
- [
- 352,
- "Citation `Peeters:2001np' on page 27 undefined on input line 352.",
- 'compiles/d1585ce575dea4cab55f784a22a88652/sections/appendices.tex',
- ] + '',
- ]
- expect(expectedErrors.length)
- for (var i = 0; i < errors.length; i++) {
- if (
- expectedErrors.indexOf(
- [errors[i].line, errors[i].message, errors[i].file] + ''
- ) > -1
- ) {
- ok(true, 'Found error: ' + errors[i].message)
- }
- }
- })
- module('Biber Warnings')
- test('Biber Warning parsing', function () {
- var errors = LatexParser.parse(biberWarningsLog).warnings
- var expectedErrors = [
- [
- null,
- 'Package biblatex Warning: No "backend" specified, using Biber backend. To use BibTeX, load biblatex with the "backend=bibtex" option.',
- '/usr/local/texlive/2013/texmf-dist/tex/latex/biblatex/biblatex.sty',
- ] + '',
- [
- null,
- 'Package biblatex Warning: The following entry could not be found in the database: Missing3 Please verify the spelling and rerun LaTeX afterwards.',
- '/compile/output.bbl',
- ] + '',
- [
- null,
- 'Package biblatex Warning: The following entry could not be found in the database: Missing2 Please verify the spelling and rerun LaTeX afterwards.',
- '/compile/output.bbl',
- ] + '',
- [
- null,
- 'Package biblatex Warning: The following entry could not be found in the database: Missing1 Please verify the spelling and rerun LaTeX afterwards.',
- '/compile/output.bbl',
- ] + '',
- ]
- expect(expectedErrors.length)
- for (var i = 0; i < errors.length; i++) {
- if (
- expectedErrors.indexOf(
- [errors[i].line, errors[i].message, errors[i].file] + ''
- ) > -1
- ) {
- ok(true, 'Found error: ' + errors[i].message)
- } else {
- ok(false, 'Unexpected error found: ' + errors[i].message)
- }
- }
- })
- module('Natbib Warnings')
- test('Natbib Warning parsing', function () {
- var errors = LatexParser.parse(natbibWarningsLog).warnings
- var expectedErrors = [
- [
- 6,
- "Package natbib Warning: Citation `blah' on page 1 undefined on input line 6.",
- '/compile/main.tex',
- ] + '',
- [
- null,
- 'Package natbib Warning: There were undefined citations.',
- '/compile/main.tex',
- ] + '',
- ]
- expect(expectedErrors.length)
- for (var i = 0; i < errors.length; i++) {
- if (
- expectedErrors.indexOf(
- [errors[i].line, errors[i].message, errors[i].file] + ''
- ) > -1
- ) {
- ok(true, 'Found error: ' + errors[i].message)
- } else {
- ok(false, 'Unexpected error found: ' + errors[i].message)
- }
- }
- })
- module('Geometry Warnings')
- test('Geometry Warning parsing', function () {
- var errors = LatexParser.parse(geometryWarningsLog).warnings
- var expectedErrors = [
- [
- null,
- "Package geometry Warning: Over-specification in `h'-direction. `width' (597.50787pt) is ignored.",
- '/compile/main.tex',
- ] + '',
- [
- null,
- "Package geometry Warning: Over-specification in `v'-direction. `height' (845.04684pt) is ignored.",
- '/compile/main.tex',
- ] + '',
- ]
- expect(expectedErrors.length)
- for (var i = 0; i < errors.length; i++) {
- if (
- expectedErrors.indexOf(
- [errors[i].line, errors[i].message, errors[i].file] + ''
- ) > -1
- ) {
- ok(true, 'Found error: ' + errors[i].message)
- } else {
- ok(false, 'Unexpected error found: ' + errors[i].message)
- }
- }
- })
- module('Caption Warnings')
- test('Caption Warning parsing', function () {
- var errors = LatexParser.parse(captionWarningsLog).warnings
- var expectedErrors = [
- [
- null,
- 'Package caption Warning: Unsupported document class (or package) detected, usage of the caption package is not recommended. See the caption package documentation for explanation.',
- '/usr/local/texlive/2014/texmf-dist/tex/latex/caption/caption.sty',
- ] + '',
- [
- 46,
- "Package caption Warning: The option `hypcap=true' will be ignored for this particular \\caption on input line 46. See the caption package documentation for explanation.",
- '/compile/main.tex',
- ] + '',
- ]
- expect(expectedErrors.length)
- for (var i = 0; i < errors.length; i++) {
- if (
- expectedErrors.indexOf(
- [errors[i].line, errors[i].message, errors[i].file] + ''
- ) > -1
- ) {
- ok(true, 'Found error: ' + errors[i].message)
- } else {
- ok(false, 'Unexpected error found: ' + errors[i].message)
- }
- }
- })
- module('Runaway Arguments')
- test('Runaway Arguments parsing', function () {
- var errors = LatexParser.parse(runawayArgumentsLog).errors
- var expectedErrors = [
- [null, 'Runaway argument?', '/compile/runaway_argument.tex'] + '',
- [null, 'Emergency stop.', '/compile/runaway_argument.tex'] + '',
- ]
- expect(expectedErrors.length)
- for (var i = 0; i < errors.length; i++) {
- if (
- expectedErrors.indexOf(
- [errors[i].line, errors[i].message, errors[i].file] + ''
- ) > -1
- ) {
- ok(true, 'Found error: ' + errors[i].message)
- } else {
- ok(false, 'Unexpected error found: ' + errors[i].message)
- }
- }
- })
- module('Filename Errors')
- test('Filename parsing', function () {
- var { errors, warnings, typesetting } = LatexParser.parse(filenamesLog)
- var expectedErrors = [
- [
- 1,
- 'Undefined control sequence.',
- '/compile/a folder with spaces/a subfolder with spaces/a subsubfolder with spaces/another file with spaces.tex',
- ] + '',
- ]
- var expectedWarnings = [
- [
- 9,
- "Citation `Peeters:2001np' on page 13 undefined on input line 9.",
- '/compile/main',
- ] + '',
- ]
- var expectedTypesetting = [
- [
- 123,
- 'Overfull \\hbox (4.56pt too wide) in paragraph at lines 123--456',
- '/compile/otherfile',
- ] + '',
- ]
- expect(
- expectedErrors.length +
- expectedWarnings.length +
- expectedTypesetting.length
- )
- for (var i = 0; i < errors.length; i++) {
- if (
- expectedErrors.indexOf(
- [errors[i].line, errors[i].message, errors[i].file] + ''
- ) > -1
- ) {
- ok(true, 'Found error: ' + errors[i].message)
- } else {
- ok(false, 'Unexpected error found: ' + errors[i].message)
- }
- }
- for (var i = 0; i < warnings.length; i++) {
- if (
- expectedWarnings.indexOf(
- [warnings[i].line, warnings[i].message, warnings[i].file] + ''
- ) > -1
- ) {
- ok(true, 'Found error: ' + warnings[i].message)
- } else {
- ok(false, 'Unexpected error found: ' + warnings[i].message)
- }
- }
- for (var i = 0; i < typesetting.length; i++) {
- if (
- expectedTypesetting.indexOf(
- [typesetting[i].line, typesetting[i].message, typesetting[i].file] +
- ''
- ) > -1
- ) {
- ok(true, 'Found error: ' + typesetting[i].message)
- } else {
- ok(false, 'Unexpected error found: ' + typesetting[i].message)
- }
- }
- })
- module('File Line Errors')
- test('File line error parsing', function () {
- var errors = LatexParser.parse(fileLineErrorLog).errors
- var expectedErrors = [
- [
- 1,
- 'Undefined control sequence.',
- '/compile/a folder with spaces/a subfolder with spaces/a subsubfolder with spaces/another file with spaces.tex',
- ] + '',
- ]
- expect(expectedErrors.length)
- for (var i = 0; i < errors.length; i++) {
- if (
- expectedErrors.indexOf(
- [errors[i].line, errors[i].message, errors[i].file] + ''
- ) > -1
- ) {
- ok(true, 'Found error: ' + errors[i].message)
- } else {
- ok(false, 'Unexpected error found: ' + errors[i].message)
- }
- }
- })
- module('General')
- test('Ignore Duplicates', function () {
- var errors = LatexParser.parse(errorLog).errors
- equal(errors.length, 10, 'Duplicates included')
- errors = LatexParser.parse(errorLog, { ignoreDuplicates: true }).errors
- equal(errors.length, 7, 'Duplicates ignored')
- })
- test('File paths', function () {
- var errors = LatexParser.parse(errorLog).errors
- for (var i = 0; i < errors.length; i++) {
- equal(
- errors[i].file,
- 'compiles/dff0c37d892f346e58fc14975a16bf69/sections/appendices.tex',
- 'File path correct'
- )
- }
- errors = LatexParser.parse(badBoxesLog).all
- for (var i = 0; i < errors.length; i++) {
- equal(
- errors[i].file,
- 'compiles/b6cf470376785e64ad84c57e3296c912/logs/bad-boxes.tex',
- 'File path correct'
- )
- }
- })
- // biber-log-parser
- module('BibLogParser')
- test('Typical biber .blg file', function () {
- var result = BibLogParser.parse(biberBlg, {})
- equal(typeof result, 'object')
- equal(result.all.length, 14)
- equal(result.errors.length, 1)
- equal(result.warnings.length, 2)
- var error = result.errors[0]
- equal(error.level, 'error')
- equal(error.line, '8')
- equal(error.file, 'bibliography.bib')
- equal(
- error.message,
- 'syntax error: at end of input, expected end of entry ("}" or ")") (skipping to next "@")'
- )
- })
- test('Not a .blg file', function () {
- try {
- var result = BibLogParser.parse(captionWarningsLog)
- } catch (e) {
- ok(true, 'Should throw an error')
- }
- })
- test('Empty string', function () {
- try {
- var result = BibLogParser.parse('')
- } catch (e) {
- ok(true, 'Should throw an error')
- }
- })
- test('Not a string', function () {
- try {
- var result = BibLogParser.parse({ a: 1 })
- } catch (e) {
- ok(true, 'Should throw an error')
- }
- })
- test('typical bibtex .blg file', function () {
- var result = BibLogParser.parse(bibtexBlg, {})
- equal(typeof result, 'object')
- equal(result.all.length, 13)
- equal(result.warnings.length, 6)
- var firstWarning = result.warnings[0]
- equal(firstWarning.file, 'references.bib')
- equal(firstWarning.line, '152')
- equal(firstWarning.level, 'warning')
- equal(firstWarning.message, 'string name "something" is undefined')
- var thirdWarning = result.warnings[2]
- equal(
- thirdWarning.message,
- "can't use both author and editor fields in Binney87"
- )
- equal(result.errors.length, 7)
- var firstError = result.errors[0]
- equal(firstError.file, 'references.bib')
- equal(firstError.line, '196')
- equal(firstError.level, 'error')
- equal(firstError.message.indexOf("I was expecting a `,' or a `}'"), 0)
- equal(
- firstError.message.indexOf('(Error may have been on previous line)') > 0,
- true
- )
- var crossReferenceError = result.errors[5]
- equal(crossReferenceError.level, 'error')
- equal(crossReferenceError.message.indexOf('A bad cross reference'), 0)
- var styleError = result.errors[6]
- equal(styleError.level, 'error')
- equal(styleError.message.indexOf("I couldn't open style file aa.bst"), 0)
- })
- })
|