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 we re-run LaTeX when a source file in \lstinputlisting
31 Thanks to Stefan Hepp for the patch that fixed this.
36 test = TestSCons.TestSCons()
38 pdflatex = test.where_is('pdflatex')
41 test.skip_test("Could not find pdflatex; skipping test(s).\n")
43 test.write(['SConstruct'], """\
46 DefaultEnvironment(ENV={'PATH':os.environ['PATH']})
51 test.write(['test.tex'], r"""
52 \documentclass{article}
59 \lstinputlisting{test.c}
65 int main(int argc, char** argv) {
72 test.write('test.c', source_content % '0')
76 pdf_output_1 = test.read('test.pdf')
80 test.write('test.c', source_content % '1')
84 pdf_output_2 = test.read('test.pdf')
86 # If the PDF file is the same as it was previously, then it didn't
87 # pick up the change from 1981 to 1982, so fail.
88 test.fail_test(pdf_output_1 == pdf_output_2)
92 # Double-check: clean everything and rebuild from scratch, which
93 # should force the PDF file to be the 1982 version.
95 test.run(arguments = '-c')
99 pdf_output_3 = test.read('test.pdf')
103 # If the PDF file is now different than the second run, modulo the
104 # creation timestamp and the ID and some other PDF garp, then something
105 # else odd has happened, so fail.
107 pdf_output_2 = test.normalize_pdf(pdf_output_2)
108 pdf_output_3 = test.normalize_pdf(pdf_output_3)
110 if pdf_output_2 != pdf_output_3:
112 test.write('test.normalized.2.pdf', pdf_output_2)
113 test.write('test.normalized.3.pdf', pdf_output_3)
114 sys.stdout.write("***** 2 and 3 are different!\n")
115 sys.stdout.write(test.diff_substr(pdf_output_2, pdf_output_3, 80, 80) + '\n')
116 sys.stdout.write("Output from run 2:\n")
117 sys.stdout.write(test.stdout(-2) + '\n')
118 sys.stdout.write("Output from run 3:\n")
119 sys.stdout.write(test.stdout() + '\n')
129 # indent-tabs-mode:nil
131 # vim: set expandtab tabstop=4 shiftwidth=4: