5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Verify that sections of LaTeX output that use auxiliary files (a
29 bibliography in our configuration below) are consistent when re-run
30 after modifying the input file.
32 This checks for a bug that was triggered by the presence of auxiliary
33 files which were detected by SCons but then removed prior to invoking
34 TeX, causing the auxiliary sections to be excluded from the output.
35 That was fixed (courtesy Joel B. Mohler) by making all the relevant
36 auxiliary files Precious().
38 Test configuration courtesy Dmitry Mikhin.
43 test = TestSCons.TestSCons()
45 dvips = test.where_is('dvips')
46 latex = test.where_is('latex')
48 if not dvips or not latex:
49 test.skip_test("Could not find dvips or latex; skipping test(s).\n")
54 test.write(['SConstruct'], """\
55 env = Environment(tools = ['pdftex', 'dvipdf', 'dvips', 'tex', 'latex'],
57 BUILD_DIR = '#build/docs')
59 # Use 'duplicate=1' because LaTeX toolchain does not work properly for
60 # input/output files outside of the current directory
62 env.VariantDir('$BUILD_DIR', 'docs', duplicate=1)
63 env.SConscript('$BUILD_DIR/SConscript', exports = ['env'])
66 test.write(['docs', 'SConscript'], """\
70 test_dvi = envc.DVI(source='test.tex')
71 test_ps = envc.PostScript(source='test.tex')
72 test_pdf = envc.PDF(source='test.tex')
74 envc.Default(test_dvi)
76 envc.Default(test_pdf)
79 test.write(['docs', 'my.bib'], """\
81 author = "Dmitry {\uppercase{Y}u}. Mikhin",
83 journal = "Some yellow paper",
91 tex_input = r"""\documentclass{article}
95 \author{Dmitry Yu. Mikhin}
103 \noindent A bug in BibTeX processing?
107 \section{The problem}
109 Provide a citation here: \cite{Mikhin}.
113 \bibliographystyle{unsrtnat}
118 test.write(['docs', 'test.tex'], tex_input)
120 test.run(stderr=None)
122 pdf_output_1 = test.read(['build', 'docs', 'test.pdf'])
123 ps_output_1 = test.read(['build', 'docs', 'test.ps'])
125 # Adding blank lines will cause SCons to re-run the builds, but the
126 # actual contents of the output files should be the same modulo
127 # the CreationDate header and some other PDF garp.
128 test.write(['docs', 'test.tex'], tex_input + "\n\n\n")
130 test.run(stderr=None)
132 pdf_output_2 = test.read(['build', 'docs', 'test.pdf'])
133 ps_output_2 = test.read(['build', 'docs', 'test.ps'])
137 pdf_output_1 = test.normalize_pdf(pdf_output_1)
138 pdf_output_2 = test.normalize_pdf(pdf_output_2)
140 if pdf_output_1 != pdf_output_2:
142 test.write(['build', 'docs', 'test.normalized.1.pdf'], pdf_output_1)
143 test.write(['build', 'docs', 'test.normalized.2.pdf'], pdf_output_2)
144 sys.stdout.write("***** 1.pdf and 2.pdf are different!\n")
145 sys.stdout.write(test.diff_substr(pdf_output_1, pdf_output_2, 80, 80) + '\n')
146 sys.stdout.write("Output from run 1:\n")
147 sys.stdout.write(test.stdout(-1) + '\n')
148 sys.stdout.write("Output from run 2:\n")
149 sys.stdout.write(test.stdout() + '\n')
153 if ps_output_1 != ps_output_2:
155 sys.stdout.write("***** 1.ps and 2.ps are different!\n")
156 sys.stdout.write(test.diff_substr(ps_output_1, ps_output_2, 80, 80) + '\n')
157 sys.stdout.write("Output from run 1:\n")
158 sys.stdout.write(test.stdout(-1) + '\n')
159 sys.stdout.write("Output from run 2:\n")
160 sys.stdout.write(test.stdout() + '\n')