Chromium Code Reviews| 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 * Test infrastructure for testing pub. Unlike typical unit tests, most pub | 6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub |
| 7 * tests are integration tests that stage some stuff on the file system, run | 7 * tests are integration tests that stage some stuff on the file system, run |
| 8 * pub, and then validate the results. This library provides an API to build | 8 * pub, and then validate the results. This library provides an API to build |
| 9 * tests like that. | 9 * tests like that. |
| 10 */ | 10 */ |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 968 /** | 968 /** |
| 969 * Creates the files and directories within this tar file, then archives them, | 969 * Creates the files and directories within this tar file, then archives them, |
| 970 * compresses them, and saves the result to [parentDir]. | 970 * compresses them, and saves the result to [parentDir]. |
| 971 */ | 971 */ |
| 972 Future<File> create(parentDir) { | 972 Future<File> create(parentDir) { |
| 973 var tempDir; | 973 var tempDir; |
| 974 return parentDir.createTemp().chain((_tempDir) { | 974 return parentDir.createTemp().chain((_tempDir) { |
| 975 tempDir = _tempDir; | 975 tempDir = _tempDir; |
| 976 return Futures.wait(contents.map((child) => child.create(tempDir))); | 976 return Futures.wait(contents.map((child) => child.create(tempDir))); |
| 977 }).chain((_) { | 977 }).chain((_) { |
| 978 var args = ["--directory", tempDir.path, "--create", "--gzip", "--file", | 978 if (Platform.operatingSystem != "windows") { |
| 979 join(parentDir, _stringName)]; | 979 var args = ["--directory", tempDir.path, "--create", "--gzip", |
| 980 args.addAll(contents.map((child) => child.name)); | 980 "--file", join(parentDir, _stringName)]; |
| 981 return runProcess("tar", args); | 981 args.addAll(contents.map((child) => child.name)); |
| 982 return runProcess("tar", args); | |
| 983 } else { | |
| 984 // TODO(bob): HACK TEMP!!!!! | |
| 985 var command = "C:\\Program Files (x86)\\7-Zip\\7z.exe"; | |
|
nweiz
2012/09/18 23:07:12
Make this a real path
Bob Nystrom
2012/09/19 15:57:54
Oopsie! Done.
| |
| 986 | |
| 987 // Create the tar file. | |
| 988 var tarFile = join(tempDir, _stringName.replaceAll("tar.gz", "tar")); | |
| 989 var args = ["a", tarFile]; | |
| 990 args.addAll(contents.map( | |
| 991 (child) => '-i!"${join(tempDir, child.name)}"')); | |
| 992 | |
| 993 return runProcess(command, args).chain((_) { | |
| 994 // GZIP it. 7zip doesn't support doing both as a single operation. | |
| 995 args = ["a", join(parentDir, _stringName), tarFile]; | |
| 996 return runProcess(command, args); | |
| 997 }); | |
| 998 } | |
| 982 }).chain((result) { | 999 }).chain((result) { |
| 983 if (!result.success) { | 1000 if (!result.success) { |
| 984 throw "Failed to create tar file $name.\n" | 1001 throw "Failed to create tar file $name.\n" |
| 985 "STDERR: ${Strings.join(result.stderr, "\n")}"; | 1002 "STDERR: ${Strings.join(result.stderr, "\n")}"; |
| 986 } | 1003 } |
| 987 return deleteDir(tempDir); | 1004 return deleteDir(tempDir); |
| 988 }).transform((_) { | 1005 }).transform((_) { |
| 989 return new File(join(parentDir, _stringName)); | 1006 return new File(join(parentDir, _stringName)); |
| 990 }); | 1007 }); |
| 991 } | 1008 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1055 } | 1072 } |
| 1056 | 1073 |
| 1057 /** | 1074 /** |
| 1058 * Schedules a callback to be called after Pub is run with [runPub], even if it | 1075 * Schedules a callback to be called after Pub is run with [runPub], even if it |
| 1059 * fails. | 1076 * fails. |
| 1060 */ | 1077 */ |
| 1061 void _scheduleCleanup(_ScheduledEvent event) { | 1078 void _scheduleCleanup(_ScheduledEvent event) { |
| 1062 if (_scheduledCleanup == null) _scheduledCleanup = []; | 1079 if (_scheduledCleanup == null) _scheduledCleanup = []; |
| 1063 _scheduledCleanup.add(event); | 1080 _scheduledCleanup.add(event); |
| 1064 } | 1081 } |
| OLD | NEW |