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..4acf11c088097f21b7a603874b27f272aa30171f 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"; |
@@ -470,6 +473,26 @@ class ModifyPubspecYamlCommand extends ScriptCommand { |
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 |