| 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 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 * Creates the Git repository and commits the contents. | 992 * Creates the Git repository and commits the contents. |
| 993 */ | 993 */ |
| 994 Future<Directory> create(parentDir) { | 994 Future<Directory> create(parentDir) { |
| 995 var workingDir; | 995 var workingDir; |
| 996 Future runGit(List<String> args) => _runGit(args, workingDir); | 996 Future runGit(List<String> args) => _runGit(args, workingDir); |
| 997 | 997 |
| 998 return super.create(parentDir).chain((rootDir) { | 998 return super.create(parentDir).chain((rootDir) { |
| 999 workingDir = rootDir; | 999 workingDir = rootDir; |
| 1000 return runGit(['init']); | 1000 return runGit(['init']); |
| 1001 }).chain((_) => runGit(['add', '.'])) | 1001 }).chain((_) => runGit(['add', '.'])) |
| 1002 .chain((_) => runGit(['commit', '-m', 'initial commit'])) | 1002 .chain((_) => runGit(['commit', '-m', 'initial commit', |
| 1003 '--author="Pub Test <pub@dartlang.org>"'])) |
| 1003 .transform((_) => workingDir); | 1004 .transform((_) => workingDir); |
| 1004 } | 1005 } |
| 1005 | 1006 |
| 1006 /** | 1007 /** |
| 1007 * Commits any changes to the Git repository. | 1008 * Commits any changes to the Git repository. |
| 1008 */ | 1009 */ |
| 1009 Future commit(parentDir) { | 1010 Future commit(parentDir) { |
| 1010 var workingDir; | 1011 var workingDir; |
| 1011 Future runGit(List<String> args) => _runGit(args, workingDir); | 1012 Future runGit(List<String> args) => _runGit(args, workingDir); |
| 1012 | 1013 |
| 1013 return super.create(parentDir).chain((rootDir) { | 1014 return super.create(parentDir).chain((rootDir) { |
| 1014 workingDir = rootDir; | 1015 workingDir = rootDir; |
| 1015 return runGit(['add', '.']); | 1016 return runGit(['add', '.']); |
| 1016 }).chain((_) => runGit(['commit', '-m', 'update'])); | 1017 }).chain((_) => runGit(['commit', '-m', 'update', |
| 1018 '--author="Pub Test <pub@dartlang.org>"'])); |
| 1017 } | 1019 } |
| 1018 | 1020 |
| 1019 /** | 1021 /** |
| 1020 * Schedules changes to be committed to the Git repository. | 1022 * Schedules changes to be committed to the Git repository. |
| 1021 */ | 1023 */ |
| 1022 void scheduleCommit() => _schedule((dir) => this.commit(dir)); | 1024 void scheduleCommit() => _schedule((dir) => this.commit(dir)); |
| 1023 | 1025 |
| 1024 /** | 1026 /** |
| 1025 * Return a Future that completes to the commit in the git repository referred | 1027 * Return a Future that completes to the commit in the git repository referred |
| 1026 * to by [ref] at the current point in the scheduled test run. | 1028 * to by [ref] at the current point in the scheduled test run. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1043 /// Schedule a Git command to run in this repository. | 1045 /// Schedule a Git command to run in this repository. |
| 1044 void scheduleGit(List<String> args) { | 1046 void scheduleGit(List<String> args) { |
| 1045 _schedule((parentDir) { | 1047 _schedule((parentDir) { |
| 1046 var gitDir = new Directory(join(parentDir, name)); | 1048 var gitDir = new Directory(join(parentDir, name)); |
| 1047 return _runGit(args, gitDir); | 1049 return _runGit(args, gitDir); |
| 1048 }); | 1050 }); |
| 1049 } | 1051 } |
| 1050 | 1052 |
| 1051 Future<String> _runGit(List<String> args, Directory workingDir) { | 1053 Future<String> _runGit(List<String> args, Directory workingDir) { |
| 1052 return runGit(args, workingDir: workingDir.path).transform((result) { | 1054 return runGit(args, workingDir: workingDir.path).transform((result) { |
| 1053 if (!result.success) throw "Error running git: ${result.stderr}"; | 1055 if (!result.success) { |
| 1056 throw "Error running: git ${Strings.join(args, ' ')}\n" |
| 1057 "${Strings.join(result.stderr, '\n')}"; |
| 1058 } |
| 1059 |
| 1054 return result.stdout; | 1060 return result.stdout; |
| 1055 }); | 1061 }); |
| 1056 } | 1062 } |
| 1057 } | 1063 } |
| 1058 | 1064 |
| 1059 /** | 1065 /** |
| 1060 * Describes a gzipped tar file and its contents. | 1066 * Describes a gzipped tar file and its contents. |
| 1061 */ | 1067 */ |
| 1062 class TarFileDescriptor extends Descriptor { | 1068 class TarFileDescriptor extends Descriptor { |
| 1063 final List<Descriptor> contents; | 1069 final List<Descriptor> contents; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 } | 1207 } |
| 1202 | 1208 |
| 1203 /** | 1209 /** |
| 1204 * Schedules a callback to be called after Pub is run with [runPub], even if it | 1210 * Schedules a callback to be called after Pub is run with [runPub], even if it |
| 1205 * fails. | 1211 * fails. |
| 1206 */ | 1212 */ |
| 1207 void _scheduleCleanup(_ScheduledEvent event) { | 1213 void _scheduleCleanup(_ScheduledEvent event) { |
| 1208 if (_scheduledCleanup == null) _scheduledCleanup = []; | 1214 if (_scheduledCleanup == null) _scheduledCleanup = []; |
| 1209 _scheduledCleanup.add(event); | 1215 _scheduledCleanup.add(event); |
| 1210 } | 1216 } |
| OLD | NEW |