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

Side by Side Diff: utils/tests/pub/test_pub.dart

Issue 11343059: Configure git explicitly when committing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« utils/pub/io.dart ('K') | « utils/pub/io.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 dartBin = new File(dartBin).fullPathSync(); 529 dartBin = new File(dartBin).fullPathSync();
530 } 530 }
531 531
532 // Find the main pub entrypoint. 532 // Find the main pub entrypoint.
533 var pubPath = fs.joinPaths(testDirectory, '../../pub/pub.dart'); 533 var pubPath = fs.joinPaths(testDirectory, '../../pub/pub.dart');
534 534
535 var dartArgs = 535 var dartArgs =
536 ['--enable-type-checks', '--enable-asserts', pubPath, '--trace']; 536 ['--enable-type-checks', '--enable-asserts', pubPath, '--trace'];
537 dartArgs.addAll(args); 537 dartArgs.addAll(args);
538 538
539 var environment = new Map.from(Platform.environment); 539 var environment = {
540 environment['PUB_CACHE'] = pathInSandbox(cachePath); 540 'PUB_CACHE': pathInSandbox(cachePath),
541 environment['DART_SDK'] = pathInSandbox(sdkPath); 541 'DART_SDK': pathInSandbox(sdkPath)
542 };
542 543
543 return runProcess(dartBin, dartArgs, workingDir: pathInSandbox(appPath), 544 return runProcess(dartBin, dartArgs, workingDir: pathInSandbox(appPath),
544 environment: environment); 545 environment: environment);
545 }).transform((result) { 546 }).transform((result) {
546 var failures = []; 547 var failures = [];
547 548
548 _validateOutput(failures, 'stdout', output, result.stdout); 549 _validateOutput(failures, 'stdout', output, result.stdout);
549 _validateOutput(failures, 'stderr', error, result.stderr); 550 _validateOutput(failures, 'stderr', error, result.stderr);
550 551
551 if (result.exitCode != exitCode) { 552 if (result.exitCode != exitCode) {
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 var workingDir; 1044 var workingDir;
1044 1045
1045 Future runGitStep(_) { 1046 Future runGitStep(_) {
1046 if (commands.isEmpty) return new Future.immediate(workingDir); 1047 if (commands.isEmpty) return new Future.immediate(workingDir);
1047 var command = commands.removeAt(0); 1048 var command = commands.removeAt(0);
1048 return _runGit(command, workingDir).chain(runGitStep); 1049 return _runGit(command, workingDir).chain(runGitStep);
1049 } 1050 }
1050 1051
1051 return super.create(parentDir).chain((rootDir) { 1052 return super.create(parentDir).chain((rootDir) {
1052 workingDir = rootDir; 1053 workingDir = rootDir;
1053 return writeTextFile(join(parentDir, '.gitconfig'), ''' 1054 return runGitStep(null);
1054 [user] 1055 });
1055 name = Test Pub
1056 email = pub@dartlang.org
1057 ''');
1058 }).chain(runGitStep);
1059 } 1056 }
1060 1057
1061 Future<String> _runGit(List<String> args, Directory workingDir) { 1058 Future<String> _runGit(List<String> args, Directory workingDir) {
1062 return runGit(args, workingDir: workingDir.path).transform((result) { 1059 // Explicitly specify the committer information. Git needs this to commit
1060 // and we don't want to rely on the buildbots having this already set up.
1061 var environment = {
1062 'GIT_AUTHOR_NAME': 'Pub Test',
1063 'GIT_AUTHOR_EMAIL': 'pub@dartlang.org',
1064 'GIT_COMMITTER_NAME': 'Pub Test',
1065 'GIT_COMMITTER_EMAIL': 'pub@dartlang.org'
1066 };
1067
1068 return runGit(args, workingDir: workingDir.path,
1069 environment: environment).transform((result) {
1063 if (!result.success) { 1070 if (!result.success) {
1064 throw "Error running: git ${Strings.join(args, ' ')}\n" 1071 throw "Error running: git ${Strings.join(args, ' ')}\n"
1065 "${Strings.join(result.stderr, '\n')}"; 1072 "${Strings.join(result.stderr, '\n')}";
1066 } 1073 }
1067 1074
1068 return result.stdout; 1075 return result.stdout;
1069 }); 1076 });
1070 } 1077 }
1071 } 1078 }
1072 1079
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 } 1222 }
1216 1223
1217 /** 1224 /**
1218 * Schedules a callback to be called after Pub is run with [runPub], even if it 1225 * Schedules a callback to be called after Pub is run with [runPub], even if it
1219 * fails. 1226 * fails.
1220 */ 1227 */
1221 void _scheduleCleanup(_ScheduledEvent event) { 1228 void _scheduleCleanup(_ScheduledEvent event) {
1222 if (_scheduledCleanup == null) _scheduledCleanup = []; 1229 if (_scheduledCleanup == null) _scheduledCleanup = [];
1223 _scheduledCleanup.add(event); 1230 _scheduledCleanup.add(event);
1224 } 1231 }
OLDNEW
« utils/pub/io.dart ('K') | « utils/pub/io.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698