Variables testing: confirm space-containing values
[scons.git] / test / TEX / recursive_scanner_dependencies_input.py
blob5afcbc26141b458c8ef99c8ec2a9c7c221ebf762
1 #!/usr/bin/env python
3 # __COPYRIGHT__
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__"
27 r"""
28 Verify that we re-run LaTeX after changing a nested \input. This
29 checks that recursive implicit dependencies are found correctly.
30 """
32 import TestSCons
34 test = TestSCons.TestSCons()
36 pdflatex = test.where_is('pdflatex')
38 if not pdflatex:
39 test.skip_test("Could not find 'pdflatex'; skipping test(s).\n")
41 test.write(['SConstruct'], """\
42 env = Environment(tools=['pdftex', 'tex'])
43 env.PDF('master.tex')
44 """)
46 test.write(['master.tex'], r"""
47 \documentclass{article}
48 \begin{document}
49 \input{sub1}
50 \end{document}
51 """)
53 test.write(['sub1.tex'], r"""
54 \input{sub2}
55 """)
57 test.write(['sub2.tex'], r"""
58 Sub-document 2 content
59 """)
61 test.run()
63 pdf_output_1 = test.read('master.pdf')
65 # Change sub2.tex, see if master.pdf is changed
66 test.write(['sub2.tex'], r"""
67 Sub-document 2 content -- updated
68 """)
70 test.run()
72 pdf_output_2 = test.read('master.pdf')
74 # If the PDF file is the same as it was previously, then it didn't
75 # pick up the change in sub2.tex, so fail.
76 test.fail_test(pdf_output_1 == pdf_output_2)
78 # Double-check: clean everything and rebuild from scratch, which
79 # should force the PDF file to be the 1982 version.
81 test.run(arguments='-c')
82 test.run()
84 pdf_output_3 = test.read('master.pdf')
86 # If the PDF file is now different than the second run, modulo the
87 # creation timestamp and the ID and some other PDF garp, then something
88 # else odd has happened, so fail.
90 pdf_output_2 = test.normalize_pdf(pdf_output_2)
91 pdf_output_3 = test.normalize_pdf(pdf_output_3)
93 if pdf_output_2 != pdf_output_3:
94 import sys
95 test.write('master.normalized.2.pdf', pdf_output_2)
96 test.write('master.normalized.3.pdf', pdf_output_3)
97 sys.stdout.write("***** 2 and 3 are different!\n")
98 sys.stdout.write(test.diff_substr(pdf_output_2, pdf_output_3, 80, 80)
99 + '\n')
100 sys.stdout.write("Output from run 2:\n")
101 sys.stdout.write(test.stdout(-2) + '\n')
102 sys.stdout.write("Output from run 3:\n")
103 sys.stdout.write(test.stdout() + '\n')
104 sys.stdout.flush()
105 test.fail_test()
107 test.pass_test()
109 # Local Variables:
110 # tab-width:4
111 # indent-tabs-mode:nil
112 # End:
113 # vim: set expandtab tabstop=4 shiftwidth=4: