| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // 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 |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * A test execution pipeline is made up of a list of tasks. Each task is a | 6 * A test execution pipeline is made up of a list of tasks. Each task is a |
| 7 * subclass of [PipelineTask]. | 7 * subclass of [PipelineTask]. |
| 8 */ | 8 */ |
| 9 abstract class PipelineTask { | 9 abstract class PipelineTask { |
| 10 | 10 |
| 11 abstract void execute(Path testfile, List stdout, List stderr, | 11 abstract execute(Path testfile, List stdout, List stderr, |
| 12 bool logging, Function exitHandler); | 12 bool logging, Function exitHandler); |
| 13 | 13 |
| 14 void cleanup(Path testfile, List stdout, List stderr, | 14 void cleanup(Path testfile, List stdout, List stderr, |
| 15 bool verboseLogging, bool keepTestFiles) { | 15 bool verboseLogging, bool keepTestFiles) { |
| 16 } | 16 } |
| 17 | 17 |
| 18 void deleteFiles(List templates, Path testfile, bool logging, bool keepFiles, | 18 void deleteFiles(List templates, Path testfile, bool logging, bool keepFiles, |
| 19 List stdout) { | 19 List stdout) { |
| 20 if (!keepFiles) { | 20 if (!keepFiles) { |
| 21 for (var template in templates) { | 21 for (var template in templates) { |
| 22 var fname = expandMacros(template, testfile); | 22 var fname = expandMacros(template, testfile); |
| 23 deleteFile(fname); | 23 if (deleteFile(fname)) { |
| 24 if (logging) { | 24 if (logging) { |
| 25 stdout.add('Removing $fname'); | 25 stdout.add('Removed $fname'); |
| 26 } |
| 27 } else { |
| 28 if (logging) { |
| 29 stdout.add('Failed to remove $fname'); |
| 30 } |
| 26 } | 31 } |
| 27 } | 32 } |
| 28 } | 33 } |
| 29 } | 34 } |
| 30 | 35 |
| 31 String flattenPath(String path) { | 36 String flattenPath(String path) { |
| 32 return makePathAbsolute(path). | 37 return makePathAbsolute(path). |
| 33 replaceAll(Platform.pathSeparator, "_"). | 38 replaceAll(Platform.pathSeparator, "_"). |
| 34 replaceAll(":",""); | 39 replaceAll(":",""); |
| 35 } | 40 } |
| 36 | 41 |
| 37 // This takes a string used in a template and does macro expansion for | 42 // This takes a string used in a template and does macro expansion for |
| 38 // a specific test file. | 43 // a specific test file. |
| 39 String expandMacros(String template, Path testfile) { | 44 String expandMacros(String template, Path testfile) { |
| 40 String path = makePathAbsolute(testfile.directoryPath.toString()); | 45 String path = makePathAbsolute(testfile.directoryPath.toString()); |
| 41 return template. | 46 return template. |
| 42 replaceAll(Macros.fullFilePath, testfile.toNativePath()). | 47 replaceAll(Macros.fullFilePath, testfile.toNativePath()). |
| 43 replaceAll(Macros.filenameNoExtension, | 48 replaceAll(Macros.filenameNoExtension, |
| 44 testfile.filenameWithoutExtension). | 49 testfile.filenameWithoutExtension). |
| 45 replaceAll(Macros.filename, testfile.filename). | 50 replaceAll(Macros.filename, testfile.filename). |
| 46 replaceAll(Macros.directory, path). | 51 replaceAll(Macros.directory, path). |
| 47 replaceAll(Macros.flattenedDirectory, flattenPath(path)); | 52 replaceAll(Macros.flattenedDirectory, flattenPath(path)); |
| 48 } | 53 } |
| 49 } | 54 } |
| 50 | 55 |
| 51 | 56 |
| OLD | NEW |