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'], """\
56 env = Environment(tools = ['pdftex', 'dvipdf', 'dvips', 'tex', 'latex'],
57 ENV = {'PATH' : os.environ['PATH']},
58 BUILD_DIR = '#build/docs')
60 # Use 'duplicate=1' because LaTeX toolchain does not work properly for
61 # input/output files outside of the current directory
63 env.VariantDir('$BUILD_DIR', 'docs', duplicate=1)
64 env.SConscript('$BUILD_DIR/SConscript', exports = ['env'])
67 test.write(['docs', 'SConscript'], """\
71 test_dvi = envc.DVI(source='test.tex')
72 test_ps = envc.PostScript(source='test.tex')
73 test_pdf = envc.PDF(source='test.tex')
75 envc.Default(test_dvi)
77 envc.Default(test_pdf)
80 test.write(['docs', 'my.bib'], """\
82 author = "Dmitry {\uppercase{Y}u}. Mikhin",
84 journal = "Some yellow paper",
92 tex_input = r"""\documentclass{article}
96 \author{Dmitry Yu. Mikhin}
104 \noindent A bug in BibTeX processing?
108 \section{The problem}
110 Provide a citation here: \cite{Mikhin}.
114 \bibliographystyle{unsrtnat}
119 test.write(['docs', 'test.tex'], tex_input)
121 test.run(stderr=None)
123 pdf_output_1 = test.read(['build', 'docs', 'test.pdf'])
124 ps_output_1 = test.read(['build', 'docs', 'test.ps'])
126 # Adding blank lines will cause SCons to re-run the builds, but the
127 # actual contents of the output files should be the same modulo
128 # the CreationDate header and some other PDF garp.
129 test.write(['docs', 'test.tex'], tex_input + "\n\n\n")
131 test.run(stderr=None)
133 pdf_output_2 = test.read(['build', 'docs', 'test.pdf'])
134 ps_output_2 = test.read(['build', 'docs', 'test.ps'])
138 pdf_output_1 = test.normalize_pdf(pdf_output_1)
139 pdf_output_2 = test.normalize_pdf(pdf_output_2)
141 if pdf_output_1 != pdf_output_2:
143 test.write(['build', 'docs', 'test.normalized.1.pdf'], pdf_output_1)
144 test.write(['build', 'docs', 'test.normalized.2.pdf'], pdf_output_2)
145 sys.stdout.write("***** 1.pdf and 2.pdf are different!\n")
146 sys.stdout.write(test.diff_substr(pdf_output_1, pdf_output_2, 80, 80) + '\n')
147 sys.stdout.write("Output from run 1:\n")
148 sys.stdout.write(test.stdout(-1) + '\n')
149 sys.stdout.write("Output from run 2:\n")
150 sys.stdout.write(test.stdout() + '\n')
154 if ps_output_1 != ps_output_2:
156 sys.stdout.write("***** 1.ps and 2.ps are different!\n")
157 sys.stdout.write(test.diff_substr(ps_output_1, ps_output_2, 80, 80) + '\n')
158 sys.stdout.write("Output from run 1:\n")
159 sys.stdout.write(test.stdout(-1) + '\n')
160 sys.stdout.write("Output from run 2:\n")
161 sys.stdout.write(test.stdout() + '\n')