Index: third_party/pkg/barback-0.13.0/test/utils.dart |
diff --git a/pkg/barback/test/utils.dart b/third_party/pkg/barback-0.13.0/test/utils.dart |
similarity index 91% |
copy from pkg/barback/test/utils.dart |
copy to third_party/pkg/barback-0.13.0/test/utils.dart |
index 4fa3d3f2357919f5c03a8dfd67825049be6ee4dc..7a77f1bddd27dcbf89415413a13f7e5e5c2c8c8e 100644 |
--- a/pkg/barback/test/utils.dart |
+++ b/third_party/pkg/barback-0.13.0/test/utils.dart |
@@ -5,11 +5,12 @@ |
library barback.test.utils; |
import 'dart:async'; |
+import 'dart:collection'; |
import 'dart:convert' show Encoding; |
import 'package:barback/barback.dart'; |
+import 'package:barback/src/cancelable_future.dart'; |
import 'package:barback/src/utils.dart'; |
-import 'package:barback/src/utils/cancelable_future.dart'; |
import 'package:path/path.dart' as pathos; |
import 'package:scheduled_test/scheduled_test.dart'; |
import 'package:stack_trace/stack_trace.dart'; |
@@ -22,22 +23,15 @@ export 'transformer/check_content.dart'; |
export 'transformer/check_content_and_rename.dart'; |
export 'transformer/conditionally_consume_primary.dart'; |
export 'transformer/create_asset.dart'; |
-export 'transformer/declare_assets.dart'; |
-export 'transformer/declaring_bad.dart'; |
-export 'transformer/declaring_check_content_and_rename.dart'; |
-export 'transformer/declaring_rewrite.dart'; |
export 'transformer/emit_nothing.dart'; |
export 'transformer/has_input.dart'; |
-export 'transformer/lazy_assets.dart'; |
export 'transformer/lazy_bad.dart'; |
-export 'transformer/lazy_check_content_and_rename.dart'; |
export 'transformer/lazy_many_to_one.dart'; |
export 'transformer/lazy_rewrite.dart'; |
export 'transformer/many_to_one.dart'; |
export 'transformer/mock.dart'; |
export 'transformer/one_to_many.dart'; |
export 'transformer/rewrite.dart'; |
-export 'transformer/sync_rewrite.dart'; |
var _configured = false; |
@@ -81,7 +75,30 @@ void initGraph([assets, |
if (assets == null) assets = []; |
if (transformers == null) transformers = {}; |
- _provider = new MockProvider(assets, additionalPackages: transformers.keys); |
+ var assetList; |
+ if (assets is Map) { |
+ assetList = assets.keys.map((asset) { |
+ var id = new AssetId.parse(asset); |
+ return new _MockAsset(id, assets[asset]); |
+ }); |
+ } else if (assets is Iterable) { |
+ assetList = assets.map((asset) { |
+ var id = new AssetId.parse(asset); |
+ var contents = pathos.basenameWithoutExtension(id.path); |
+ return new _MockAsset(id, contents); |
+ }); |
+ } |
+ |
+ var assetMap = mapMapValues(groupBy(assetList, (asset) => asset.id.package), |
+ (package, assets) => new AssetSet.from(assets)); |
+ |
+ // Make sure that packages that have transformers but no assets are considered |
+ // by MockProvider to exist. |
+ for (var package in transformers.keys) { |
+ assetMap.putIfAbsent(package, () => new AssetSet()); |
+ } |
+ |
+ _provider = new MockProvider(assetMap); |
_barback = new Barback(_provider); |
// Add a dummy listener to the log so it doesn't print to stdout. |
_barback.log.listen((_) {}); |
@@ -464,7 +481,7 @@ Future _futureShouldNotCompleteUntil(Future future, Future delay, |
class MockProvider implements PackageProvider { |
Iterable<String> get packages => _assets.keys; |
- final Map<String, AssetSet> _assets; |
+ Map<String, AssetSet> _assets; |
/// The set of assets for which [MockLoadException]s should be emitted if |
/// they're loaded. |
@@ -488,40 +505,13 @@ class MockProvider implements PackageProvider { |
_pauseCompleter = null; |
} |
- MockProvider(assets, {Iterable<String> additionalPackages}) |
- : _assets = _normalizeAssets(assets, additionalPackages); |
- |
- static Map<String, AssetSet> _normalizeAssets(assets, |
- Iterable<String> additionalPackages) { |
- var assetList; |
- if (assets is Map) { |
- assetList = assets.keys.map((asset) { |
- var id = new AssetId.parse(asset); |
- return new _MockAsset(id, assets[asset]); |
- }); |
- } else if (assets is Iterable) { |
- assetList = assets.map((asset) { |
- var id = new AssetId.parse(asset); |
- var contents = pathos.basenameWithoutExtension(id.path); |
- return new _MockAsset(id, contents); |
- }); |
- } |
- |
- var assetMap = mapMapValues(groupBy(assetList, (asset) => asset.id.package), |
- (package, assets) => new AssetSet.from(assets)); |
- |
- // Make sure that packages that have transformers but no assets are |
- // considered by MockProvider to exist. |
- if (additionalPackages != null) { |
- for (var package in additionalPackages) { |
- assetMap.putIfAbsent(package, () => new AssetSet()); |
- } |
- } |
- |
+ MockProvider(this._assets) { |
// If there are no assets or transformers, add a dummy package. This better |
// simulates the real world, where there'll always be at least the |
// entrypoint package. |
- return assetMap.isEmpty ? {"app": new AssetSet()} : assetMap; |
+ if (_assets.isEmpty) { |
+ _assets = {"app": new AssetSet()}; |
+ } |
} |
void _modifyAsset(String name, String contents) { |