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

Unified Diff: tools/testing/dart/test_runner.dart

Issue 2019163002: 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, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/.packages ('k') | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/test_runner.dart
diff --git a/tools/testing/dart/test_runner.dart b/tools/testing/dart/test_runner.dart
index e9fed49b077cde5ea16598a2fcf9dcd1eb88d0a4..3f755dda9cf4109fa282b869ab3ce63d73041aac 100644
--- a/tools/testing/dart/test_runner.dart
+++ b/tools/testing/dart/test_runner.dart
@@ -18,6 +18,9 @@ import "dart:convert" show LineSplitter, UTF8, JSON;
// CommandOutput.exitCode in subclasses of CommandOutput.
import "dart:io" as io;
import "dart:math" as math;
+
+import 'package:yaml/yaml.dart';
+
import 'android.dart';
import 'dependency_graph.dart' as dgraph;
import "browser_controller.dart";
@@ -463,13 +466,33 @@ class ModifyPubspecYamlCommand extends ScriptCommand {
String _destinationFile;
Map<String, Map> _dependencyOverrides;
- ModifyPubspecYamlCommand._(
- this._pubspecYamlFile, this._destinationFile, this._dependencyOverrides)
+ ModifyPubspecYamlCommand._(this._pubspecYamlFile,
+ this._destinationFile, this._dependencyOverrides)
: super._("modify_pubspec") {
assert(_pubspecYamlFile.endsWith("pubspec.yaml"));
assert(_destinationFile.endsWith("pubspec.yaml"));
}
+ static Map<String, Map> _filterOverrides(
+ String pubspec, Map<String, Map> overrides) {
+ if (overrides.isEmpty) return overrides;
+ var yaml = loadYaml(pubspec);
+ var deps = yaml['dependencies'];
+ var filteredOverrides = <String, Map>{};
+ if (deps != null) {
+ for (var d in deps.keys) {
+ if (!overrides.containsKey(d)) {
+ // pub depends on compiler_unsupported instead of compiler
+ // The dependency is so hackish that we currently ignore it here.
+ if (d == 'compiler_unsupported') continue;
+ throw "Repo doesn't have package $d used in $pubspec";
+ }
+ filteredOverrides[d] = overrides[d];
+ }
+ }
+ return filteredOverrides;
+ }
+
String get reproductionCommand =>
"Adding necessary dependency overrides to '$_pubspecYamlFile' "
"(destination = $_destinationFile).";
@@ -485,12 +508,13 @@ class ModifyPubspecYamlCommand extends ScriptCommand {
var destinationFile = new io.File(_destinationFile);
var lockfile = new io.File(pubspecLockFile);
return file.readAsString().then((String yamlString) {
+ var overrides = _filterOverrides(yamlString, _dependencyOverrides);
var dependencyOverrideSection = new StringBuffer();
if (_dependencyOverrides.isNotEmpty) {
dependencyOverrideSection.write("\n"
"# This section was autogenerated by test.py!\n"
"dependency_overrides:\n");
- _dependencyOverrides.forEach((String packageName, Map override) {
+ overrides.forEach((String packageName, Map override) {
dependencyOverrideSection.write(" $packageName:\n");
override.forEach((overrideKey, overrideValue) {
dependencyOverrideSection
« 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