Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 // testing ../../../tools/addlatexhash.dart | 6 // testing ../../../tools/addlatexhash.dart |
| 7 | 7 |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
| 10 import '../../../tools/addlatexhash.dart'; | 10 import '../../../tools/addlatexhash.dart'; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 oneTestSisp(sispIsDartBegin, "Begin", "whatever else ..", false); | 52 oneTestSisp(sispIsDartBegin, "Begin", "whatever else ..", false); |
| 53 oneTestSisp(sispIsDartEnd, "End", "\\end{dartCode}", true); | 53 oneTestSisp(sispIsDartEnd, "End", "\\end{dartCode}", true); |
| 54 oneTestSisp(sispIsDartEnd, "End", " \\end{dartCode}\t \n", true); | 54 oneTestSisp(sispIsDartEnd, "End", " \\end{dartCode}\t \n", true); |
| 55 oneTestSisp(sispIsDartEnd, "End", "whatever else ..", false); | 55 oneTestSisp(sispIsDartEnd, "End", "whatever else ..", false); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Check that the hash values of paragraphs in the specially prepared | 58 // Check that the hash values of paragraphs in the specially prepared |
| 59 // LaTeX source 'addlatexhash_test_src.tex' are identical in groups | 59 // LaTeX source 'addlatexhash_test_src.tex' are identical in groups |
| 60 // of eight (so we get 8 identical hash values, then another hash | 60 // of eight (so we get 8 identical hash values, then another hash |
| 61 // value 8 times, etc.) | 61 // value 8 times, etc.) |
| 62 testSameHash() { | 62 testSameHash(String tmpDirPath) { |
| 63 // set up temporary directory to hold output | |
| 64 final tmpDir = Directory.systemTemp.createTempSync("addlatexhash_test"); | |
| 65 final tmpDirPath = tmpDir.path; | |
| 66 | |
| 67 // file names/paths for file containing groups of 8 variants of a paragraph | 63 // file names/paths for file containing groups of 8 variants of a paragraph |
| 68 const par8timesName = "addlatexhash_test_src"; | 64 const par8timesName = "addlatexhash_test_src"; |
| 69 const par8timesFileName = "$par8timesName.tex"; | 65 const par8timesFileName = "$par8timesName.tex"; |
| 70 final par8timesDirPath = path.join(dartRootDir, "tests", "standalone", "io"); | 66 final par8timesDirPath = path.join(dartRootDir, "tests", "standalone", "io"); |
| 71 final par8timesPath = path.join(par8timesDirPath, par8timesFileName); | 67 final par8timesPath = path.join(par8timesDirPath, par8timesFileName); |
| 72 final tmpPar8timesPath = path.join(tmpDirPath, par8timesFileName); | 68 final tmpPar8timesPath = path.join(tmpDirPath, par8timesFileName); |
| 73 | 69 |
| 74 // file names paths for output | 70 // file names paths for output |
| 75 final hashName = par8timesName + "-hash"; | 71 final hashName = par8timesName + "-hash"; |
| 76 final hashFileName = "$hashName.tex"; | 72 final hashFileName = "$hashName.tex"; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 } else { | 109 } else { |
| 114 sameCount++; | 110 sameCount++; |
| 115 } | 111 } |
| 116 } | 112 } |
| 117 } | 113 } |
| 118 | 114 |
| 119 // Check that the LaTeX source transformation done by addlatexhash.dart | 115 // Check that the LaTeX source transformation done by addlatexhash.dart |
| 120 // does not affect the generated output, as seen via dvi2tty and diff. | 116 // does not affect the generated output, as seen via dvi2tty and diff. |
| 121 // NB: Not part of normal testing (only local): latex and dvi2tty are | 117 // NB: Not part of normal testing (only local): latex and dvi2tty are |
| 122 // not installed in the standard test environment. | 118 // not installed in the standard test environment. |
| 123 testSameDVI() { | 119 testSameDVI(String tmpDirPath) { |
| 124 // set up /tmp directory to hold output | |
| 125 final tmpDir = Directory.systemTemp.createTempSync("addlatexhash_test"); | |
| 126 final tmpDirPath = tmpDir.path; | |
| 127 | |
| 128 // file names/paths for original spec | 120 // file names/paths for original spec |
| 129 const specName = "dartLangSpec"; | 121 const specName = "dartLangSpec"; |
| 130 const specFileName = "$specName.tex"; | 122 const specFileName = "$specName.tex"; |
| 131 final specDirPath = path.join(dartRootDir, "docs", "language"); | 123 final specDirPath = path.join(dartRootDir, "docs", "language"); |
| 132 final specPath = path.join(specDirPath, specFileName); | 124 final specPath = path.join(specDirPath, specFileName); |
| 133 final tmpSpecPath = path.join(tmpDirPath, specFileName); | 125 final tmpSpecPath = path.join(tmpDirPath, specFileName); |
| 134 const specDviFileName = "$specName.dvi"; | 126 const specDviFileName = "$specName.dvi"; |
| 135 final specDviPath = path.join(tmpDirPath, specDviFileName); | 127 final specDviPath = path.join(tmpDirPath, specDviFileName); |
| 136 | 128 |
| 137 // file names/paths for associated sty | 129 // file names/paths for associated sty |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 checkAction(runLatex(hashFileName, tmpDirPath), "LaTeX on output failed"); | 177 checkAction(runLatex(hashFileName, tmpDirPath), "LaTeX on output failed"); |
| 186 } | 178 } |
| 187 if (chkDvi2tty(specDviPath, "spec") != chkDvi2tty(hashDviPath, "output")) { | 179 if (chkDvi2tty(specDviPath, "spec") != chkDvi2tty(hashDviPath, "output")) { |
| 188 throw "dvi2tty spec != dvitty output"; | 180 throw "dvi2tty spec != dvitty output"; |
| 189 } | 181 } |
| 190 } | 182 } |
| 191 | 183 |
| 192 main([args]) { | 184 main([args]) { |
| 193 testCutMatch(); | 185 testCutMatch(); |
| 194 testSisp(); | 186 testSisp(); |
| 195 testSameHash(); | 187 |
| 188 final tmpDir = Directory.systemTemp.createTempSync("addlatexhash_test"); | |
| 189 try { | |
| 190 testSameHash(tmpDir.path); | |
| 191 } finally { | |
| 192 tmpDir.delete(recursive: true); | |
| 193 } | |
| 196 // latex and dvi2tty are not installed in the standard test environment | 194 // latex and dvi2tty are not installed in the standard test environment |
| 197 if (args.length > 0 && args[0] == "local") testSameDVI(); | 195 if (args.length > 0 && args[0] == "local") { |
| 196 final dviDir = Directory.systemTemp.createTempSync("addlatexhash_test"); | |
| 197 try { | |
| 198 testSameDVI(dviDir.path); | |
| 199 } finally { | |
| 200 dviDir.delete(recursive: true); | |
| 201 } | |
| 202 } | |
|
eernst
2015/01/28 13:04:35
Ah, of course I should have removed those tmp file
| |
| 198 } | 203 } |
| OLD | NEW |