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

Side by Side Diff: pkg/analysis_server/test/stress/utilities/git.dart

Issue 2611593002: Rework the replay test to be more correct (Closed)
Patch Set: Created 3 years, 11 months 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 * Support for interacting with a git repository. 6 * Support for interacting with a git repository.
7 */ 7 */
8 library analysis_server.test.stress.utilities.git;
9
10 import 'dart:convert'; 8 import 'dart:convert';
11 import 'dart:io'; 9 import 'dart:io';
12 10
13 import 'package:analyzer/src/util/glob.dart'; 11 import 'package:analyzer/src/util/glob.dart';
14 import 'package:path/path.dart' as path; 12 import 'package:path/path.dart' as path;
15 13
14 import 'logger.dart';
15
16 /** 16 /**
17 * A representation of the differences between two blobs. 17 * A representation of the differences between two blobs.
18 */ 18 */
19 class BlobDiff { 19 class BlobDiff {
20 /** 20 /**
21 * The regular expression used to identify the beginning of a hunk. 21 * The regular expression used to identify the beginning of a hunk.
22 */ 22 */
23 static final RegExp hunkHeaderRegExp = 23 static final RegExp hunkHeaderRegExp =
24 new RegExp(r'@@ -([0-9]+)(?:,[0-9]+)? \+([0-9]+)(?:,[0-9]+)? @@'); 24 new RegExp(r'@@ -([0-9]+)(?:,[0-9]+)? \+([0-9]+)(?:,[0-9]+)? @@');
25 25
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 /** 388 /**
389 * A representation of a git repository. 389 * A representation of a git repository.
390 */ 390 */
391 class GitRepository { 391 class GitRepository {
392 /** 392 /**
393 * The absolute path of the directory containing the repository. 393 * The absolute path of the directory containing the repository.
394 */ 394 */
395 final String path; 395 final String path;
396 396
397 /** 397 /**
398 * The logger to which git commands should be written, or `null` if the
399 * commands should not be written.
400 */
401 final Logger logger;
402
403 /**
398 * Initialize a newly created repository to represent the git repository at 404 * Initialize a newly created repository to represent the git repository at
399 * the given [path]. 405 * the given [path].
406 *
407 * If a [commandSink] is provided, any calls to git will be written to it.
400 */ 408 */
401 GitRepository(this.path); 409 GitRepository(this.path, {this.logger = null});
402 410
403 /** 411 /**
404 * Checkout the given [commit] from the repository. This is done by running 412 * Checkout the given [commit] from the repository. This is done by running
405 * the command `git checkout <sha>`. 413 * the command `git checkout <sha>`.
406 */ 414 */
407 void checkout(String commit) { 415 void checkout(String commit) {
408 _run(['checkout', commit]); 416 _run(['checkout', commit]);
409 } 417 }
410 418
411 /** 419 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 ProcessResult result = _run(['rev-list', '--first-parent', 'HEAD']); 455 ProcessResult result = _run(['rev-list', '--first-parent', 'HEAD']);
448 List<String> commitIds = LineSplitter.split(result.stdout).toList(); 456 List<String> commitIds = LineSplitter.split(result.stdout).toList();
449 return new LinearCommitHistory(this, commitIds); 457 return new LinearCommitHistory(this, commitIds);
450 } 458 }
451 459
452 /** 460 /**
453 * Synchronously run the given [executable] with the given [arguments]. Return 461 * Synchronously run the given [executable] with the given [arguments]. Return
454 * the result of running the process. 462 * the result of running the process.
455 */ 463 */
456 ProcessResult _run(List<String> arguments) { 464 ProcessResult _run(List<String> arguments) {
465 logger?.log('git', 'git', arguments: arguments);
457 return Process.runSync('git', arguments, 466 return Process.runSync('git', arguments,
458 stderrEncoding: UTF8, stdoutEncoding: UTF8, workingDirectory: path); 467 stderrEncoding: UTF8, stdoutEncoding: UTF8, workingDirectory: path);
459 } 468 }
460 } 469 }
461 470
462 /** 471 /**
463 * A representation of the history of a Git repository. This only represents a 472 * A representation of the history of a Git repository. This only represents a
464 * single linear path in the history graph. 473 * single linear path in the history graph.
465 */ 474 */
466 class LinearCommitHistory { 475 class LinearCommitHistory {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 currentCommit--; 542 currentCommit--;
534 return true; 543 return true;
535 } 544 }
536 545
537 /** 546 /**
538 * Return the difference between the current commit and the commit that 547 * Return the difference between the current commit and the commit that
539 * followed it. 548 * followed it.
540 */ 549 */
541 CommitDelta next() => history.repository.getCommitDiff(srcCommit, dstCommit); 550 CommitDelta next() => history.repository.getCommitDiff(srcCommit, dstCommit);
542 } 551 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/stress/replay/replay.dart ('k') | pkg/analysis_server/test/stress/utilities/logger.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698