| Index: tests/standalone/io/addlatexhash_test.dart
|
| diff --git a/tests/standalone/io/addlatexhash_test.dart b/tests/standalone/io/addlatexhash_test.dart
|
| index 98f1ba52be528e5aff4420054da4f03526ccfceb..286563e63fb9dc64530f1ece59d63f79f5f6f5a2 100644
|
| --- a/tests/standalone/io/addlatexhash_test.dart
|
| +++ b/tests/standalone/io/addlatexhash_test.dart
|
| @@ -54,11 +54,64 @@ testSisp() {
|
| oneTestSisp(sispIsDartEnd, "End", "whatever else ..", false);
|
| }
|
|
|
| +// Check that the hash values of paragraphs in the specially prepared
|
| +// LaTeX source 'addlatexhash_test_src.tex' are identical in groups
|
| +// of eight (so we get 8 identical hash values, then another hash
|
| +// value 8 times, etc.)
|
| +testSameHash() {
|
| + // set up /tmp directory to hold output
|
| + final tmpDir = Directory.systemTemp.createTempSync("addlatexhash_test");
|
| + final tmpDirPath = tmpDir.path;
|
| +
|
| + // file names/paths for file containing groups of 8 variants of a paragraph
|
| + const par8timesName = "addlatexhash_test_src";
|
| + const par8timesFileName = "$par8timesName.tex";
|
| + final par8timesDirPath = path.join(dartRootDir, "tests", "standalone", "io");
|
| + final par8timesPath = path.join(par8timesDirPath, par8timesFileName);
|
| + final tmpPar8timesPath = path.join(tmpDirPath, par8timesFileName);
|
| +
|
| + // file names paths for output
|
| + final hashName = par8timesName + "-hash";
|
| + final hashFileName = "$hashName.tex";
|
| + final hashPath = path.join(tmpDirPath, hashFileName);
|
| + final listName = par8timesName + "-list";
|
| + final listFileName = "$listName.txt";
|
| + final listPath = path.join(tmpDirPath, listFileName);
|
| +
|
| + // actions to take
|
| + runAddHash() =>
|
| + Process.runSync("dart",
|
| + [path.join(dartRootPath, "tools", "addlatexhash.dart"),
|
| + tmpPar8timesPath,
|
| + hashPath,
|
| + listPath]);
|
| +
|
| + // perform test
|
| + new File(par8timesPath).copySync(tmpPar8timesPath);
|
| + checkAction(runAddHash(), "addlatexhash.dart failed");
|
| + var listFile = new File(listPath);
|
| + var listLines = listFile.readAsLinesSync();
|
| + var latestLine = null;
|
| + var sameCount = 0;
|
| + for (var line in listLines) {
|
| + if (!line.startsWith(" ")) continue; // section marker
|
| + if (line.startsWith(" %")) continue; // transformed text "comment"
|
| + if (line != latestLine) {
|
| + // new hash, check for number of equal hashes, then reset
|
| + if (sameCount % 8 == 0) {
|
| + // saw zero or more blocks of 8 identical hash values: OK
|
| + latestLine = line;
|
| + sameCount = 1;
|
| + } else throw "normalization failed to produce same result";
|
| + } else sameCount++;
|
| + }
|
| +}
|
| +
|
| // Check that the LaTeX source transformation done by addlatexhash.dart
|
| // does not affect the generated output, as seen via dvi2tty and diff.
|
| // NB: Not part of normal testing (only local): latex and dvi2tty are
|
| // not installed in the standard test environment.
|
| -testNoChange() {
|
| +testSameDVI() {
|
| // set up /tmp directory to hold output
|
| final tmpDir = Directory.systemTemp.createTempSync("addlatexhash_test");
|
| final tmpDirPath = tmpDir.path;
|
| @@ -83,6 +136,10 @@ testNoChange() {
|
| final hashPath = path.join(tmpDirPath, hashFileName);
|
| final hashDviPath = path.join(tmpDirPath, "$hashName.dvi");
|
|
|
| + final listName = specName + "-list";
|
| + final listFileName = "$listName.txt";
|
| + final listPath = path.join(tmpDirPath, listFileName);
|
| +
|
| // actions to take
|
| runLatex(fileName,workingDirectory) =>
|
| Process.runSync("latex", [fileName], workingDirectory: workingDirectory);
|
| @@ -91,7 +148,8 @@ testNoChange() {
|
| Process.runSync("dart",
|
| [path.join(dartRootPath, "tools", "addlatexhash.dart"),
|
| tmpSpecPath,
|
| - hashPath]);
|
| + hashPath,
|
| + listPath]);
|
|
|
| runDvi2tty(dviFile) =>
|
| Process.runSync("dvi2tty", [dviFile], workingDirectory: tmpDir.path);
|
| @@ -100,23 +158,28 @@ testNoChange() {
|
| checkAction(runDvi2tty(file), "dvitty on $subject failed");
|
|
|
| // perform test
|
| - new File(styPath).copySync(tmpStyPath);
|
| - new File(specPath).copySync(tmpSpecPath);
|
| - for (var i = 0; i < 5; i++) {
|
| - checkAction(runLatex(specName, tmpDirPath), "LaTeX on spec failed");
|
| - }
|
| - checkAction(runAddHash(),"addlatexhash.dart failed");
|
| - for (var i = 0; i < 5; i++) {
|
| - checkAction(runLatex(hashFileName, tmpDirPath), "LaTeX on output failed");
|
| - }
|
| - if (chkDvi2tty(specDviPath, "spec") != chkDvi2tty(hashDviPath, "output")) {
|
| - throw "dvi2tty spec != dvitty output";
|
| - }
|
| + var tmpStyFile = new File(styPath).copySync(tmpStyPath);
|
| + var tmpStySink = tmpStyFile.openWrite(mode: FileMode.APPEND);
|
| + tmpStySink.writeln(r"\renewcommand{\LMHash}[1]{\OriginalLMHash{xxxx}}");
|
| + tmpStySink.close().then((_) {
|
| + new File(specPath).copySync(tmpSpecPath);
|
| + checkAction(runAddHash(),"addlatexhash.dart failed");
|
| + for (var i = 0; i < 5; i++) {
|
| + checkAction(runLatex(specName, tmpDirPath), "LaTeX on spec failed");
|
| + }
|
| + for (var i = 0; i < 5; i++) {
|
| + checkAction(runLatex(hashFileName, tmpDirPath), "LaTeX on output failed");
|
| + }
|
| + if (chkDvi2tty(specDviPath, "spec") != chkDvi2tty(hashDviPath, "output")) {
|
| + throw "dvi2tty spec != dvitty output";
|
| + }
|
| + });
|
| }
|
|
|
| main([args]) {
|
| testCutMatch();
|
| testSisp();
|
| + testSameHash();
|
| // latex and dvi2tty are not installed in the standard test environment
|
| - if (args.length > 0 && args[0] == "local") testNoChange();
|
| + if (args.length > 0 && args[0] == "local") testSameDVI();
|
| }
|
|
|