# SCons / test / TEX / multi-run.py

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 #!/usr/bin/env python # # __COPYRIGHT__ # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Validate that both .tex and .ltx files can handle a LaTeX-style bibliography (by calling $BIBTEX to generate a .bbl file) and correctly re-run to resolve undefined references. Also verifies that package warnings are caught and re-run as needed. """ import string import TestSCons test = TestSCons.TestSCons() tex = test.where_is('tex') latex = test.where_is('latex') if not tex and not latex: test.skip_test("Could not find tex or latex; skipping test(s).\n") test.subdir('work1', 'work2', 'work3', 'work4') input_file = r""" \documentclass{article} \begin{document} As stated in \cite{X}, this is a bug-a-boo. \bibliography{fooref} \bibliographystyle{plain} \end{document} """ input_file2 = r""" \documentclass{article} \begin{document} Hello world. % \bibliography{fooref} % \bibliographystyle{plain} \end{document} """ input_file3 = r""" \documentclass{article} \usepackage{longtable} \begin{document} As stated in the last paper, this is a bug-a-boo. here is some more junk and another table here is some more junk and another table \begin{longtable}[l]{rlll} Isotope &\multicolumn{1}{c}{Abar} &Name\\ \\ 1001 &1.0078 &Proton &$p$\\ 1002 &2.0141 &Deuterium &$d$\\ 1003 &3.0170 &Tritium &$t$\\ 2003 &3.0160 &Helium 3 &He$^3$\\ 2004 &4.0026 &Helium 4 &He$^{4}\$\\ \end{longtable} and a closing comment These parameters and arrays are filled in when the parameter \textbf{iftnrates} is set to 1: \begin{longtable}[l]{ll} \\ \textbf{nxxxx} &Total number of particles made by xxxx reaction\\ \textbf{pxxxx} &Total number of particles made by xxxx reaction\\ \textbf{nxxxxx} &Total number of particles made by xxxxx reaction\\ \textbf{nxxxx} &Total number of particles made by xxxx reaction\\ \textbf{pxxxx} &Total number of particles made by xxxx reaction\\ \textbf{nxxxx} &Total number of particles made by xxxx reaction\\ \textbf{pxxxx} &Total number of particles made by xxxx reaction\\ \textbf{nxxxxx} &Total number of particles made by xxxxx reaction\\ \textbf{nxxxx} &Total number of particles made by xxxx reaction\\ \textbf{pxxxx} &Total number of particles made by xxxx reaction\\ \\ \textbf{rnxxxx} &Regional total of particles made by xxxx reaction\\ \textbf{rpxxxx} &Regional total of particles made by xxxx reaction\\ \textbf{rnxxxxx} &Regional total of particles made by xxxxx reaction\\ \textbf{rnxxxx} &Regional total of particles made by xxxx reaction\\ \textbf{rpxxxx} &Regional total of particles made by xxxx reaction\\ \textbf{rnxxxx} &Regional total of particles made by xxxx reaction\\ \textbf{rpxxxx} &Regional total of particles made by xxxx reaction\\ \textbf{rnxxxxx} &Regional total of particles made by xxxxx reaction\\ \textbf{rnxxxx} &Regional total of particles made by xxxx reaction\\ \textbf{rpxxxx} &Regional total of particles made by xxxx reaction\\ \\ \textbf{reactot}(r) &Total number of reactions for reaction r\\ \textbf{reacreg}(r,ir) &Total number of reactions for reaction r in region ir\\ \end{longtable} \end{document} """ bibfile = r""" @Article{X, author = "Mr. X", title = "A determination of bug-a-boo-ness", journal = "Journal of B.a.B.", year = 1920, volume = 62, pages = 291 } """ if tex: test.write(['work1', 'SConstruct'], """\ DVI( "foo.tex" ) PDF( "foo.tex" ) """) test.write(['work1', 'foo.tex'], input_file) test.write(['work1', 'fooref.bib'], bibfile) test.run(chdir = 'work1', arguments = '.') test.must_exist(['work1', 'foo.bbl']) foo_log = test.read(['work1', 'foo.log']) if string.find(foo_log, 'undefined references') != -1: print 'foo.log contains "undefined references":' print foo_log test.fail_test(1) test.write(['work3', 'SConstruct'], """\ DVI( "foo3.tex" ) """) test.write(['work3', 'foo3.tex'], input_file3) test.run(chdir = 'work3', arguments = '.') foo_log = test.read(['work3', 'foo3.log']) if string.find(foo_log, 'Rerun LaTeX') != -1: print 'foo.log contains "Rerun LaTeX":' print foo_log test.fail_test(1) if latex: test.write(['work2', 'SConstruct'], """\ DVI( "foo.ltx" ) PDF( "foo.ltx" ) """) test.write(['work2', 'foo.ltx'], input_file) test.write(['work2', 'fooref.bib'], bibfile) test.run(chdir = 'work2', arguments = '.') test.must_exist(['work2', 'foo.bbl']) foo_log = test.read(['work2', 'foo.log']) if string.find(foo_log, 'undefined references') != -1: print 'foo.log contains "undefined references":' print foo_log test.fail_test(1) test.write(['work3', 'SConstruct'], """\ DVI( "foo3.tex" ) PDF( "foo3.tex" ) """) test.write(['work3', 'foo3.tex'], input_file3) test.run(chdir = 'work3', arguments = '.') foo_log = test.read(['work3', 'foo3.log']) if string.find(foo_log, 'Rerun LaTeX') != -1: print 'foo.log contains "Rerun LaTeX":' print foo_log test.fail_test(1) test.write(['work4', 'SConstruct'], """\ DVI( "foo.ltx" ) """) test.write(['work4', 'foo.ltx'], input_file2) test.run(chdir = 'work4', arguments = '.') test.up_to_date(chdir = 'work4', arguments = '.') test.pass_test()