tests/executable.rs: add a multi-bibtex executable test

This commit is contained in:
Peter Williams 2022-06-29 23:48:17 -04:00
parent 2a65aa75eb
commit e25f3aac0e
4 changed files with 88 additions and 1 deletions

View File

@ -1,4 +1,4 @@
// Copyright 2016-2021 the Tectonic Project
// Copyright 2016-2022 the Tectonic Project
// Licensed under the MIT License.
use lazy_static::lazy_static;
@ -448,6 +448,18 @@ fn biber_issue_844() {
assert_eq!(stat.len(), contents.len() as u64);
}
/// Fakily testing the bibtex implementation even though we don't have LaTeX.
/// This implementation is strongly cribbed from the biber tests, which came
/// first.
#[test]
fn bibtex_multiple_aux_files() {
let fmt_arg = get_plain_format_arg();
let tempdir =
setup_and_copy_files(&["bibtex_multiple_aux_files.tex", "refs.bib", "catchkey.bst"]);
let output = run_tectonic(tempdir.path(), &[&fmt_arg, "bibtex_multiple_aux_files.tex"]);
success_or_panic(&output);
}
#[test]
fn help_flag() {
let output = run_tectonic(&PathBuf::from("."), &["-h"]);

View File

@ -0,0 +1,53 @@
% Test if we're on the second pass by seeing if the BBL already exists
\newif\ifsecond
\newread\r
\openin\r=bibtex_multiple_aux_files.bbl
\ifeof\r
\message{first pass}
\secondfalse
\else
\message{second pass}
\secondtrue
\closein\r
\fi
% Now create first .aux
\newwrite\w
\immediate\openout\w=bibtex_multiple_aux_files.aux\relax
\immediate\write\w{\string\bibdata{refs}}
\immediate\write\w{\string\citation{refA}}
\immediate\write\w{\string\bibstyle{catchkey}}
\immediate\closeout\w
% Second .aux
\immediate\openout\w=secondary.aux\relax
\immediate\write\w{\string\bibdata{refs}}
\immediate\write\w{\string\citation{refB}}
\immediate\write\w{\string\bibstyle{catchkey}}
\immediate\closeout\w
hello
% catchkey.bst emits a command `\saw$KEY` for each key it sees. So
% we can check that we got keys from both files like so:
\newif\ifrefA
\refAfalse
\newif\ifrefB
\refBfalse
\ifsecond
\let\sawrefA=\refAtrue
\let\sawrefB=\refBtrue
\input{bibtex_multiple_aux_files.bbl}
\input{secondary.bbl}
\ifrefA\else
\didnotseerefA
\fi
\ifrefB\else
\didnotseerefB
\fi
\fi
\bye

View File

@ -0,0 +1,11 @@
ENTRY { author title year } {} {}
FUNCTION { misc }
{
"\saw" write$
cite$ write$
newline$
}
READ
ITERATE {call.type$}

11
tests/executable/refs.bib Normal file
View File

@ -0,0 +1,11 @@
@misc{refA,
author="No Body",
title="An Article",
year="2020"
}
@misc{refB,
author="An Other",
title="Rebuttal",
year="2021"
}