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

Side by Side Diff: tools/testing/dart/test_runner.dart

Issue 2020843002: Make test.dart override only those dependencies declared in the pubspec.yaml (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « tools/.packages ('k') | tools/testing/dart/test_suite.dart » ('j') | 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 * Classes and methods for executing tests. 6 * Classes and methods for executing tests.
7 * 7 *
8 * This module includes: 8 * This module includes:
9 * - Managing parallel execution of tests, including timeout checks. 9 * - Managing parallel execution of tests, including timeout checks.
10 * - Evaluating the output of each test as pass/fail/crash/timeout. 10 * - Evaluating the output of each test as pass/fail/crash/timeout.
11 */ 11 */
12 library test_runner; 12 library test_runner;
13 13
14 import "dart:async"; 14 import "dart:async";
15 import "dart:collection" show Queue; 15 import "dart:collection" show Queue;
16 import "dart:convert" show LineSplitter, UTF8, JSON; 16 import "dart:convert" show LineSplitter, UTF8, JSON;
17 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow 17 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow
18 // CommandOutput.exitCode in subclasses of CommandOutput. 18 // CommandOutput.exitCode in subclasses of CommandOutput.
19 import "dart:io" as io; 19 import "dart:io" as io;
20 import "dart:math" as math; 20 import "dart:math" as math;
21
22 import 'package:yaml/yaml.dart';
23
21 import 'android.dart'; 24 import 'android.dart';
22 import 'dependency_graph.dart' as dgraph; 25 import 'dependency_graph.dart' as dgraph;
23 import "browser_controller.dart"; 26 import "browser_controller.dart";
24 import "path.dart"; 27 import "path.dart";
25 import "status_file_parser.dart"; 28 import "status_file_parser.dart";
26 import "test_progress.dart"; 29 import "test_progress.dart";
27 import "test_suite.dart"; 30 import "test_suite.dart";
28 import "utils.dart"; 31 import "utils.dart";
29 import 'record_and_replay.dart'; 32 import 'record_and_replay.dart';
30 33
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 String _destinationFile; 466 String _destinationFile;
464 Map<String, Map> _dependencyOverrides; 467 Map<String, Map> _dependencyOverrides;
465 468
466 ModifyPubspecYamlCommand._( 469 ModifyPubspecYamlCommand._(
467 this._pubspecYamlFile, this._destinationFile, this._dependencyOverrides) 470 this._pubspecYamlFile, this._destinationFile, this._dependencyOverrides)
468 : super._("modify_pubspec") { 471 : super._("modify_pubspec") {
469 assert(_pubspecYamlFile.endsWith("pubspec.yaml")); 472 assert(_pubspecYamlFile.endsWith("pubspec.yaml"));
470 assert(_destinationFile.endsWith("pubspec.yaml")); 473 assert(_destinationFile.endsWith("pubspec.yaml"));
471 } 474 }
472 475
476 static Map<String, Map> _filterOverrides(
477 String pubspec, Map<String, Map> overrides) {
478 if (overrides.isEmpty) return overrides;
479 var yaml = loadYaml(pubspec);
480 var deps = yaml['dependencies'];
481 var filteredOverrides = <String, Map>{};
482 if (deps != null) {
483 for (var d in deps.keys) {
484 if (!overrides.containsKey(d)) {
485 // pub depends on compiler_unsupported instead of compiler
486 // The dependency is so hackish that we currently ignore it here.
487 if (d == 'compiler_unsupported') continue;
488 throw "Repo doesn't have package $d used in $pubspec";
489 }
490 filteredOverrides[d] = overrides[d];
491 }
492 }
493 return filteredOverrides;
494 }
495
473 String get reproductionCommand => 496 String get reproductionCommand =>
474 "Adding necessary dependency overrides to '$_pubspecYamlFile' " 497 "Adding necessary dependency overrides to '$_pubspecYamlFile' "
475 "(destination = $_destinationFile)."; 498 "(destination = $_destinationFile).";
476 499
477 Future<ScriptCommandOutputImpl> run() { 500 Future<ScriptCommandOutputImpl> run() {
478 var watch = new Stopwatch()..start(); 501 var watch = new Stopwatch()..start();
479 502
480 var pubspecLockFile = _destinationFile.substring( 503 var pubspecLockFile = _destinationFile.substring(
481 0, _destinationFile.length - ".yaml".length) + 504 0, _destinationFile.length - ".yaml".length) +
482 ".lock"; 505 ".lock";
483 506
484 var file = new io.File(_pubspecYamlFile); 507 var file = new io.File(_pubspecYamlFile);
485 var destinationFile = new io.File(_destinationFile); 508 var destinationFile = new io.File(_destinationFile);
486 var lockfile = new io.File(pubspecLockFile); 509 var lockfile = new io.File(pubspecLockFile);
487 return file.readAsString().then((String yamlString) { 510 return file.readAsString().then((String yamlString) {
511 var overrides = _filterOverrides(yamlString, _dependencyOverrides);
488 var dependencyOverrideSection = new StringBuffer(); 512 var dependencyOverrideSection = new StringBuffer();
489 if (_dependencyOverrides.isNotEmpty) { 513 if (_dependencyOverrides.isNotEmpty) {
490 dependencyOverrideSection.write("\n" 514 dependencyOverrideSection.write("\n"
491 "# This section was autogenerated by test.py!\n" 515 "# This section was autogenerated by test.py!\n"
492 "dependency_overrides:\n"); 516 "dependency_overrides:\n");
493 _dependencyOverrides.forEach((String packageName, Map override) { 517 overrides.forEach((String packageName, Map override) {
494 dependencyOverrideSection.write(" $packageName:\n"); 518 dependencyOverrideSection.write(" $packageName:\n");
495 override.forEach((overrideKey, overrideValue) { 519 override.forEach((overrideKey, overrideValue) {
496 dependencyOverrideSection 520 dependencyOverrideSection
497 .write(" $overrideKey: $overrideValue\n"); 521 .write(" $overrideKey: $overrideValue\n");
498 }); 522 });
499 }); 523 });
500 } 524 }
501 var modifiedYamlString = "$yamlString\n$dependencyOverrideSection"; 525 var modifiedYamlString = "$yamlString\n$dependencyOverrideSection";
502 return destinationFile.writeAsString(modifiedYamlString).then((_) { 526 return destinationFile.writeAsString(modifiedYamlString).then((_) {
503 lockfile.exists().then((bool lockfileExists) { 527 lockfile.exists().then((bool lockfileExists) {
(...skipping 2523 matching lines...) Expand 10 before | Expand all | Expand 10 after
3027 } 3051 }
3028 } 3052 }
3029 3053
3030 void eventAllTestsDone() { 3054 void eventAllTestsDone() {
3031 for (var listener in _eventListener) { 3055 for (var listener in _eventListener) {
3032 listener.allDone(); 3056 listener.allDone();
3033 } 3057 }
3034 _allDone(); 3058 _allDone();
3035 } 3059 }
3036 } 3060 }
OLDNEW
« no previous file with comments | « tools/.packages ('k') | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698