Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: tests/standalone/io/addlatexhash_test.dart

Issue 714883002: Revert "Working insertion of hash values; added a few labels in spec" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « docs/language/dartLangSpec.tex ('k') | tests/standalone/io/addlatexhash_test_src.tex » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env dart
2 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // 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 2 // 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. 3 // BSD-style license that can be found in the LICENSE file.
5 4
6 // testing ../../../tools/addlatexhash.dart 5 // testing ../../../tools/addlatexhash.dart
7 6
8 import 'dart:io'; 7 import 'dart:io';
9 import 'package:path/path.dart' as path; 8 import 'package:path/path.dart' as path;
10 import '../../../tools/addlatexhash.dart'; 9 import '../../../tools/addlatexhash.dart';
11 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 47
49 testSisp() { 48 testSisp() {
50 oneTestSisp(sispIsDartBegin, "Begin", "\\begin{dartCode}\n", true); 49 oneTestSisp(sispIsDartBegin, "Begin", "\\begin{dartCode}\n", true);
51 oneTestSisp(sispIsDartBegin, "Begin", " \\begin{dartCode}\n", true); 50 oneTestSisp(sispIsDartBegin, "Begin", " \\begin{dartCode}\n", true);
52 oneTestSisp(sispIsDartBegin, "Begin", "whatever else ..", false); 51 oneTestSisp(sispIsDartBegin, "Begin", "whatever else ..", false);
53 oneTestSisp(sispIsDartEnd, "End", "\\end{dartCode}", true); 52 oneTestSisp(sispIsDartEnd, "End", "\\end{dartCode}", true);
54 oneTestSisp(sispIsDartEnd, "End", " \\end{dartCode}\t \n", true); 53 oneTestSisp(sispIsDartEnd, "End", " \\end{dartCode}\t \n", true);
55 oneTestSisp(sispIsDartEnd, "End", "whatever else ..", false); 54 oneTestSisp(sispIsDartEnd, "End", "whatever else ..", false);
56 } 55 }
57 56
58 // Check that the hash values of paragraphs in the specially prepared
59 // LaTeX source 'addlatexhash_test_src.tex' are identical in groups
60 // of eight (so we get 8 identical hash values, then another hash
61 // value 8 times, etc.)
62 testSameHash() {
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
68 const par8timesName = "addlatexhash_test_src";
69 const par8timesFileName = "$par8timesName.tex";
70 final par8timesDirPath = path.join(dartRootDir, "tests", "standalone", "io");
71 final par8timesPath = path.join(par8timesDirPath, par8timesFileName);
72 final tmpPar8timesPath = path.join(tmpDirPath, par8timesFileName);
73
74 // file names paths for output
75 final hashName = par8timesName + "-hash";
76 final hashFileName = "$hashName.tex";
77 final hashPath = path.join(tmpDirPath, hashFileName);
78 final listName = par8timesName + "-list";
79 final listFileName = "$listName.txt";
80 final listPath = path.join(tmpDirPath, listFileName);
81
82 // actions to take
83 runAddHash() =>
84 Process.runSync("dart",
85 [path.join(dartRootPath, "tools", "addlatexhash.dart"),
86 tmpPar8timesPath,
87 hashPath,
88 listPath]);
89
90 // perform test
91 new File(par8timesPath).copySync(tmpPar8timesPath);
92 checkAction(runAddHash(), "addlatexhash.dart failed");
93 var listFile = new File(listPath);
94 var listLines = listFile.readAsLinesSync();
95 var latestLine = null;
96 var sameCount = 0;
97 for (var line in listLines) {
98 if (!line.startsWith(" ")) continue; // section marker
99 if (line.startsWith(" %")) continue; // transformed text "comment"
100 if (line != latestLine) {
101 // new hash, check for number of equal hashes, then reset
102 if (sameCount % 8 == 0) {
103 // saw zero or more blocks of 8 identical hash values: OK
104 latestLine = line;
105 sameCount = 1;
106 } else {
107 throw "normalization failed to produce same result";
108 }
109 } else {
110 sameCount++;
111 }
112 }
113 }
114
115 // Check that the LaTeX source transformation done by addlatexhash.dart 57 // Check that the LaTeX source transformation done by addlatexhash.dart
116 // does not affect the generated output, as seen via dvi2tty and diff. 58 // does not affect the generated output, as seen via dvi2tty and diff.
117 // NB: Not part of normal testing (only local): latex and dvi2tty are 59 // NB: Not part of normal testing (only local): latex and dvi2tty are
118 // not installed in the standard test environment. 60 // not installed in the standard test environment.
119 testSameDVI() { 61 testNoChange() {
120 // set up /tmp directory to hold output 62 // set up /tmp directory to hold output
121 final tmpDir = Directory.systemTemp.createTempSync("addlatexhash_test"); 63 final tmpDir = Directory.systemTemp.createTempSync("addlatexhash_test");
122 final tmpDirPath = tmpDir.path; 64 final tmpDirPath = tmpDir.path;
123 65
124 // file names/paths for original spec 66 // file names/paths for original spec
125 const specName = "dartLangSpec"; 67 const specName = "dartLangSpec";
126 const specFileName = "$specName.tex"; 68 const specFileName = "$specName.tex";
127 final specDirPath = path.join(dartRootDir, "docs", "language"); 69 final specDirPath = path.join(dartRootDir, "docs", "language");
128 final specPath = path.join(specDirPath, specFileName); 70 final specPath = path.join(specDirPath, specFileName);
129 final tmpSpecPath = path.join(tmpDirPath, specFileName); 71 final tmpSpecPath = path.join(tmpDirPath, specFileName);
130 const specDviFileName = "$specName.dvi"; 72 const specDviFileName = "$specName.dvi";
131 final specDviPath = path.join(tmpDirPath, specDviFileName); 73 final specDviPath = path.join(tmpDirPath, specDviFileName);
132 74
133 // file names/paths for associated sty 75 // file names/paths for associated sty
134 const styFileName = "dart.sty"; 76 const styFileName = "dart.sty";
135 final styPath = path.join(specDirPath, styFileName); 77 final styPath = path.join(specDirPath, styFileName);
136 final tmpStyPath = path.join(tmpDirPath, styFileName); 78 final tmpStyPath = path.join(tmpDirPath, styFileName);
137 79
138 // file names paths for output 80 // file names paths for output
139 const hashName = "dartLangSpec-hash"; 81 const hashName = "dartLangSpec-hash";
140 const hashFileName = "$hashName.tex"; 82 const hashFileName = "$hashName.tex";
141 final hashPath = path.join(tmpDirPath, hashFileName); 83 final hashPath = path.join(tmpDirPath, hashFileName);
142 final hashDviPath = path.join(tmpDirPath, "$hashName.dvi"); 84 final hashDviPath = path.join(tmpDirPath, "$hashName.dvi");
143 85
144 final listName = "$specName-list";
145 final listFileName = "$listName.txt";
146 final listPath = path.join(tmpDirPath, listFileName);
147
148 // actions to take 86 // actions to take
149 runLatex(fileName,workingDirectory) => 87 runLatex(fileName,workingDirectory) =>
150 Process.runSync("latex", [fileName], workingDirectory: workingDirectory); 88 Process.runSync("latex", [fileName], workingDirectory: workingDirectory);
151 89
152 runAddHash() => 90 runAddHash() =>
153 Process.runSync("dart", 91 Process.runSync("dart",
154 [path.join(dartRootPath, "tools", "addlatexhash.dart"), 92 [path.join(dartRootPath, "tools", "addlatexhash.dart"),
155 tmpSpecPath, 93 tmpSpecPath,
156 hashPath, 94 hashPath]);
157 listPath]);
158 95
159 runDvi2tty(dviFile) => 96 runDvi2tty(dviFile) =>
160 Process.runSync("dvi2tty", [dviFile], workingDirectory: tmpDir.path); 97 Process.runSync("dvi2tty", [dviFile], workingDirectory: tmpDir.path);
161 98
162 chkDvi2tty(file, subject) => 99 chkDvi2tty(file, subject) =>
163 checkAction(runDvi2tty(file), "dvitty on $subject failed"); 100 checkAction(runDvi2tty(file), "dvitty on $subject failed");
164 101
165 // perform test 102 // perform test
166 var renewLMHashCmd = r"\renewcommand{\LMHash}[1]{\OriginalLMHash{xxxx}}"; 103 new File(styPath).copySync(tmpStyPath);
167 new File(styPath)
168 .copySync(tmpStyPath)
169 .writeAsStringSync(renewLMHashCmd, mode: FileMode.APPEND);
170 new File(specPath).copySync(tmpSpecPath); 104 new File(specPath).copySync(tmpSpecPath);
171
172 checkAction(runAddHash(),"addlatexhash.dart failed");
173 for (var i = 0; i < 5; i++) { 105 for (var i = 0; i < 5; i++) {
174 checkAction(runLatex(specName, tmpDirPath), "LaTeX on spec failed"); 106 checkAction(runLatex(specName, tmpDirPath), "LaTeX on spec failed");
175 } 107 }
108 checkAction(runAddHash(),"addlatexhash.dart failed");
176 for (var i = 0; i < 5; i++) { 109 for (var i = 0; i < 5; i++) {
177 checkAction(runLatex(hashFileName, tmpDirPath), "LaTeX on output failed"); 110 checkAction(runLatex(hashFileName, tmpDirPath), "LaTeX on output failed");
178 } 111 }
179 if (chkDvi2tty(specDviPath, "spec") != chkDvi2tty(hashDviPath, "output")) { 112 if (chkDvi2tty(specDviPath, "spec") != chkDvi2tty(hashDviPath, "output")) {
180 throw "dvi2tty spec != dvitty output"; 113 throw "dvi2tty spec != dvitty output";
181 } 114 }
182 } 115 }
183 116
184 main([args]) { 117 main([args]) {
185 testCutMatch(); 118 testCutMatch();
186 testSisp(); 119 testSisp();
187 testSameHash();
188 // latex and dvi2tty are not installed in the standard test environment 120 // latex and dvi2tty are not installed in the standard test environment
189 if (args.length > 0 && args[0] == "local") testSameDVI(); 121 if (args.length > 0 && args[0] == "local") testNoChange();
190 } 122 }
OLDNEW
« no previous file with comments | « docs/language/dartLangSpec.tex ('k') | tests/standalone/io/addlatexhash_test_src.tex » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698