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

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

Issue 2017093004: Revert "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
24 import 'android.dart'; 21 import 'android.dart';
25 import 'dependency_graph.dart' as dgraph; 22 import 'dependency_graph.dart' as dgraph;
26 import "browser_controller.dart"; 23 import "browser_controller.dart";
27 import "path.dart"; 24 import "path.dart";
28 import "status_file_parser.dart"; 25 import "status_file_parser.dart";
29 import "test_progress.dart"; 26 import "test_progress.dart";
30 import "test_suite.dart"; 27 import "test_suite.dart";
31 import "utils.dart"; 28 import "utils.dart";
32 import 'record_and_replay.dart'; 29 import 'record_and_replay.dart';
33 30
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 String _destinationFile; 463 String _destinationFile;
467 Map<String, Map> _dependencyOverrides; 464 Map<String, Map> _dependencyOverrides;
468 465
469 ModifyPubspecYamlCommand._( 466 ModifyPubspecYamlCommand._(
470 this._pubspecYamlFile, this._destinationFile, this._dependencyOverrides) 467 this._pubspecYamlFile, this._destinationFile, this._dependencyOverrides)
471 : super._("modify_pubspec") { 468 : super._("modify_pubspec") {
472 assert(_pubspecYamlFile.endsWith("pubspec.yaml")); 469 assert(_pubspecYamlFile.endsWith("pubspec.yaml"));
473 assert(_destinationFile.endsWith("pubspec.yaml")); 470 assert(_destinationFile.endsWith("pubspec.yaml"));
474 } 471 }
475 472
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
496 String get reproductionCommand => 473 String get reproductionCommand =>
497 "Adding necessary dependency overrides to '$_pubspecYamlFile' " 474 "Adding necessary dependency overrides to '$_pubspecYamlFile' "
498 "(destination = $_destinationFile)."; 475 "(destination = $_destinationFile).";
499 476
500 Future<ScriptCommandOutputImpl> run() { 477 Future<ScriptCommandOutputImpl> run() {
501 var watch = new Stopwatch()..start(); 478 var watch = new Stopwatch()..start();
502 479
503 var pubspecLockFile = _destinationFile.substring( 480 var pubspecLockFile = _destinationFile.substring(
504 0, _destinationFile.length - ".yaml".length) + 481 0, _destinationFile.length - ".yaml".length) +
505 ".lock"; 482 ".lock";
506 483
507 var file = new io.File(_pubspecYamlFile); 484 var file = new io.File(_pubspecYamlFile);
508 var destinationFile = new io.File(_destinationFile); 485 var destinationFile = new io.File(_destinationFile);
509 var lockfile = new io.File(pubspecLockFile); 486 var lockfile = new io.File(pubspecLockFile);
510 return file.readAsString().then((String yamlString) { 487 return file.readAsString().then((String yamlString) {
511 var overrides = _filterOverrides(yamlString, _dependencyOverrides);
512 var dependencyOverrideSection = new StringBuffer(); 488 var dependencyOverrideSection = new StringBuffer();
513 if (_dependencyOverrides.isNotEmpty) { 489 if (_dependencyOverrides.isNotEmpty) {
514 dependencyOverrideSection.write("\n" 490 dependencyOverrideSection.write("\n"
515 "# This section was autogenerated by test.py!\n" 491 "# This section was autogenerated by test.py!\n"
516 "dependency_overrides:\n"); 492 "dependency_overrides:\n");
517 overrides.forEach((String packageName, Map override) { 493 _dependencyOverrides.forEach((String packageName, Map override) {
518 dependencyOverrideSection.write(" $packageName:\n"); 494 dependencyOverrideSection.write(" $packageName:\n");
519 override.forEach((overrideKey, overrideValue) { 495 override.forEach((overrideKey, overrideValue) {
520 dependencyOverrideSection 496 dependencyOverrideSection
521 .write(" $overrideKey: $overrideValue\n"); 497 .write(" $overrideKey: $overrideValue\n");
522 }); 498 });
523 }); 499 });
524 } 500 }
525 var modifiedYamlString = "$yamlString\n$dependencyOverrideSection"; 501 var modifiedYamlString = "$yamlString\n$dependencyOverrideSection";
526 return destinationFile.writeAsString(modifiedYamlString).then((_) { 502 return destinationFile.writeAsString(modifiedYamlString).then((_) {
527 lockfile.exists().then((bool lockfileExists) { 503 lockfile.exists().then((bool lockfileExists) {
(...skipping 2523 matching lines...) Expand 10 before | Expand all | Expand 10 after
3051 } 3027 }
3052 } 3028 }
3053 3029
3054 void eventAllTestsDone() { 3030 void eventAllTestsDone() {
3055 for (var listener in _eventListener) { 3031 for (var listener in _eventListener) {
3056 listener.allDone(); 3032 listener.allDone();
3057 } 3033 }
3058 _allDone(); 3034 _allDone();
3059 } 3035 }
3060 } 3036 }
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