| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 final hashPath = path.join(tmpDirPath, hashFileName); | 73 final hashPath = path.join(tmpDirPath, hashFileName); |
| 74 final listName = par8timesName + "-list"; | 74 final listName = par8timesName + "-list"; |
| 75 final listFileName = "$listName.txt"; | 75 final listFileName = "$listName.txt"; |
| 76 final listPath = path.join(tmpDirPath, listFileName); | 76 final listPath = path.join(tmpDirPath, listFileName); |
| 77 | 77 |
| 78 // dart executable | 78 // dart executable |
| 79 final dartExecutable = Platform.executable; | 79 final dartExecutable = Platform.executable; |
| 80 if (dartExecutable == "") throw "dart executable not available"; | 80 if (dartExecutable == "") throw "dart executable not available"; |
| 81 | 81 |
| 82 // actions to take | 82 // actions to take |
| 83 runAddHash() => | 83 runAddHash() { |
| 84 Process.runSync(dartExecutable, | 84 var args = [ |
| 85 [path.join(dartRootPath, "tools", "addlatexhash.dart"), | 85 '--package-root=${Platform.packageRoot}', |
| 86 tmpPar8timesPath, | 86 path.join(dartRootPath, "tools", "addlatexhash.dart"), |
| 87 hashPath, | 87 tmpPar8timesPath, |
| 88 listPath]); | 88 hashPath, |
| 89 listPath |
| 90 ]; |
| 91 return Process.runSync(dartExecutable, args); |
| 92 } |
| 89 | 93 |
| 90 // perform test | 94 // perform test |
| 91 new File(par8timesPath).copySync(tmpPar8timesPath); | 95 new File(par8timesPath).copySync(tmpPar8timesPath); |
| 92 checkAction(runAddHash(), "addlatexhash.dart failed"); | 96 checkAction(runAddHash(), "addlatexhash.dart failed"); |
| 93 var listFile = new File(listPath); | 97 var listFile = new File(listPath); |
| 94 var listLines = listFile.readAsLinesSync(); | 98 var listLines = listFile.readAsLinesSync(); |
| 95 var latestLine = null; | 99 var latestLine = null; |
| 96 var sameCount = 0; | 100 var sameCount = 0; |
| 97 for (var line in listLines) { | 101 for (var line in listLines) { |
| 98 if (!line.startsWith(" ")) continue; // section marker | 102 if (!line.startsWith(" ")) continue; // section marker |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 final listPath = path.join(tmpDirPath, listFileName); | 146 final listPath = path.join(tmpDirPath, listFileName); |
| 143 | 147 |
| 144 // dart executable | 148 // dart executable |
| 145 final dartExecutable = Platform.executable; | 149 final dartExecutable = Platform.executable; |
| 146 if (dartExecutable == "") throw "dart executable not available"; | 150 if (dartExecutable == "") throw "dart executable not available"; |
| 147 | 151 |
| 148 // actions to take; rely on having latex and dvi2tty in PATH | 152 // actions to take; rely on having latex and dvi2tty in PATH |
| 149 runLatex(fileName,workingDirectory) => | 153 runLatex(fileName,workingDirectory) => |
| 150 Process.runSync("latex", [fileName], workingDirectory: workingDirectory); | 154 Process.runSync("latex", [fileName], workingDirectory: workingDirectory); |
| 151 | 155 |
| 152 runAddHash() => | 156 runAddHash() { |
| 153 Process.runSync(dartExecutable, | 157 var args = [ |
| 154 [path.join(dartRootPath, "tools", "addlatexhash.dart"), | 158 '--package-root=${Platform.packageRoot}', |
| 155 tmpSpecPath, | 159 path.join(dartRootPath, "tools", "addlatexhash.dart"), |
| 156 hashPath, | 160 tmpSpecPath, |
| 157 listPath]); | 161 hashPath, |
| 162 listPath |
| 163 ]; |
| 164 return Process.runSync(dartExecutable, args); |
| 165 } |
| 158 | 166 |
| 159 runDvi2tty(dviFile) => | 167 runDvi2tty(dviFile) => |
| 160 Process.runSync("dvi2tty", [dviFile], workingDirectory: tmpDirPath); | 168 Process.runSync("dvi2tty", [dviFile], workingDirectory: tmpDirPath); |
| 161 | 169 |
| 162 chkDvi2tty(file, subject) => | 170 chkDvi2tty(file, subject) => |
| 163 checkAction(runDvi2tty(file), "dvitty on $subject failed"); | 171 checkAction(runDvi2tty(file), "dvitty on $subject failed"); |
| 164 | 172 |
| 165 // perform test | 173 // perform test |
| 166 var renewLMHashCmd = r"\renewcommand{\LMHash}[1]{\OriginalLMHash{xxxx}}"; | 174 var renewLMHashCmd = r"\renewcommand{\LMHash}[1]{\OriginalLMHash{xxxx}}"; |
| 167 new File(styPath) | 175 new File(styPath) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 195 main([args]) { | 203 main([args]) { |
| 196 testCutMatch(); | 204 testCutMatch(); |
| 197 testSisp(); | 205 testSisp(); |
| 198 | 206 |
| 199 runWithTempDir(testSameHash); | 207 runWithTempDir(testSameHash); |
| 200 // latex and dvi2tty are not installed in the standard test environment | 208 // latex and dvi2tty are not installed in the standard test environment |
| 201 if (args.length > 0 && args[0] == "local") { | 209 if (args.length > 0 && args[0] == "local") { |
| 202 runWithTempDir(testSameDVI); | 210 runWithTempDir(testSameDVI); |
| 203 } | 211 } |
| 204 } | 212 } |
| OLD | NEW |