Roll to pickup pool changes
BUG=
R=rmacnak@google.com
Review-Url: https://codereview.chromium.org//3014633002 .
diff --git a/packages/barback/.status b/packages/barback/.status
index cc86fa3..8ea2f4a 100644
--- a/packages/barback/.status
+++ b/packages/barback/.status
@@ -17,7 +17,7 @@
[ $runtime == vm && $mode == debug]
build/test/package_graph/repetition_test: Skip # Times out
-[ $runtime == vm && ( $arch == simarm || $arch == simmips ) ]
+[ $runtime == vm && $arch == simarm ]
build/test/too_many_open_files_test: Skip # 14220
[ $browser ]
diff --git a/packages/barback/CHANGELOG.md b/packages/barback/CHANGELOG.md
index 7101619..b26e554 100644
--- a/packages/barback/CHANGELOG.md
+++ b/packages/barback/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.15.2+12
+
+* Declare support for `async` 2.0.0.
+
## 0.15.2+11
* Update `AssetNode.whenAvailable` to be a generic method to fix a new strong
diff --git a/packages/barback/example/aggregate_transformer/lib/transformer.dart b/packages/barback/example/aggregate_transformer/lib/transformer.dart
index 35634dc..f96701c 100644
--- a/packages/barback/example/aggregate_transformer/lib/transformer.dart
+++ b/packages/barback/example/aggregate_transformer/lib/transformer.dart
@@ -16,7 +16,6 @@
// to handle. Return a value for the assets you want to handle,
// or null for those that you do not want to handle.
classifyPrimary(AssetId id) {
-
// Only process assets where the filename ends with "recipe.html".
if (!id.path.endsWith('recipe.html')) return null;
diff --git a/packages/barback/example/lazy_transformer/lib/transformer.dart b/packages/barback/example/lazy_transformer/lib/transformer.dart
index aaee46f..02bfd8a 100644
--- a/packages/barback/example/lazy_transformer/lib/transformer.dart
+++ b/packages/barback/example/lazy_transformer/lib/transformer.dart
@@ -7,14 +7,13 @@
import 'dart:async';
class CodedMessageConverter extends Transformer implements LazyTransformer {
-
// A constructor named "asPlugin" is required. It can be empty, but
// it must be present.
CodedMessageConverter.asPlugin();
Future<bool> isPrimary(AssetId id) async => id.extension == '.txt';
- Future declareOutputs(DeclaringTransform transform) {
+ void declareOutputs(DeclaringTransform transform) {
transform.declareOutput(transform.primaryId.changeExtension('.shhhhh'));
}
@@ -33,10 +32,15 @@
rot13(var ch) {
var c = ch.codeUnitAt(0);
- if (c >= 'a'.codeUnitAt(0) && c <= 'm'.codeUnitAt(0)) c += 13;
- else if (c >= 'A'.codeUnitAt(0) && c <= 'M'.codeUnitAt(0)) c += 13;
- else if (c >= 'n'.codeUnitAt(0) && c <= 'z'.codeUnitAt(0)) c -= 13;
- else if (c >= 'N'.codeUnitAt(0) && c <= 'Z'.codeUnitAt(0)) c -= 13;
+ if (c >= 'a'.codeUnitAt(0) && c <= 'm'.codeUnitAt(0)) {
+ c += 13;
+ } else if (c >= 'A'.codeUnitAt(0) && c <= 'M'.codeUnitAt(0)) {
+ c += 13;
+ } else if (c >= 'n'.codeUnitAt(0) && c <= 'z'.codeUnitAt(0)) {
+ c -= 13;
+ } else if (c >= 'N'.codeUnitAt(0) && c <= 'Z'.codeUnitAt(0)) {
+ c -= 13;
+ }
return new String.fromCharCode(c);
}
}
diff --git a/packages/barback/example/markdown_converter/lib/transformer.dart b/packages/barback/example/markdown_converter/lib/transformer.dart
index dcbdd8c..8161768 100644
--- a/packages/barback/example/markdown_converter/lib/transformer.dart
+++ b/packages/barback/example/markdown_converter/lib/transformer.dart
@@ -8,7 +8,6 @@
import 'dart:async';
class ConvertMarkdown extends Transformer {
-
// A constructor named "asPlugin" is required. It can be empty, but
// it must be present. It is how pub determines that you want this
// class to be publicly available as a loadable transformer plugin.
diff --git a/packages/barback/lib/src/asset/asset.dart b/packages/barback/lib/src/asset/asset.dart
index c0f11ba..15794e5 100644
--- a/packages/barback/lib/src/asset/asset.dart
+++ b/packages/barback/lib/src/asset/asset.dart
@@ -24,14 +24,12 @@
factory Asset.fromBytes(AssetId id, List<int> bytes) =>
new BinaryAsset(id, bytes);
- factory Asset.fromFile(AssetId id, File file) =>
- new FileAsset(id, file.path);
+ factory Asset.fromFile(AssetId id, File file) => new FileAsset(id, file.path);
factory Asset.fromString(AssetId id, String content) =>
new StringAsset(id, content);
- factory Asset.fromPath(AssetId id, String path) =>
- new FileAsset(id, path);
+ factory Asset.fromPath(AssetId id, String path) => new FileAsset(id, path);
factory Asset.fromStream(AssetId id, Stream<List<int>> stream) =>
new StreamAsset(id, stream);
diff --git a/packages/barback/lib/src/asset/asset_id.dart b/packages/barback/lib/src/asset/asset_id.dart
index adb2247..ee62280 100644
--- a/packages/barback/lib/src/asset/asset_id.dart
+++ b/packages/barback/lib/src/asset/asset_id.dart
@@ -30,8 +30,7 @@
/// The [path] will be normalized: any backslashes will be replaced with
/// forward slashes (regardless of host OS) and "." and ".." will be removed
/// where possible.
- AssetId(this.package, String path)
- : path = _normalizePath(path);
+ AssetId(this.package, String path) : path = _normalizePath(path);
/// Parses an [AssetId] string of the form "package|path/to/asset.txt".
///
@@ -50,8 +49,7 @@
}
if (parts[1].isEmpty) {
- throw new FormatException(
- 'Cannot have empty path in "$description".');
+ throw new FormatException('Cannot have empty path in "$description".');
}
return new AssetId(parts[0], parts[1]);
@@ -69,9 +67,7 @@
/// Returns `true` of [other] is an [AssetId] with the same package and path.
operator ==(other) =>
- other is AssetId &&
- package == other.package &&
- path == other.path;
+ other is AssetId && package == other.package && path == other.path;
int get hashCode => package.hashCode ^ path.hashCode;
@@ -108,4 +104,4 @@
// Collapse "." and "..".
return pathos.posix.normalize(path);
-}
\ No newline at end of file
+}
diff --git a/packages/barback/lib/src/asset/asset_node.dart b/packages/barback/lib/src/asset/asset_node.dart
index a9e0000..629599c 100644
--- a/packages/barback/lib/src/asset/asset_node.dart
+++ b/packages/barback/lib/src/asset/asset_node.dart
@@ -59,8 +59,8 @@
/// Whether this node is lazy, meaning that [force] must be called to
/// guarantee that it will eventually become available.
- bool get isLazy => _lazyCallback != null ||
- (_origin != null && _origin.isLazy);
+ bool get isLazy =>
+ _lazyCallback != null || (_origin != null && _origin.isLazy);
/// A broadcast stream that emits an event whenever the node changes state.
///
@@ -83,7 +83,7 @@
/// The return value of [callback] is piped to the returned Future. If the
/// asset is removed before becoming available, the returned future will throw
/// an [AssetNotFoundException].
- Future/*<T>*/ whenAvailable/*<T>*/(/*=T*/ callback(Asset asset)) {
+ Future<T> whenAvailable<T>(T callback(Asset asset)) {
return _waitForState((state) => state.isAvailable || state.isRemoved,
(state) {
if (state.isRemoved) throw new AssetNotFoundException(id);
@@ -98,7 +98,7 @@
///
/// The return value of [callback] is piped to the returned Future.
Future whenRemoved(callback()) =>
- _waitForState((state) => state.isRemoved, (_) => callback());
+ _waitForState((state) => state.isRemoved, (_) => callback());
/// Returns a [Future] that completes when [state] changes from its current
/// value to any other value.
@@ -114,8 +114,8 @@
/// [callback] is called synchronously if this is already in such a state.
///
/// The return value of [callback] is piped to the returned Future.
- Future/*<T>*/ _waitForState/*<T>*/(bool test(AssetState state),
- /*=T*/ callback(AssetState state)) {
+ Future<T> _waitForState<T>(
+ bool test(AssetState state), T callback(AssetState state)) {
if (test(state)) return new Future.sync(() => callback(state));
return onStateChange.firstWhere(test).then((_) => callback(state));
}
@@ -172,7 +172,7 @@
///
/// [callback] is guaranteed to only fire once.
AssetNodeController.lazy(AssetId id, void callback(),
- [TransformNode transform])
+ [TransformNode transform])
: node = new AssetNode._lazy(id, transform, null, callback);
/// Creates a controller for a node whose initial state matches the current
diff --git a/packages/barback/lib/src/asset/asset_node_set.dart b/packages/barback/lib/src/asset/asset_node_set.dart
index a1fc17b..da55c23 100644
--- a/packages/barback/lib/src/asset/asset_node_set.dart
+++ b/packages/barback/lib/src/asset/asset_node_set.dart
@@ -19,8 +19,7 @@
/// A map from asset ids to assets in the set.
final _assetsById = new Map<AssetId, AssetNode>();
- AssetNodeSet()
- : super(new Set());
+ AssetNodeSet() : super(new Set());
/// Returns the asset node in the set with [id], or `null` if none exists.
AssetNode operator [](AssetId id) => _assetsById[id];
@@ -39,4 +38,4 @@
bool containsId(AssetId id) => _assetsById.containsKey(id);
void addAll(Iterable<AssetNode> nodes) => nodes.forEach(add);
-}
\ No newline at end of file
+}
diff --git a/packages/barback/lib/src/asset/asset_set.dart b/packages/barback/lib/src/asset/asset_set.dart
index a529443..f4ad47c 100644
--- a/packages/barback/lib/src/asset/asset_set.dart
+++ b/packages/barback/lib/src/asset/asset_set.dart
@@ -37,7 +37,7 @@
/// Gets the [Asset] in the set with [id], or returns `null` if no asset with
/// that ID is present.
- Asset operator[](AssetId id) => _assets[id];
+ Asset operator [](AssetId id) => _assets[id];
/// Adds [asset] to the set.
///
diff --git a/packages/barback/lib/src/asset/internal_asset.dart b/packages/barback/lib/src/asset/internal_asset.dart
index ed7f309..ead30c4 100644
--- a/packages/barback/lib/src/asset/internal_asset.dart
+++ b/packages/barback/lib/src/asset/internal_asset.dart
@@ -22,23 +22,11 @@
Map serializeAsset(Asset asset) {
var id = serializeId(asset.id);
if (asset is BinaryAsset) {
- return {
- 'type': 'binary',
- 'id': id,
- 'contents': asset._contents
- };
+ return {'type': 'binary', 'id': id, 'contents': asset._contents};
} else if (asset is FileAsset) {
- return {
- 'type': 'file',
- 'id': id,
- 'path': asset._path
- };
+ return {'type': 'file', 'id': id, 'path': asset._path};
} else if (asset is StringAsset) {
- return {
- 'type': 'string',
- 'id': id,
- 'contents': asset._contents
- };
+ return {'type': 'string', 'id': id, 'contents': asset._contents};
} else {
// [asset] is probably a [StreamAsset], but it's possible that the user has
// created a custom subclass, in which case we just serialize the stream
@@ -58,8 +46,10 @@
case 'binary':
return new BinaryAsset(
id, DelegatingList.typed(asset['contents'] as List));
- case 'file': return new FileAsset(id, asset['path']);
- case 'string': return new StringAsset(id, asset['contents']);
+ case 'file':
+ return new FileAsset(id, asset['path']);
+ case 'string':
+ return new StringAsset(id, asset['contents']);
case 'stream':
return new StreamAsset(
id, DelegatingStream.typed(deserializeStream(asset['stream'])));
@@ -74,8 +64,7 @@
final Uint8List _contents;
- BinaryAsset(this.id, List<int> contents)
- : _contents = toUint8List(contents);
+ BinaryAsset(this.id, List<int> contents) : _contents = toUint8List(contents);
Future<String> readAsString({Encoding encoding}) {
if (encoding == null) encoding = UTF8;
@@ -153,8 +142,9 @@
// Don't show the whole string if it's long.
var contents = _contents;
if (contents.length > 40) {
- contents = contents.substring(0, 20) + " ... " +
- contents.substring(contents.length - 20);
+ contents = contents.substring(0, 20) +
+ " ... " +
+ contents.substring(contents.length - 20);
}
contents = _escape(contents);
@@ -183,7 +173,10 @@
Future<String> readAsString({Encoding encoding}) {
if (encoding == null) encoding = UTF8;
- return _replayer.getReplay().expand((chunk) => chunk).toList()
+ return _replayer
+ .getReplay()
+ .expand((chunk) => chunk)
+ .toList()
.then((bytes) => encoding.decode(bytes));
}
diff --git a/packages/barback/lib/src/barback.dart b/packages/barback/lib/src/barback.dart
index 98d1154..d116939 100644
--- a/packages/barback/lib/src/barback.dart
+++ b/packages/barback/lib/src/barback.dart
@@ -71,8 +71,7 @@
/// Otherwise, a default logger will display them.
Stream<LogEntry> get log => _graph.log;
- Barback(PackageProvider provider)
- : _graph = new PackageGraph(provider);
+ Barback(PackageProvider provider) : _graph = new PackageGraph(provider);
/// Gets the asset identified by [id].
///
diff --git a/packages/barback/lib/src/build_result.dart b/packages/barback/lib/src/build_result.dart
index fff2e24..b19821c 100644
--- a/packages/barback/lib/src/build_result.dart
+++ b/packages/barback/lib/src/build_result.dart
@@ -29,8 +29,7 @@
/// Creates a build result indicating a successful build.
///
/// This equivalent to a build result with no errors.
- BuildResult.success()
- : this([]);
+ BuildResult.success() : this([]);
/// Creates a single [BuildResult] that contains all of the errors of
/// [results].
@@ -42,22 +41,23 @@
String toString() {
if (succeeded) return "success";
- return "errors:\n" + errors.map((error) {
- var stackTrace = null;
- if (error is TransformerException) {
- stackTrace = error.stackTrace.terse;
- } else if (error is AssetLoadException) {
- stackTrace = error.stackTrace.terse;
- }
+ return "errors:\n" +
+ errors.map((error) {
+ var stackTrace = null;
+ if (error is TransformerException) {
+ stackTrace = error.stackTrace.terse;
+ } else if (error is AssetLoadException) {
+ stackTrace = error.stackTrace.terse;
+ }
- var msg = new StringBuffer();
- msg.write(prefixLines(error.toString()));
- if (stackTrace != null) {
- msg.write("\n\n");
- msg.write("Stack chain:\n");
- msg.write(prefixLines(stackTrace.toString()));
- }
- return msg.toString();
- }).join("\n\n");
+ var msg = new StringBuffer();
+ msg.write(prefixLines(error.toString()));
+ if (stackTrace != null) {
+ msg.write("\n\n");
+ msg.write("Stack chain:\n");
+ msg.write(prefixLines(stackTrace.toString()));
+ }
+ return msg.toString();
+ }).join("\n\n");
}
}
diff --git a/packages/barback/lib/src/errors.dart b/packages/barback/lib/src/errors.dart
index 96cfbc7..19dcb3b 100644
--- a/packages/barback/lib/src/errors.dart
+++ b/packages/barback/lib/src/errors.dart
@@ -60,8 +60,8 @@
buffer.writeln("Multiple errors occurred:\n");
for (var error in errors) {
- buffer.writeln(prefixLines(error.toString(),
- prefix: " ", firstPrefix: "- "));
+ buffer.writeln(
+ prefixLines(error.toString(), prefix: " ", firstPrefix: "- "));
}
return buffer.toString();
@@ -178,10 +178,11 @@
final AssetId primaryId;
TransformInfo(transformer, this.primaryId)
- : transformer = transformer is WrappingAggregateTransformer ?
- transformer.transformer : transformer;
+ : transformer = transformer is WrappingAggregateTransformer
+ ? transformer.transformer
+ : transformer;
- bool operator==(other) =>
+ bool operator ==(other) =>
other is TransformInfo &&
other.transformer == transformer &&
other.primaryId == primaryId;
diff --git a/packages/barback/lib/src/graph/asset_cascade.dart b/packages/barback/lib/src/graph/asset_cascade.dart
index d307b87..c9a93b2 100644
--- a/packages/barback/lib/src/graph/asset_cascade.dart
+++ b/packages/barback/lib/src/graph/asset_cascade.dart
@@ -197,8 +197,8 @@
_phases.removeRange(transformers.length + 1, _phases.length);
_phaseStatusSubscription.cancel();
- _phaseStatusSubscription = _phases.last.onStatusChange
- .listen(_streams.changeStatus);
+ _phaseStatusSubscription =
+ _phases.last.onStatusChange.listen(_streams.changeStatus);
_streams.onAssetPool.add(_phases.last.onAsset);
}
diff --git a/packages/barback/lib/src/graph/node_status.dart b/packages/barback/lib/src/graph/node_status.dart
index a42e523..71fdfec 100644
--- a/packages/barback/lib/src/graph/node_status.dart
+++ b/packages/barback/lib/src/graph/node_status.dart
@@ -37,9 +37,8 @@
final String _name;
/// Returns the dirtiest status in [statuses].
- static NodeStatus dirtiest(Iterable<NodeStatus> statuses) =>
- statuses.fold(NodeStatus.IDLE,
- (status1, status2) => status1.dirtier(status2));
+ static NodeStatus dirtiest(Iterable<NodeStatus> statuses) => statuses.fold(
+ NodeStatus.IDLE, (status1, status2) => status1.dirtier(status2));
const NodeStatus(this._name);
@@ -51,4 +50,4 @@
if (this == MATERIALIZING || other == MATERIALIZING) return MATERIALIZING;
return IDLE;
}
-}
\ No newline at end of file
+}
diff --git a/packages/barback/lib/src/graph/package_graph.dart b/packages/barback/lib/src/graph/package_graph.dart
index 1c2b534..8eec163 100644
--- a/packages/barback/lib/src/graph/package_graph.dart
+++ b/packages/barback/lib/src/graph/package_graph.dart
@@ -57,8 +57,8 @@
final _logController = new StreamController<LogEntry>.broadcast(sync: true);
/// How far along [this] is in processing its assets.
- NodeStatus get _status => NodeStatus.dirtiest(
- _cascades.values.map((cascade) => cascade.status));
+ NodeStatus get _status =>
+ NodeStatus.dirtiest(_cascades.values.map((cascade) => cascade.status));
/// Whether a [BuildResult] is scheduled to be emitted on [results] (see
/// [_tryScheduleResult]).
@@ -127,7 +127,7 @@
///
/// If the asset cannot be found, returns null.
Future<AssetNode> getAssetNode(AssetId id) {
- return _inErrorZone/*<Future<AssetNode>>*/(() {
+ return _inErrorZone<Future<AssetNode>>(() {
var cascade = _cascades[id.package];
if (cascade != null) return cascade.getAssetNode(id);
return new Future.value(null);
@@ -158,7 +158,7 @@
if (_status != NodeStatus.IDLE) {
// A build is still ongoing, so wait for it to complete and try again.
- return results.first.then/*<Future<AssetSet>>*/((_) => getAllAssets());
+ return results.first.then<Future<AssetSet>>((_) => getAllAssets());
}
// If an unexpected error occurred, complete with that.
@@ -174,9 +174,9 @@
}
// Otherwise, return all of the final output assets.
- return Future.wait(_cascades.values.map(
- (cascade) => cascade.availableOutputs))
- .then((assetSets) {
+ return Future
+ .wait(_cascades.values.map((cascade) => cascade.availableOutputs))
+ .then((assetSets) {
var assets = unionAll(assetSets.map((assetSet) => assetSet.toSet()));
return new AssetSet.from(assets);
});
@@ -225,8 +225,8 @@
void _onLog(LogEntry entry) {
if (entry.level == LogLevel.ERROR) {
// TODO(nweiz): keep track of stack chain.
- _accumulatedErrors.add(
- new TransformerException(entry.transform, entry.message, null));
+ _accumulatedErrors
+ .add(new TransformerException(entry.transform, entry.message, null));
}
if (_logController.hasListener) {
@@ -274,10 +274,11 @@
/// [Future]. If it throws a [BarbackException], that exception will be piped
/// to the returned [Future] as well. Any other exceptions will be piped to
/// [results].
- Future/*<T>*/ _inErrorZone/*<T>*/(/*=T*/ body()) {
- var completer = new Completer/*<T>*/.sync();
+ Future<T> _inErrorZone<T>(T body()) {
+ var completer = new Completer<T>.sync();
runZoned(() {
- new Future.sync(body).then(completer.complete)
+ new Future.sync(body)
+ .then(completer.complete)
.catchError((error, stackTrace) {
if (error is! BarbackException) throw error;
completer.completeError(error, stackTrace);
diff --git a/packages/barback/lib/src/graph/phase.dart b/packages/barback/lib/src/graph/phase.dart
index 629291a..fd5ad61 100644
--- a/packages/barback/lib/src/graph/phase.dart
+++ b/packages/barback/lib/src/graph/phase.dart
@@ -92,14 +92,15 @@
// Before any transformers are added, the phase should be dirty if and only
// if any input is dirty.
if (_classifiers.isEmpty && _groups.isEmpty && previous == null) {
- return _inputs.any((input) => input.state.isDirty) ?
- NodeStatus.RUNNING : NodeStatus.IDLE;
+ return _inputs.any((input) => input.state.isDirty)
+ ? NodeStatus.RUNNING
+ : NodeStatus.IDLE;
}
- var classifierStatus = NodeStatus.dirtiest(
- _classifiers.values.map((classifier) => classifier.status));
- var groupStatus = NodeStatus.dirtiest(
- _groups.values.map((group) => group.status));
+ var classifierStatus = NodeStatus
+ .dirtiest(_classifiers.values.map((classifier) => classifier.status));
+ var groupStatus =
+ NodeStatus.dirtiest(_groups.values.map((group) => group.status));
return (previous == null ? NodeStatus.IDLE : previous.status)
.dirtier(classifierStatus)
.dirtier(groupStatus);
@@ -134,14 +135,13 @@
// TODO(nweiz): Rather than passing the cascade and the phase everywhere,
// create an interface that just exposes [getInput]. Emit errors via
// [AssetNode]s.
- Phase(AssetCascade cascade, String location)
- : this._(cascade, location, 0);
+ Phase(AssetCascade cascade, String location) : this._(cascade, location, 0);
Phase._(this.cascade, this._location, this._index, [this.previous]) {
if (previous != null) {
_previousOnAssetSubscription = previous.onAsset.listen(addInput);
- _previousStatusSubscription = previous.onStatusChange
- .listen((_) => _streams.changeStatus(status));
+ _previousStatusSubscription =
+ previous.onStatusChange.listen((_) => _streams.changeStatus(status));
}
onStatusChange.listen((status) {
@@ -170,8 +170,8 @@
void addInput(AssetNode node) {
// Each group is one channel along which an asset may be forwarded, as is
// each transformer.
- var forwarder = new PhaseForwarder(
- node, _classifiers.length, _groups.length);
+ var forwarder =
+ new PhaseForwarder(node, _classifiers.length, _groups.length);
_forwarders[node.id] = forwarder;
forwarder.onAsset.listen(_handleOutputWithoutForwarder);
if (forwarder.output != null) {
@@ -203,7 +203,7 @@
/// If [id] is for a generated or transformed asset, this will wait until it
/// has been created and return it. This means that the returned asset will
/// always be [AssetState.AVAILABLE].
- ///
+ ///
/// If the output cannot be found, returns null.
Future<AssetNode> getOutput(AssetId id) {
return new Future.sync(() {
@@ -231,8 +231,8 @@
// Otherwise, store a completer for the asset node. If it's generated in
// the future, we'll complete this completer.
- var completer = _pendingOutputRequests.putIfAbsent(id,
- () => new Completer.sync());
+ var completer =
+ _pendingOutputRequests.putIfAbsent(id, () => new Completer.sync());
return completer.future;
});
}
@@ -248,8 +248,8 @@
}
for (var transformer in newTransformers.difference(oldTransformers)) {
- var classifier = new TransformerClassifier(
- this, transformer, "$_location.$_index");
+ var classifier =
+ new TransformerClassifier(this, transformer, "$_location.$_index");
_classifiers[transformer] = classifier;
classifier.onAsset.listen(_handleOutput);
_streams.onLogPool.add(classifier.onLog);
@@ -259,7 +259,7 @@
}
}
- var newGroups = DelegatingSet.typed/*<TransformerGroup>*/(
+ var newGroups = DelegatingSet.typed<TransformerGroup>(
transformers.where((op) => op is TransformerGroup).toSet());
var oldGroups = _groups.keys.toSet();
for (var removed in oldGroups.difference(newGroups)) {
@@ -354,8 +354,9 @@
_outputs[asset.id].add(asset);
} else {
_outputs[asset.id] = new PhaseOutput(this, asset, "$_location.$_index");
- _outputs[asset.id].onAsset.listen(_emit,
- onDone: () => _outputs.remove(asset.id));
+ _outputs[asset.id]
+ .onAsset
+ .listen(_emit, onDone: () => _outputs.remove(asset.id));
_emit(_outputs[asset.id].output);
}
@@ -387,12 +388,14 @@
// either available or removed before trying again to access it.
assert(asset.state.isDirty);
asset.force();
- asset.whenStateChanges().then((state) {
- if (state.isRemoved) return getOutput(asset.id);
- return asset;
- })
- .then((asset) => request.complete(asset))
- .catchError(request.completeError);
+ asset
+ .whenStateChanges()
+ .then((state) {
+ if (state.isRemoved) return getOutput(asset.id);
+ return asset;
+ })
+ .then((asset) => request.complete(asset))
+ .catchError(request.completeError);
}
String toString() => "phase $_location.$_index";
diff --git a/packages/barback/lib/src/graph/phase_output.dart b/packages/barback/lib/src/graph/phase_output.dart
index 3d6460b..7967d6a 100644
--- a/packages/barback/lib/src/graph/phase_output.dart
+++ b/packages/barback/lib/src/graph/phase_output.dart
@@ -50,7 +50,8 @@
AssetCollisionException get collisionException {
if (_assets.length == 1) return null;
return new AssetCollisionException(
- _assets.where((asset) => asset.transform != null)
+ _assets
+ .where((asset) => asset.transform != null)
.map((asset) => asset.transform.info),
output.id);
}
diff --git a/packages/barback/lib/src/graph/static_asset_cascade.dart b/packages/barback/lib/src/graph/static_asset_cascade.dart
index 4effda5..2c2df8e 100644
--- a/packages/barback/lib/src/graph/static_asset_cascade.dart
+++ b/packages/barback/lib/src/graph/static_asset_cascade.dart
@@ -40,13 +40,17 @@
final status = NodeStatus.IDLE;
- final onLog = new StreamController<LogEntry>.broadcast().stream;
- final onStatusChange = new StreamController<NodeStatus>.broadcast().stream;
- final onAsset = new StreamController<AssetNode>.broadcast().stream;
+ final Stream<LogEntry> onLog = new StreamController.broadcast().stream;
+ final Stream<NodeStatus> onStatusChange =
+ new StreamController.broadcast().stream;
+ final Stream<AssetNode> onAsset = new StreamController.broadcast().stream;
Future<AssetSet> get availableOutputs {
var provider = graph.provider as StaticPackageProvider;
- return provider.getAllAssetIds(package).asyncMap(provider.getAsset).toList()
+ return provider
+ .getAllAssetIds(package)
+ .asyncMap(provider.getAsset)
+ .toList()
.then((assets) => new AssetSet.from(DelegatingList.typed(assets)));
}
diff --git a/packages/barback/lib/src/graph/transform_node.dart b/packages/barback/lib/src/graph/transform_node.dart
index 39f5c52..d2755ca 100644
--- a/packages/barback/lib/src/graph/transform_node.dart
+++ b/packages/barback/lib/src/graph/transform_node.dart
@@ -68,7 +68,8 @@
return NodeStatus.IDLE;
}
- if (_declaring && _state != _State.DECLARING &&
+ if (_declaring &&
+ _state != _State.DECLARING &&
_state != _State.NEEDS_DECLARE) {
return NodeStatus.MATERIALIZING;
} else {
@@ -80,8 +81,8 @@
///
/// [TransformInfo] is the publicly-visible representation of a transform
/// node.
- TransformInfo get info => new TransformInfo(transformer,
- new AssetId(phase.cascade.package, key));
+ TransformInfo get info =>
+ new TransformInfo(transformer, new AssetId(phase.cascade.package, key));
/// Whether this is a declaring transform.
///
@@ -89,7 +90,8 @@
/// DeclaringAggregateTransformer`, but if a declaring and non-lazy
/// transformer emits an error during `declareOutputs` it's treated as though
/// it wasn't declaring.
- bool get _declaring => transformer is DeclaringAggregateTransformer &&
+ bool get _declaring =>
+ transformer is DeclaringAggregateTransformer &&
(_state == _State.DECLARING || _declaredOutputs != null);
/// Whether this transform has been forced since it last finished applying.
@@ -140,7 +142,8 @@
// can run [apply] even if [force] hasn't been called, since [transformer]
// should run eagerly if possible.
bool get _canRunDeclaringEagerly =>
- _declaring && transformer is! LazyAggregateTransformer &&
+ _declaring &&
+ transformer is! LazyAggregateTransformer &&
_primaries.every((input) => input.state.isAvailable);
/// Which primary inputs the most recent run of this transform has declared
@@ -220,8 +223,8 @@
_primaries.add(input);
if (_forced) input.force();
- _primarySubscriptions[input.id] = input.onStateChange
- .listen((_) => _onPrimaryStateChange(input));
+ _primarySubscriptions[input.id] =
+ input.onStateChange.listen((_) => _onPrimaryStateChange(input));
if (_state == _State.DECLARING && !_declareController.isDone) {
// If we're running `declareOutputs` and its id stream isn't closed yet,
@@ -292,7 +295,8 @@
/// being added or removed are handled by [addInput] and
/// [_onPrimaryStateChange].
void _dirty() {
- if (_state == _State.DECLARING || _state == _State.NEEDS_DECLARE ||
+ if (_state == _State.DECLARING ||
+ _state == _State.NEEDS_DECLARE ||
_state == _State.NEEDS_APPLY) {
// If we already know that [_apply] needs to be run, there's nothing to do
// here.
@@ -377,7 +381,8 @@
var controller = _passThroughControllers[input.id];
if (controller != null) controller.setDirty();
- if (_state == _State.APPLYING && !_applyController.addedId(input.id) &&
+ if (_state == _State.APPLYING &&
+ !_applyController.addedId(input.id) &&
(_forced || !input.isLazy)) {
// If the input hasn't yet been added to the transform's input stream,
// there's no need to consider the transformation dirty. However, if the
@@ -472,7 +477,8 @@
_consumedPrimaries = controller.consumedPrimaries;
_declaredOutputs = controller.outputIds;
var invalidIds = _declaredOutputs
- .where((id) => id.package != phase.cascade.package).toSet();
+ .where((id) => id.package != phase.cascade.package)
+ .toSet();
for (var id in invalidIds) {
_declaredOutputs.remove(id);
// TODO(nweiz): report this as a warning rather than a failing error.
@@ -663,11 +669,7 @@
"${_pendingSecondaryInputs.keys.join(", ")}");
}
_streams.onLogController.add(new LogEntry(
- info,
- info.primaryId,
- LogLevel.FINE,
- message.toString(),
- null));
+ info, info.primaryId, LogLevel.FINE, message.toString(), null));
});
return transformer.apply(controller.transform);
@@ -702,17 +704,19 @@
var ranLong = _timeInTransformer.elapsed > new Duration(seconds: 1);
var ranLongLocally =
_timeInTransformer.elapsed - _timeAwaitingInputs.elapsed >
- new Duration(milliseconds: 200);
+ new Duration(milliseconds: 200);
// Report the transformer's timing information if it spent more than 0.2s
// doing things other than waiting for its secondary inputs or if it spent
// more than 1s in total.
if (ranLongLocally || ranLong) {
_streams.onLogController.add(new LogEntry(
- info, info.primaryId, LogLevel.FINE,
+ info,
+ info.primaryId,
+ LogLevel.FINE,
"Took ${niceDuration(_timeInTransformer.elapsed)} "
- "(${niceDuration(_timeAwaitingInputs.elapsed)} awaiting "
- "secondary inputs).",
+ "(${niceDuration(_timeAwaitingInputs.elapsed)} awaiting "
+ "secondary inputs).",
null));
}
diff --git a/packages/barback/lib/src/graph/transformer_classifier.dart b/packages/barback/lib/src/graph/transformer_classifier.dart
index d57f80a..fe14ef7 100644
--- a/packages/barback/lib/src/graph/transformer_classifier.dart
+++ b/packages/barback/lib/src/graph/transformer_classifier.dart
@@ -49,7 +49,7 @@
/// classifying all available inputs.
Stream get onDoneClassifying => _onDoneClassifyingController.stream;
final _onDoneClassifyingController =
- new StreamController.broadcast(sync: true);
+ new StreamController<Null>.broadcast(sync: true);
/// The number of currently-active calls to [transformer.classifyPrimary].
///
@@ -62,13 +62,14 @@
/// How far along [this] is in processing its assets.
NodeStatus get status {
if (isClassifying) return NodeStatus.RUNNING;
- return NodeStatus.dirtiest(
- _transforms.values.map((transform) => transform.status));
+ return NodeStatus
+ .dirtiest(_transforms.values.map((transform) => transform.status));
}
TransformerClassifier(this.phase, transformer, this._location)
- : transformer = transformer is AggregateTransformer ?
- transformer : new WrappingAggregateTransformer(transformer);
+ : transformer = transformer is AggregateTransformer
+ ? transformer
+ : new WrappingAggregateTransformer(transformer);
/// Adds a new asset as an input for this transformer.
void addInput(AssetNode input) {
@@ -93,8 +94,8 @@
if (key == null) {
var forwarder = new AssetForwarder(input);
_passThroughForwarders.add(forwarder);
- forwarder.node.whenRemoved(
- () => _passThroughForwarders.remove(forwarder));
+ forwarder.node
+ .whenRemoved(() => _passThroughForwarders.remove(forwarder));
_streams.onAssetController.add(forwarder.node);
} else if (_transforms.containsKey(key)) {
_transforms[key].addPrimary(input);
@@ -102,8 +103,7 @@
var transform = new TransformNode(this, transformer, key, _location);
_transforms[key] = transform;
- transform.onStatusChange.listen(
- (_) => _streams.changeStatus(status),
+ transform.onStatusChange.listen((_) => _streams.changeStatus(status),
onDone: () {
_transforms.remove(transform.key);
if (!_streams.isClosed) _streams.changeStatus(status);
diff --git a/packages/barback/lib/src/serialize.dart b/packages/barback/lib/src/serialize.dart
index 10cc6fe..c2f7ac4 100644
--- a/packages/barback/lib/src/serialize.dart
+++ b/packages/barback/lib/src/serialize.dart
@@ -23,11 +23,11 @@
stream.listen((data) => sendPort.send({'type': 'data', 'data': data}),
onDone: () => sendPort.send({'type': 'done'}),
onError: (error, stackTrace) {
- sendPort.send({
- 'type': 'error',
- 'error': CrossIsolateException.serialize(error, stackTrace)
- });
- });
+ sendPort.send({
+ 'type': 'error',
+ 'error': CrossIsolateException.serialize(error, stackTrace)
+ });
+ });
});
return receivePort.sendPort;
@@ -45,8 +45,8 @@
return callbackStream(() {
var receivePort = new ReceivePort();
sendPort.send(receivePort.sendPort);
- return receivePort.transform(
- const StreamTransformer(_deserializeTransformer));
+ return receivePort
+ .transform(const StreamTransformer(_deserializeTransformer));
});
}
@@ -54,8 +54,8 @@
/// sent by [serializeStream].
StreamSubscription _deserializeTransformer(Stream input, bool cancelOnError) {
var subscription;
- var transformed = input.transform(new StreamTransformer.fromHandlers(
- handleData: (data, sink) {
+ var transformed = input
+ .transform(new StreamTransformer.fromHandlers(handleData: (data, sink) {
if (data['type'] == 'data') {
sink.add(data['data']);
} else if (data['type'] == 'error') {
@@ -95,8 +95,8 @@
CrossIsolateException.deserialize(Map error)
: type = error['type'],
message = error['message'],
- stackTrace = error['stack'] == null ? null :
- new Chain.parse(error['stack']);
+ stackTrace =
+ error['stack'] == null ? null : new Chain.parse(error['stack']);
/// Serializes [error] to an object that can safely be passed across isolate
/// boundaries.
diff --git a/packages/barback/lib/src/transformer/aggregate_transform.dart b/packages/barback/lib/src/transformer/aggregate_transform.dart
index a92f738..5c5fe6c 100644
--- a/packages/barback/lib/src/transformer/aggregate_transform.dart
+++ b/packages/barback/lib/src/transformer/aggregate_transform.dart
@@ -81,7 +81,7 @@
/// If an input with [id] cannot be found, throws an [AssetNotFoundException].
Future<String> readInputAsString(AssetId id, {Encoding encoding}) {
if (encoding == null) encoding = UTF8;
- return getInput(id).then/*<Future<String>>*/(
+ return getInput(id).then<Future<String>>(
(input) => input.readAsString(encoding: encoding));
}
@@ -100,8 +100,8 @@
/// This is equivalent to calling [getInput] and catching an
/// [AssetNotFoundException].
Future<bool> hasInput(AssetId id) {
- return DelegatingFuture.typed(
- getInput(id).then((_) => true).catchError((error) {
+ return DelegatingFuture
+ .typed(getInput(id).then((_) => true).catchError((error) {
if (error is AssetNotFoundException && error.id == id) return false;
throw error;
}));
@@ -146,8 +146,7 @@
}
/// Returns whether an input with the given [id] was added via [addInput].
- bool addedId(AssetId id) =>
- transform._emittedPrimaryInputs.containsId(id);
+ bool addedId(AssetId id) => transform._emittedPrimaryInputs.containsId(id);
void done() {
transform._inputController.close();
diff --git a/packages/barback/lib/src/transformer/barback_settings.dart b/packages/barback/lib/src/transformer/barback_settings.dart
index 5b3f46c..f68e315 100644
--- a/packages/barback/lib/src/transformer/barback_settings.dart
+++ b/packages/barback/lib/src/transformer/barback_settings.dart
@@ -48,8 +48,10 @@
factory BarbackMode(String name) {
// Use canonical instances of known names.
switch (name) {
- case "debug": return BarbackMode.DEBUG;
- case "release": return BarbackMode.RELEASE;
+ case "debug":
+ return BarbackMode.DEBUG;
+ case "release":
+ return BarbackMode.RELEASE;
default:
return new BarbackMode._(name);
}
diff --git a/packages/barback/lib/src/transformer/declaring_transform.dart b/packages/barback/lib/src/transformer/declaring_transform.dart
index 7dff33a..7ace38e 100644
--- a/packages/barback/lib/src/transformer/declaring_transform.dart
+++ b/packages/barback/lib/src/transformer/declaring_transform.dart
@@ -26,8 +26,8 @@
// key, so we can safely get the first asset emitted. We don't want to wait
// for the stream to close, since that requires barback to prove that no more
// new assets will be generated.
- return aggregate.primaryIds.first.then((primaryId) =>
- new DeclaringTransform._(aggregate, primaryId));
+ return aggregate.primaryIds.first
+ .then((primaryId) => new DeclaringTransform._(aggregate, primaryId));
}
/// A transform for [DeclaringTransformer]s that allows them to declare the ids
diff --git a/packages/barback/lib/src/transformer/transform.dart b/packages/barback/lib/src/transformer/transform.dart
index 2da73ee..8bc057a 100644
--- a/packages/barback/lib/src/transformer/transform.dart
+++ b/packages/barback/lib/src/transformer/transform.dart
@@ -25,8 +25,8 @@
// key, so we can safely get the first asset emitted. We don't want to wait
// for the stream to close, since that requires barback to prove that no more
// new assets will be generated.
- return aggregate.primaryInputs.first.then((primaryInput) =>
- new Transform._(aggregate, primaryInput));
+ return aggregate.primaryInputs.first
+ .then((primaryInput) => new Transform._(aggregate, primaryInput));
}
/// While a [Transformer] represents a *kind* of transformation, this defines
diff --git a/packages/barback/lib/src/transformer/transform_logger.dart b/packages/barback/lib/src/transformer/transform_logger.dart
index 5f26a97..6fd62d6 100644
--- a/packages/barback/lib/src/transformer/transform_logger.dart
+++ b/packages/barback/lib/src/transformer/transform_logger.dart
@@ -9,8 +9,8 @@
import '../asset/asset_id.dart';
import '../log.dart';
-typedef void LogFunction(AssetId asset, LogLevel level, String message,
- SourceSpan span);
+typedef void LogFunction(
+ AssetId asset, LogLevel level, String message, SourceSpan span);
/// Object used to report warnings and errors encountered while running a
/// transformer.
diff --git a/packages/barback/lib/src/transformer/transformer.dart b/packages/barback/lib/src/transformer/transformer.dart
index b40d61d..f87f067 100644
--- a/packages/barback/lib/src/transformer/transformer.dart
+++ b/packages/barback/lib/src/transformer/transformer.dart
@@ -33,7 +33,8 @@
Transformer() {
if (allowedExtensions == null) return;
- var invalidExtensions = allowedExtensions.split(" ")
+ var invalidExtensions = allowedExtensions
+ .split(" ")
.where((extension) => !extension.startsWith("."))
.map((extension) => '"$extension"');
if (invalidExtensions.isEmpty) return;
diff --git a/packages/barback/lib/src/transformer/wrapping_aggregate_transformer.dart b/packages/barback/lib/src/transformer/wrapping_aggregate_transformer.dart
index a24260d..8d65ae0 100644
--- a/packages/barback/lib/src/transformer/wrapping_aggregate_transformer.dart
+++ b/packages/barback/lib/src/transformer/wrapping_aggregate_transformer.dart
@@ -60,11 +60,8 @@
class _DeclaringWrappingAggregateTransformer
extends WrappingAggregateTransformer
implements DeclaringAggregateTransformer {
- final DeclaringTransformer _declaring;
-
_DeclaringWrappingAggregateTransformer(DeclaringTransformer transformer)
- : _declaring = transformer,
- super._(transformer as Transformer);
+ : super._(transformer as Transformer);
Future declareOutputs(DeclaringAggregateTransform aggregateTransform) {
return newDeclaringTransform(aggregateTransform).then((transform) {
diff --git a/packages/barback/lib/src/utils.dart b/packages/barback/lib/src/utils.dart
index e991078..71dd229 100644
--- a/packages/barback/lib/src/utils.dart
+++ b/packages/barback/lib/src/utils.dart
@@ -130,9 +130,8 @@
///
/// This returns a map whose keys are the return values of [fn] and whose values
/// are lists of each element in [iter] for which [fn] returned that key.
-Map<Object/*=T*/, List/*<S>*/> groupBy/*<S, T>*/(Iterable/*<S>*/ iter,
- /*=T*/ fn(/*=S*/ element)) {
- var map = /*<T, List<S>>*/{};
+Map<Object, List<S>> groupBy<S, T>(Iterable<S> iter, T fn(S element)) {
+ var map = <T, List<S>>{};
for (var element in iter) {
var list = map.putIfAbsent(fn(element), () => []);
list.add(element);
@@ -153,50 +152,48 @@
}
}
}
+
helper(nested);
return result;
}
/// Returns the union of all elements in each set in [sets].
-Set/*<T>*/ unionAll/*<T>*/(Iterable<Set/*<T>*/> sets) =>
- sets.fold(new Set(), (union, set) => union.union(set));
+Set<T> unionAll<T>(Iterable<Set<T>> sets) =>
+ sets.fold(new Set(), (union, set) => union.union(set));
/// Creates a new map from [map] with new keys and values.
///
/// The return values of [keyFn] are used as the keys and the return values of
/// [valueFn] are used as the values for the new map.
-Map/*<K2, V2>*/ mapMap/*<K1, V1, K2, V2>*/(Map/*<K1, V1>*/ map,
- /*=K2*/ keyFn(/*=K1*/ key, /*=V1*/ value),
- /*=V2*/ valueFn(/*=K1*/ key, /*=V1*/ value)) =>
- new Map.fromIterable(map.keys,
- key: (key) => keyFn(key as dynamic/*=K1*/, map[key]),
- value: (key) => valueFn(key as dynamic/*=K1*/, map[key]));
+Map<K2, V2> mapMap<K1, V1, K2, V2>(Map<K1, V1> map, K2 keyFn(K1 key, V1 value),
+ V2 valueFn(K1 key, V1 value)) =>
+ new Map.fromIterable(map.keys,
+ key: (key) => keyFn(key as K1, map[key]),
+ value: (key) => valueFn(key as K1, map[key]));
/// Creates a new map from [map] with the same keys.
///
/// The return values of [fn] are used as the values for the new map.
-Map/*<K, V2>*/ mapMapValues/*<K, V1, V2>*/(Map/*<K, V1>*/ map,
- /*=V2*/ fn(/*=K*/ key, /*=V1*/ value)) =>
- // TODO(nweiz): Don't explicitly type [key] when sdk#25490 is fixed.
- mapMap(map, (/*=K*/ key, _) => key, fn);
+Map<K, V2> mapMapValues<K, V1, V2>(Map<K, V1> map, V2 fn(K key, V1 value)) =>
+ // TODO(nweiz): Don't explicitly type [key] when sdk#25490 is fixed.
+ mapMap(map, (K key, _) => key, fn);
/// Creates a new map from [map] with the same keys.
///
/// The return values of [fn] are used as the keys for the new map.
-Map/*<K2, V>*/ mapMapKeys/*<K1, V, K2>*/(Map/*<K1, V>*/ map,
- /*=K2*/ fn(/*=K1*/ key, /*=V*/ value)) =>
- // TODO(nweiz): Don't explicitly type [value] when sdk#25490 is fixed.
- mapMap(map, fn, (_, /*=V*/ value) => value);
+Map<K2, V> mapMapKeys<K1, V, K2>(Map<K1, V> map, K2 fn(K1 key, V value)) =>
+ // TODO(nweiz): Don't explicitly type [value] when sdk#25490 is fixed.
+ mapMap(map, fn, (_, V value) => value);
/// Returns whether [set1] has exactly the same elements as [set2].
bool setEquals(Set set1, Set set2) =>
- set1.length == set2.length && set1.containsAll(set2);
+ set1.length == set2.length && set1.containsAll(set2);
/// Merges [streams] into a single stream that emits events from all sources.
///
/// If [broadcast] is true, this will return a broadcast stream; otherwise, it
/// will return a buffered stream.
-Stream/*<T>*/ mergeStreams/*<T>*/(Iterable<Stream/*<T>*/> streams,
+Stream<T> mergeStreams<T>(Iterable<Stream<T>> streams,
{bool broadcast: false}) {
streams = streams.toList();
var doneCount = 0;
@@ -205,14 +202,11 @@
// async, then the events we receive will also be async, and forwarding them
// sync won't change that.
var controller = broadcast
- ? new StreamController/*<T>*/.broadcast(sync: true)
- : new StreamController/*<T>*/(sync: true);
+ ? new StreamController<T>.broadcast(sync: true)
+ : new StreamController<T>(sync: true);
for (var stream in streams) {
- stream.listen(
- controller.add,
- onError: controller.addError,
- onDone: () {
+ stream.listen(controller.add, onError: controller.addError, onDone: () {
doneCount++;
if (doneCount == streams.length) controller.close();
});
@@ -238,7 +232,7 @@
/// Returns a [Future] that completes after pumping the event queue [times]
/// times. By default, this should pump the event queue enough times to allow
/// any code to run, as long as it's not waiting on some external event.
-Future pumpEventQueue([int times=20]) {
+Future pumpEventQueue([int times = 20]) {
if (times == 0) return new Future.value();
// We use a delayed future to allow microtask events to finish. The
// Future.value or Future() constructors use scheduleMicrotask themselves and
@@ -249,7 +243,7 @@
/// Like [new Future], but avoids dartbug.com/11911 by using async/await under
/// the covers.
-Future/*<T>*/ newFuture/*<T>*/(/*=T*/ callback()) async => await callback();
+Future<T> newFuture<T>(T callback()) async => await callback();
/// Returns a buffered stream that will emit the same values as the stream
/// returned by [future] once [future] completes.
@@ -260,10 +254,9 @@
/// If [broadcast] is true, a broadcast stream is returned. This assumes that
/// the stream returned by [future] will be a broadcast stream as well.
/// [broadcast] defaults to false.
-Stream/*<T>*/ futureStream/*<T>*/(Future<Stream/*<T>*/> future,
- {bool broadcast: false}) {
- StreamSubscription/*<T>*/ subscription;
- StreamController/*<T>*/ controller;
+Stream<T> futureStream<T>(Future<Stream<T>> future, {bool broadcast: false}) {
+ StreamSubscription<T> subscription;
+ StreamController<T> controller;
future = DelegatingFuture.typed(future.catchError((e, stackTrace) {
// Since [controller] is synchronous, it's likely that emitting an error
@@ -276,10 +269,8 @@
onListen() {
future.then((stream) {
if (controller == null) return;
- subscription = stream.listen(
- controller.add,
- onError: controller.addError,
- onDone: controller.close);
+ subscription = stream.listen(controller.add,
+ onError: controller.addError, onDone: controller.close);
});
}
@@ -290,10 +281,10 @@
}
if (broadcast) {
- controller = new StreamController/*<T>*/.broadcast(
+ controller = new StreamController<T>.broadcast(
sync: true, onListen: onListen, onCancel: onCancel);
} else {
- controller = new StreamController/*<T>*/(
+ controller = new StreamController<T>(
sync: true, onListen: onListen, onCancel: onCancel);
}
return controller.stream;
@@ -303,14 +294,14 @@
/// [callback].
///
/// [callback] will only be called when the returned [Stream] gets a subscriber.
-Stream/*<T>*/ callbackStream/*<T>*/(Stream/*<T>*/ callback()) {
- StreamSubscription/*<T>*/ subscription;
- StreamController/*<T>*/ controller;
- controller = new StreamController/*<T>*/(onListen: () {
- subscription = callback().listen(controller.add,
- onError: controller.addError,
- onDone: controller.close);
- },
+Stream<T> callbackStream<T>(Stream<T> callback()) {
+ StreamSubscription<T> subscription;
+ StreamController<T> controller;
+ controller = new StreamController<T>(
+ onListen: () {
+ subscription = callback().listen(controller.add,
+ onError: controller.addError, onDone: controller.close);
+ },
onCancel: () => subscription.cancel(),
onPause: () => subscription.pause(),
onResume: () => subscription.resume(),
@@ -322,17 +313,16 @@
///
/// The returned stream will enqueue events from [broadcast] until a listener is
/// attached, then pipe events to that listener.
-Stream/*<T>*/ broadcastToSingleSubscription/*<T>*/(Stream/*<T>*/ broadcast) {
+Stream<T> broadcastToSingleSubscription<T>(Stream<T> broadcast) {
if (!broadcast.isBroadcast) return broadcast;
// TODO(nweiz): Implement this using a transformer when issues 18588 and 18586
// are fixed.
var subscription;
- var controller = new StreamController/*<T>*/(
- onCancel: () => subscription.cancel());
+ var controller =
+ new StreamController<T>(onCancel: () => subscription.cancel());
subscription = broadcast.listen(controller.add,
- onError: controller.addError,
- onDone: controller.close);
+ onError: controller.addError, onDone: controller.close);
return controller.stream;
}
@@ -345,7 +335,7 @@
/// Many exceptions include the exception class name at the beginning of their
/// [toString], so we remove that if it exists.
String getErrorMessage(error) =>
- error.toString().replaceFirst(_exceptionPrefix, '');
+ error.toString().replaceFirst(_exceptionPrefix, '');
/// Returns a human-friendly representation of [duration].
String niceDuration(Duration duration) {
diff --git a/packages/barback/lib/src/utils/cancelable_future.dart b/packages/barback/lib/src/utils/cancelable_future.dart
index aaa5e36..78a391f 100644
--- a/packages/barback/lib/src/utils/cancelable_future.dart
+++ b/packages/barback/lib/src/utils/cancelable_future.dart
@@ -29,8 +29,7 @@
Stream<T> asStream() => _completer.future.asStream();
Future<T> catchError(Function onError, {bool test(Object error)}) =>
_completer.future.catchError(onError, test: test);
- Future/*<S>*/ then/*<S>*/(/*=FutureOr<S>*/ onValue(T value),
- {Function onError}) =>
+ Future<S> then<S>(FutureOr<S> onValue(T value), {Function onError}) =>
_completer.future.then(onValue, onError: onError);
Future<T> whenComplete(action()) => _completer.future.whenComplete(action);
Future<T> timeout(Duration timeLimit, {void onTimeout()}) =>
diff --git a/packages/barback/lib/src/utils/file_pool.dart b/packages/barback/lib/src/utils/file_pool.dart
index c7f3d39..e322d65 100644
--- a/packages/barback/lib/src/utils/file_pool.dart
+++ b/packages/barback/lib/src/utils/file_pool.dart
@@ -34,8 +34,9 @@
/// try again.
Stream<List<int>> openRead(String path) {
return futureStream(_pool.request().then((resource) {
- return new File(path).openRead().transform(
- new StreamTransformer.fromHandlers(handleDone: (sink) {
+ return new File(path)
+ .openRead()
+ .transform(new StreamTransformer.fromHandlers(handleDone: (sink) {
sink.close();
resource.release();
}));
diff --git a/packages/barback/lib/src/utils/multiset.dart b/packages/barback/lib/src/utils/multiset.dart
index 4b3edea..8843043 100644
--- a/packages/barback/lib/src/utils/multiset.dart
+++ b/packages/barback/lib/src/utils/multiset.dart
@@ -29,12 +29,10 @@
.iterator;
}
- Multiset()
- : super();
+ Multiset() : super();
/// Creates a multi-set and initializes it using the contents of [other].
- Multiset.from(Iterable<E> other)
- : super() {
+ Multiset.from(Iterable<E> other) : super() {
other.forEach(add);
}
diff --git a/packages/barback/lib/src/utils/stream_pool.dart b/packages/barback/lib/src/utils/stream_pool.dart
index 679672d..04d1e5c 100644
--- a/packages/barback/lib/src/utils/stream_pool.dart
+++ b/packages/barback/lib/src/utils/stream_pool.dart
@@ -45,8 +45,7 @@
void add(Stream<T> stream) {
if (_subscriptions.containsKey(stream)) return;
_subscriptions[stream] = stream.listen(_controller.add,
- onError: _controller.addError,
- onDone: () => remove(stream));
+ onError: _controller.addError, onDone: () => remove(stream));
}
/// Removes [stream] as a member of this pool.
diff --git a/packages/barback/pubspec.yaml b/packages/barback/pubspec.yaml
index 7d239af..d04ba6b 100644
--- a/packages/barback/pubspec.yaml
+++ b/packages/barback/pubspec.yaml
@@ -7,7 +7,7 @@
#
# When the minor or patch version of this is upgraded, you *must* update that
# version constraint in pub to stay in sync with this.
-version: 0.15.2+11
+version: 0.15.2+12
author: "Dart Team <misc@dartlang.org>"
homepage: http://github.com/dart-lang/barback
@@ -22,7 +22,7 @@
Runs transforms asynchronously and in parallel when possible to maximize
responsiveness.
dependencies:
- async: "^1.10.0"
+ async: ">=1.10.0 <3.0.0"
path: ">=0.9.0 <2.0.0"
pool: ">=1.0.0 <2.0.0"
source_span: ">=1.0.0 <2.0.0"
diff --git a/packages/barback/test/asset_id_test.dart b/packages/barback/test/asset_id_test.dart
index 16d29ae..8fb4b96 100644
--- a/packages/barback/test/asset_id_test.dart
+++ b/packages/barback/test/asset_id_test.dart
@@ -54,13 +54,13 @@
});
test("equals another ID with the same package and path", () {
- expect(new AssetId.parse("foo|asset.txt"), equals(
- new AssetId.parse("foo|asset.txt")));
+ expect(new AssetId.parse("foo|asset.txt"),
+ equals(new AssetId.parse("foo|asset.txt")));
- expect(new AssetId.parse("foo|asset.txt"), isNot(equals(
- new AssetId.parse("bar|asset.txt"))));
+ expect(new AssetId.parse("foo|asset.txt"),
+ isNot(equals(new AssetId.parse("bar|asset.txt"))));
- expect(new AssetId.parse("foo|asset.txt"), isNot(equals(
- new AssetId.parse("bar|other.txt"))));
+ expect(new AssetId.parse("foo|asset.txt"),
+ isNot(equals(new AssetId.parse("bar|other.txt"))));
});
}
diff --git a/packages/barback/test/asset_test.dart b/packages/barback/test/asset_test.dart
index 7936c71..ce58229 100644
--- a/packages/barback/test/asset_test.dart
+++ b/packages/barback/test/asset_test.dart
@@ -85,33 +85,31 @@
group("read()", () {
test("gets the UTF-8-encoded string for a string asset", () {
var asset = new Asset.fromString(id, "çøñ†éℵ™");
- expect(asset.read().toList(),
- completion(equals([UTF8.encode("çøñ†éℵ™")])));
+ expect(
+ asset.read().toList(), completion(equals([UTF8.encode("çøñ†éℵ™")])));
});
test("gets the raw bytes for a byte asset", () {
var asset = new Asset.fromBytes(id, binaryContents);
- expect(asset.read().toList(),
- completion(equals([binaryContents])));
+ expect(asset.read().toList(), completion(equals([binaryContents])));
});
test("gets the raw bytes for a binary file", () {
var asset = new Asset.fromPath(id, binaryFilePath);
- expect(asset.read().toList(),
- completion(equals([binaryContents])));
+ expect(asset.read().toList(), completion(equals([binaryContents])));
});
test("gets the raw bytes for a text file", () {
var asset = new Asset.fromPath(id, textFilePath);
- expect(asset.read().toList(),
- completion(equals([UTF8.encode("çøñ†éℵ™")])));
+ expect(
+ asset.read().toList(), completion(equals([UTF8.encode("çøñ†éℵ™")])));
});
test("gets the raw bytes for a stream", () {
- var asset = new Asset.fromStream(id,
- new Stream.fromFuture(new Future.value(UTF8.encode("çøñ†éℵ™"))));
- expect(asset.read().toList(),
- completion(equals([UTF8.encode("çøñ†éℵ™")])));
+ var asset = new Asset.fromStream(
+ id, new Stream.fromFuture(new Future.value(UTF8.encode("çøñ†éℵ™"))));
+ expect(
+ asset.read().toList(), completion(equals([UTF8.encode("çøñ†éℵ™")])));
});
});
@@ -119,14 +117,13 @@
group("byte asset", () {
test("defaults to UTF-8 if encoding is omitted", () {
var asset = new Asset.fromBytes(id, UTF8.encode("çøñ†éℵ™"));
- expect(asset.readAsString(),
- completion(equals("çøñ†éℵ™")));
+ expect(asset.readAsString(), completion(equals("çøñ†éℵ™")));
});
test("supports UTF-8", () {
var asset = new Asset.fromBytes(id, UTF8.encode("çøñ†éℵ™"));
- expect(asset.readAsString(encoding: UTF8),
- completion(equals("çøñ†éℵ™")));
+ expect(
+ asset.readAsString(encoding: UTF8), completion(equals("çøñ†éℵ™")));
});
// TODO(rnystrom): Test other encodings once #6284 is fixed.
@@ -135,8 +132,7 @@
group("string asset", () {
test("gets the string", () {
var asset = new Asset.fromString(id, "contents");
- expect(asset.readAsString(),
- completion(equals("contents")));
+ expect(asset.readAsString(), completion(equals("contents")));
});
test("ignores the encoding", () {
@@ -149,8 +145,7 @@
group("file asset", () {
test("defaults to UTF-8 if encoding is omitted", () {
var asset = new Asset.fromPath(id, textFilePath);
- expect(asset.readAsString(),
- completion(equals("çøñ†éℵ™")));
+ expect(asset.readAsString(), completion(equals("çøñ†éℵ™")));
});
});
@@ -158,15 +153,14 @@
test("defaults to UTF-8 if encoding is omitted", () {
var asset = new Asset.fromStream(id,
new Stream.fromFuture(new Future.value(UTF8.encode("çøñ†éℵ™"))));
- expect(asset.readAsString(),
- completion(equals("çøñ†éℵ™")));
+ expect(asset.readAsString(), completion(equals("çøñ†éℵ™")));
});
test("supports UTF-8", () {
var asset = new Asset.fromStream(id,
new Stream.fromFuture(new Future.value(UTF8.encode("çøñ†éℵ™"))));
- expect(asset.readAsString(encoding: UTF8),
- completion(equals("çøñ†éℵ™")));
+ expect(
+ asset.readAsString(encoding: UTF8), completion(equals("çøñ†éℵ™")));
});
test("supports ISO-8859-1", () {
@@ -181,32 +175,31 @@
group("toString()", () {
group("byte asset", () {
test("shows the list of bytes in hex", () {
- var asset = new Asset.fromBytes(id,
- [0, 1, 2, 4, 8, 16, 32, 64, 128, 255]);
- expect(asset.toString(), equals(
- "Bytes [00 01 02 04 08 10 20 40 80 ff]"));
+ var asset =
+ new Asset.fromBytes(id, [0, 1, 2, 4, 8, 16, 32, 64, 128, 255]);
+ expect(
+ asset.toString(), equals("Bytes [00 01 02 04 08 10 20 40 80 ff]"));
});
test("truncates the middle of there are more than ten bytes", () {
- var asset = new Asset.fromBytes(id,
- [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]);
- expect(asset.toString(), equals(
- "Bytes [01 02 03 04 05 ... 0a 0b 0c 0d 0e]"));
+ var asset = new Asset.fromBytes(
+ id, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]);
+ expect(asset.toString(),
+ equals("Bytes [01 02 03 04 05 ... 0a 0b 0c 0d 0e]"));
});
});
group("string asset", () {
test("shows the contents", () {
var asset = new Asset.fromString(id, "contents");
- expect(asset.toString(), equals(
- 'String "contents"'));
+ expect(asset.toString(), equals('String "contents"'));
});
test("truncates the middle of there are more than 40 characters", () {
var asset = new Asset.fromString(id,
"this is a fairly long string asset content that gets shortened");
- expect(asset.toString(), equals(
- 'String "this is a fairly lon ... that gets shortened"'));
+ expect(asset.toString(),
+ equals('String "this is a fairly lon ... that gets shortened"'));
});
});
@@ -235,14 +228,12 @@
test("gets the raw bytes for a byte asset", () {
var asset = new Asset.fromBytes(id, binaryContents);
- expect(getBytesFromIsolate(asset),
- completion(equals(binaryContents)));
+ expect(getBytesFromIsolate(asset), completion(equals(binaryContents)));
});
test("gets the raw bytes for a binary file", () {
var asset = new Asset.fromPath(id, binaryFilePath);
- expect(getBytesFromIsolate(asset),
- completion(equals(binaryContents)));
+ expect(getBytesFromIsolate(asset), completion(equals(binaryContents)));
});
test("gets the raw bytes for a text file", () {
@@ -252,8 +243,8 @@
});
test("gets the raw bytes for a stream", () {
- var asset = new Asset.fromStream(id,
- new Stream.fromFuture(new Future.value(UTF8.encode("çøñ†éℵ™"))));
+ var asset = new Asset.fromStream(
+ id, new Stream.fromFuture(new Future.value(UTF8.encode("çøñ†éℵ™"))));
expect(getBytesFromIsolate(asset),
completion(equals(UTF8.encode("çøñ†éℵ™"))));
});
@@ -262,7 +253,8 @@
void _getAssetBytes(message) {
var asset = deserializeAsset(message['asset']);
- var builder = asset.read().fold(new BytesBuilder(),
- (builder, chunk) => builder..add(chunk));
+ var builder = asset
+ .read()
+ .fold(new BytesBuilder(), (builder, chunk) => builder..add(chunk));
builder.then((builder) => message['replyTo'].send(builder.takeBytes()));
}
diff --git a/packages/barback/test/barback_mode_test.dart b/packages/barback/test/barback_mode_test.dart
index 2d18f09..5c5233d 100644
--- a/packages/barback/test/barback_mode_test.dart
+++ b/packages/barback/test/barback_mode_test.dart
@@ -12,9 +12,12 @@
main() {
initConfig();
test("constructor uses canonical instances for DEBUG and RELEASE", () {
- expect(identical(BarbackMode.DEBUG,
- new BarbackMode(BarbackMode.DEBUG.name)), isTrue);
- expect(identical(BarbackMode.RELEASE,
- new BarbackMode(BarbackMode.RELEASE.name)), isTrue);
+ expect(
+ identical(BarbackMode.DEBUG, new BarbackMode(BarbackMode.DEBUG.name)),
+ isTrue);
+ expect(
+ identical(
+ BarbackMode.RELEASE, new BarbackMode(BarbackMode.RELEASE.name)),
+ isTrue);
});
}
diff --git a/packages/barback/test/logger_test.dart b/packages/barback/test/logger_test.dart
index 5c42b2e..342d68c 100644
--- a/packages/barback/test/logger_test.dart
+++ b/packages/barback/test/logger_test.dart
@@ -20,8 +20,12 @@
"info: This is info.",
"fine: This is fine."
]);
- initGraph(["app|foo.txt"], {
- "app": [[transformer]]
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [transformer]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -39,9 +43,17 @@
"fine: This is fine."
]);
- initGraph(["app|foo.txt"], {"app": [
- [new TransformerGroup([[transformer]])]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [transformer]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.txt"]);
buildShouldLog(LogLevel.ERROR, equals("This is an error."));
diff --git a/packages/barback/test/multiset_test.dart b/packages/barback/test/multiset_test.dart
index 7b6f09f..18d2dc1 100644
--- a/packages/barback/test/multiset_test.dart
+++ b/packages/barback/test/multiset_test.dart
@@ -61,7 +61,8 @@
expect(multiSet.remove(1), isTrue);
});
- test("remove returns true if the element was in the set even if more copies "
+ test(
+ "remove returns true if the element was in the set even if more copies "
"remain", () {
var multiSet = new Multiset.from([1, 1, 1]);
expect(multiSet.remove(1), isTrue);
diff --git a/packages/barback/test/package_graph/add_remove_transform_test.dart b/packages/barback/test/package_graph/add_remove_transform_test.dart
index d3839ee..ba14614 100644
--- a/packages/barback/test/package_graph/add_remove_transform_test.dart
+++ b/packages/barback/test/package_graph/add_remove_transform_test.dart
@@ -18,7 +18,9 @@
expectAsset("app|foo.blub", "foo");
buildShouldSucceed();
- updateTransformers("app", [[new RewriteTransformer("blub", "blab")]]);
+ updateTransformers("app", [
+ [new RewriteTransformer("blub", "blab")]
+ ]);
expectAsset("app|foo.blab", "foo.blab");
buildShouldSucceed();
});
@@ -30,7 +32,9 @@
expectAsset("app|foo.blub", "foo");
buildShouldSucceed();
- updateTransformers("app", [[new RewriteTransformer("zip", "zap")]]);
+ updateTransformers("app", [
+ [new RewriteTransformer("zip", "zap")]
+ ]);
expectAsset("app|foo.blub", "foo");
expectNoAsset("app|foo.zap");
buildShouldSucceed();
@@ -38,13 +42,21 @@
test("updateTransformers doesn't re-run an old transformer", () {
var rewrite = new RewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blab", "foo.blab");
buildShouldSucceed();
- updateTransformers("app", [[rewrite]]);
+ updateTransformers("app", [
+ [rewrite]
+ ]);
expectAsset("app|foo.blab", "foo.blab");
buildShouldSucceed();
@@ -54,22 +66,40 @@
test("updateTransformers re-runs old transformers in a new phase", () {
var rewrite1 = new RewriteTransformer("txt", "blub");
var rewrite2 = new RewriteTransformer("blub", "blab");
- initGraph(["app|foo.txt"], {"app": [[rewrite1], [rewrite2]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [rewrite1],
+ [rewrite2]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.blab", "foo.blub.blab");
buildShouldSucceed();
- updateTransformers("app", [[rewrite2], [rewrite1]]);
+ updateTransformers("app", [
+ [rewrite2],
+ [rewrite1]
+ ]);
expectAsset("app|foo.blub", "foo.blub");
expectNoAsset("app|foo.blab");
buildShouldSucceed();
});
- test("updateTransformers re-runs an old transformer when a previous phase "
+ test(
+ "updateTransformers re-runs an old transformer when a previous phase "
"changes", () {
var rewrite = new RewriteTransformer("txt", "out");
- initGraph(["app|foo.txt"], {"app": [[], [rewrite]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [],
+ [rewrite]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.out", "foo.out");
@@ -84,9 +114,13 @@
});
test("a removed transformer is no longer applied", () {
- initGraph(["app|foo.blub"], {"app": [
- [new RewriteTransformer("blub", "blab")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new RewriteTransformer("blub", "blab")]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blab", "foo.blab");
@@ -101,10 +135,14 @@
test("a new transformer is pipelined", () {
var rewrite1 = new RewriteTransformer("source", "phase1");
var rewrite3 = new RewriteTransformer("phase2", "phase3");
- initGraph(["app|foo.source"], {"app": [
- [rewrite1],
- [rewrite3]
- ]});
+ initGraph([
+ "app|foo.source"
+ ], {
+ "app": [
+ [rewrite1],
+ [rewrite3]
+ ]
+ });
updateSources(["app|foo.source"]);
expectNoAsset("app|foo.phase3");
@@ -122,24 +160,37 @@
test("a removed transformer is un-pipelined", () {
var rewrite1 = new RewriteTransformer("source", "phase1");
var rewrite3 = new RewriteTransformer("phase2", "phase3");
- initGraph(["app|foo.source"], {"app": [
- [rewrite1],
- [new RewriteTransformer("phase1", "phase2")],
- [rewrite3]
- ]});
+ initGraph([
+ "app|foo.source"
+ ], {
+ "app": [
+ [rewrite1],
+ [new RewriteTransformer("phase1", "phase2")],
+ [rewrite3]
+ ]
+ });
updateSources(["app|foo.source"]);
expectAsset("app|foo.phase3", "foo.phase1.phase2.phase3");
buildShouldSucceed();
- updateTransformers("app", [[rewrite1], [rewrite3]]);
+ updateTransformers("app", [
+ [rewrite1],
+ [rewrite3]
+ ]);
expectNoAsset("app|foo.phase3");
buildShouldSucceed();
});
test("a transformer is removed during isPrimary", () {
var rewrite = new RewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
rewrite.pauseIsPrimary("app|foo.blub");
updateSources(["app|foo.blub"]);
@@ -155,7 +206,13 @@
test("a transformer is removed during apply", () {
var rewrite = new RewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
rewrite.pauseApply();
updateSources(["app|foo.blub"]);
@@ -171,7 +228,14 @@
test("a transformer is added to an existing phase during isPrimary", () {
var rewrite = new RewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub", "app|bar.blib"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.blub",
+ "app|bar.blib"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
rewrite.pauseIsPrimary("app|foo.blub");
updateSources(["app|foo.blub", "app|bar.blib"]);
@@ -193,8 +257,12 @@
"pkg1|foo.txt": "pkg2|foo.inc",
"pkg2|foo.inc": "foo"
}, {
- "pkg1": [[new ManyToOneTransformer("txt")]],
- "pkg2": [[rewrite]]
+ "pkg1": [
+ [new ManyToOneTransformer("txt")]
+ ],
+ "pkg2": [
+ [rewrite]
+ ]
});
updateSources(["pkg1|foo.txt", "pkg2|foo.inc"]);
@@ -209,14 +277,17 @@
buildShouldSucceed();
});
- test("a cross-package transform doesn't see a removed transformer in a "
+ test(
+ "a cross-package transform doesn't see a removed transformer in a "
"removed phase", () {
var rewrite = new RewriteTransformer("inc", "inc");
initGraph({
"pkg1|foo.txt": "pkg2|foo.inc",
"pkg2|foo.inc": "foo"
}, {
- "pkg1": [[new ManyToOneTransformer("txt")]],
+ "pkg1": [
+ [new ManyToOneTransformer("txt")]
+ ],
"pkg2": [
[rewrite],
[new RewriteTransformer("inc", "inc")]
@@ -227,7 +298,9 @@
expectAsset("pkg1|foo.out", "foo.inc.inc");
buildShouldSucceed();
- updateTransformers("pkg2", [[rewrite]]);
+ updateTransformers("pkg2", [
+ [rewrite]
+ ]);
expectAsset("pkg1|foo.out", "foo.inc");
buildShouldSucceed();
});
@@ -235,7 +308,13 @@
group("pass-through", () {
test("a new transformer can see pass-through assets", () {
var rewrite = new RewriteTransformer("zip", "zap");
- initGraph(["app|foo.blub"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
updateSources(["app|foo.blub"]);
buildShouldSucceed();
@@ -250,7 +329,13 @@
test("a new transformer can overwrite an old asset", () {
var rewrite = new RewriteTransformer("zip", "zap");
- initGraph(["app|foo.txt"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.txt", "foo");
@@ -268,8 +353,12 @@
test("passes an asset through when an overwriting transform is removed",
() {
- initGraph(["app|foo.txt"], {
- "app": [[new RewriteTransformer("txt", "txt")]]
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new RewriteTransformer("txt", "txt")]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -281,10 +370,17 @@
buildShouldSucceed();
});
- test("passes an asset through when its overwriting transform is removed "
+ test(
+ "passes an asset through when its overwriting transform is removed "
"during apply", () {
var rewrite = new RewriteTransformer("txt", "txt");
- initGraph(["app|foo.txt"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
rewrite.pauseApply();
updateSources(["app|foo.txt"]);
@@ -296,11 +392,18 @@
buildShouldSucceed();
});
- test("doesn't pass an asset through when its overwriting transform is "
+ test(
+ "doesn't pass an asset through when its overwriting transform is "
"removed during apply if another transform overwrites it", () {
var rewrite1 = new RewriteTransformer("txt", "txt");
var rewrite2 = new RewriteTransformer("txt", "txt");
- initGraph(["app|foo.txt"], {"app": [[rewrite1, rewrite2]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [rewrite1, rewrite2]
+ ]
+ });
rewrite1.pauseApply();
updateSources(["app|foo.txt"]);
@@ -308,19 +411,25 @@
// Ensure we're waiting on [rewrite1.apply]
schedule(pumpEventQueue);
- updateTransformers("app", [[rewrite2]]);
+ updateTransformers("app", [
+ [rewrite2]
+ ]);
rewrite1.resumeApply();
expectAsset("app|foo.txt", "foo.txt");
buildShouldSucceed();
});
- test("doesn't pass an asset through when one overwriting transform is "
+ test(
+ "doesn't pass an asset through when one overwriting transform is "
"removed if another transform still overwrites it", () {
var rewrite = new RewriteTransformer("txt", "txt");
- initGraph(["app|foo.txt"], {"app": [[
- rewrite,
- new RewriteTransformer("txt", "txt")
- ]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [rewrite, new RewriteTransformer("txt", "txt")]
+ ]
+ });
updateSources(["app|foo.txt"]);
// This could be either the output of [CheckContentTransformer] or
@@ -328,7 +437,9 @@
expectAsset("app|foo.txt", anything);
buildShouldFail([isAssetCollisionException("app|foo.txt")]);
- updateTransformers("app", [[rewrite]]);
+ updateTransformers("app", [
+ [rewrite]
+ ]);
expectAsset("app|foo.txt", "foo.txt");
buildShouldSucceed();
});
@@ -337,8 +448,12 @@
// Regression test.
test("a phase is added, then an input is removed and re-added", () {
var rewrite = new RewriteTransformer("txt", "mid");
- initGraph(["app|foo.txt"], {
- "app": [[rewrite]]
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [rewrite]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -364,8 +479,13 @@
// Regression test for issue 19540.
test("a phase is removed and then one of its inputs is updated", () {
// Have an empty first phase because the first phase is never removed.
- initGraph(["app|foo.txt"], {
- "app": [[], [new RewriteTransformer("txt", "out")]]
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [],
+ [new RewriteTransformer("txt", "out")]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -387,4 +507,4 @@
updateSources(["app|foo.txt"]);
buildShouldSucceed();
});
-}
\ No newline at end of file
+}
diff --git a/packages/barback/test/package_graph/collisions_test.dart b/packages/barback/test/package_graph/collisions_test.dart
index 91d00a0..e7c794d 100644
--- a/packages/barback/test/package_graph/collisions_test.dart
+++ b/packages/barback/test/package_graph/collisions_test.dart
@@ -13,25 +13,29 @@
initConfig();
test("errors if two transformers output the same file", () {
- initGraph(["app|foo.a"], {"app": [
- [
- new RewriteTransformer("a", "b"),
- new RewriteTransformer("a", "b")
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [new RewriteTransformer("a", "b"), new RewriteTransformer("a", "b")]
]
- ]});
+ });
updateSources(["app|foo.a"]);
buildShouldFail([isAssetCollisionException("app|foo.b")]);
});
- test("errors if a new transformer outputs the same file as an old "
+ test(
+ "errors if a new transformer outputs the same file as an old "
"transformer", () {
- initGraph(["app|foo.a", "app|foo.b"], {"app": [
- [
- new RewriteTransformer("a", "c"),
- new RewriteTransformer("b", "c")
+ initGraph([
+ "app|foo.a",
+ "app|foo.b"
+ ], {
+ "app": [
+ [new RewriteTransformer("a", "c"), new RewriteTransformer("b", "c")]
]
- ]});
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.c", "foo.c");
buildShouldSucceed();
@@ -46,7 +50,11 @@
initGraph({
"app|foo.one": "one",
"app|foo.two": "two"
- }, {"app": [[rewrite1, rewrite2]]});
+ }, {
+ "app": [
+ [rewrite1, rewrite2]
+ ]
+ });
rewrite1.pauseApply();
updateSources(["app|foo.one", "app|foo.two"]);
@@ -71,12 +79,14 @@
initGraph({
"app|foo.one": "one",
"app|foo.two": "two"
- }, {"app": [
- [
- new RewriteTransformer("one", "out"),
- new RewriteTransformer("two", "out")
+ }, {
+ "app": [
+ [
+ new RewriteTransformer("one", "out"),
+ new RewriteTransformer("two", "out")
+ ]
]
- ]});
+ });
updateSources(["app|foo.one"]);
expectAsset("app|foo.out", "one.out");
@@ -95,13 +105,15 @@
initGraph({
"app|foo.one": "one",
"app|foo.two": "two"
- }, {"app": [
- [
- new RewriteTransformer("one", "mid"),
- new RewriteTransformer("two", "mid")
- ],
- [new RewriteTransformer("mid", "out")]
- ]});
+ }, {
+ "app": [
+ [
+ new RewriteTransformer("one", "mid"),
+ new RewriteTransformer("two", "mid")
+ ],
+ [new RewriteTransformer("mid", "out")]
+ ]
+ });
updateSources(["app|foo.one"]);
expectAsset("app|foo.out", "one.mid.out");
@@ -116,7 +128,8 @@
buildShouldSucceed();
});
- test("a collision that is partially resolved returns the second completed "
+ test(
+ "a collision that is partially resolved returns the second completed "
"output", () {
var rewrite1 = new RewriteTransformer("one", "out");
var rewrite2 = new RewriteTransformer("two", "out");
@@ -125,7 +138,11 @@
"app|foo.one": "one",
"app|foo.two": "two",
"app|foo.three": "three"
- }, {"app": [[rewrite1, rewrite2, rewrite3]]});
+ }, {
+ "app": [
+ [rewrite1, rewrite2, rewrite3]
+ ]
+ });
// Make rewrite3 the most-recently-completed transformer from the first run.
rewrite2.pauseApply();
@@ -157,9 +174,11 @@
initGraph([
"app|foo.txt",
"app|foo.in"
- ], {"app": [
- [new RewriteTransformer("in", "txt")]
- ]});
+ ], {
+ "app": [
+ [new RewriteTransformer("in", "txt")]
+ ]
+ });
updateSources(["app|foo.txt", "app|foo.in"]);
expectAsset("app|foo.txt", "foo");
@@ -170,9 +189,11 @@
initGraph([
"app|foo.txt",
"app|foo.in"
- ], {"app": [
- [new RewriteTransformer("in", "txt")]
- ]});
+ ], {
+ "app": [
+ [new RewriteTransformer("in", "txt")]
+ ]
+ });
updateSources(["app|foo.in"]);
expectAsset("app|foo.txt", "foo.txt");
@@ -183,14 +204,17 @@
buildShouldFail([isAssetCollisionException("app|foo.txt")]);
});
- test("a new transform output that collides with a pass-through asset returns "
+ test(
+ "a new transform output that collides with a pass-through asset returns "
"the pass-through asset", () {
initGraph([
"app|foo.txt",
"app|foo.in"
- ], {"app": [
- [new RewriteTransformer("in", "txt")]
- ]});
+ ], {
+ "app": [
+ [new RewriteTransformer("in", "txt")]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.txt", "foo");
diff --git a/packages/barback/test/package_graph/declaring_transformer_test.dart b/packages/barback/test/package_graph/declaring_transformer_test.dart
index aa830df..aef3299 100644
--- a/packages/barback/test/package_graph/declaring_transformer_test.dart
+++ b/packages/barback/test/package_graph/declaring_transformer_test.dart
@@ -4,7 +4,6 @@
library barback.test.package_graph.declaring_transformer_test;
-import 'package:barback/barback.dart';
import 'package:barback/src/utils.dart';
import 'package:scheduled_test/scheduled_test.dart';
@@ -14,36 +13,52 @@
initConfig();
test("gets a declared output with a different path", () {
- initGraph(["app|foo.blub"], {"app": [
- [new DeclaringRewriteTransformer("blub", "blab")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new DeclaringRewriteTransformer("blub", "blab")]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blab", "foo.blab");
buildShouldSucceed();
});
test("gets a declared output with the same path", () {
- initGraph(["app|foo.blub"], {"app": [
- [new DeclaringRewriteTransformer("blub", "blub")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new DeclaringRewriteTransformer("blub", "blub")]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blub", "foo.blub");
buildShouldSucceed();
});
test("gets a passed-through asset", () {
- initGraph(["app|foo.blub"], {"app": [
- [new DeclaringRewriteTransformer("blub", "blab")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new DeclaringRewriteTransformer("blub", "blab")]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blub", "foo");
buildShouldSucceed();
});
test("doesn't get a consumed asset", () {
- initGraph(["app|foo.blub"], {"app": [
- [new DeclaringRewriteTransformer("blub", "blab")..consumePrimary = true]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new DeclaringRewriteTransformer("blub", "blab")..consumePrimary = true]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectNoAsset("app|foo.blub");
buildShouldSucceed();
@@ -51,7 +66,13 @@
test("gets a passed-through asset before apply is finished", () {
var transformer = new DeclaringRewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
transformer.pauseApply();
updateSources(["app|foo.blub"]);
@@ -63,22 +84,36 @@
test("fails to get a consumed asset before apply is finished", () {
var transformer = new DeclaringRewriteTransformer("blub", "blab")
- ..consumePrimary = true;
- initGraph(["app|foo.blub"], {"app": [[transformer]]});
-
+ ..consumePrimary = true;
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
+
transformer.pauseApply();
updateSources(["app|foo.blub"]);
expectNoAsset("app|foo.blub");
-
+
transformer.resumeApply();
buildShouldSucceed();
});
test("blocks on getting a declared asset that wasn't generated last run", () {
var transformer = new DeclaringCheckContentAndRenameTransformer(
- oldExtension: "txt", oldContent: "yes",
- newExtension: "out", newContent: "done");
- initGraph({"app|foo.txt": "no"}, {"app": [[transformer]]});
+ oldExtension: "txt",
+ oldContent: "yes",
+ newExtension: "out",
+ newContent: "done");
+ initGraph({
+ "app|foo.txt": "no"
+ }, {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectNoAsset("app|foo.out");
@@ -96,12 +131,21 @@
buildShouldSucceed();
});
- test("doesn't block on on getting an undeclared asset that wasn't generated "
+ test(
+ "doesn't block on on getting an undeclared asset that wasn't generated "
"last run", () {
var transformer = new DeclaringCheckContentAndRenameTransformer(
- oldExtension: "txt", oldContent: "yes",
- newExtension: "out", newContent: "done");
- initGraph({"app|foo.txt": "no"}, {"app": [[transformer]]});
+ oldExtension: "txt",
+ oldContent: "yes",
+ newExtension: "out",
+ newContent: "done");
+ initGraph({
+ "app|foo.txt": "no"
+ }, {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectNoAsset("app|foo.out");
@@ -116,36 +160,49 @@
buildShouldSucceed();
});
- test("fails to get a consumed asset before apply is finished when a sibling "
+ test(
+ "fails to get a consumed asset before apply is finished when a sibling "
"has finished applying", () {
var transformer = new DeclaringRewriteTransformer("blub", "blab")
- ..consumePrimary = true;
- initGraph(["app|foo.blub", "app|foo.txt"], {"app": [[
- transformer,
- new RewriteTransformer("txt", "out")
- ]]});
-
+ ..consumePrimary = true;
+ initGraph([
+ "app|foo.blub",
+ "app|foo.txt"
+ ], {
+ "app": [
+ [transformer, new RewriteTransformer("txt", "out")]
+ ]
+ });
+
transformer.pauseApply();
updateSources(["app|foo.blub", "app|foo.txt"]);
expectAsset("app|foo.out", "foo.out");
expectNoAsset("app|foo.blub");
-
+
transformer.resumeApply();
buildShouldSucceed();
});
- test("blocks getting a consumed asset before apply is finished when a "
+ test(
+ "blocks getting a consumed asset before apply is finished when a "
"sibling hasn't finished applying", () {
var declaring = new DeclaringRewriteTransformer("blub", "blab")
- ..consumePrimary = true;
+ ..consumePrimary = true;
var eager = new RewriteTransformer("txt", "out");
- initGraph(["app|foo.blub", "app|foo.txt"], {"app": [[declaring, eager]]});
-
+ initGraph([
+ "app|foo.blub",
+ "app|foo.txt"
+ ], {
+ "app": [
+ [declaring, eager]
+ ]
+ });
+
declaring.pauseApply();
eager.pauseApply();
updateSources(["app|foo.blub", "app|foo.txt"]);
expectAssetDoesNotComplete("app|foo.blub");
-
+
declaring.resumeApply();
eager.resumeApply();
expectNoAsset("app|foo.blub");
@@ -154,7 +211,13 @@
test("waits until apply is finished to get an overwritten asset", () {
var transformer = new DeclaringRewriteTransformer("blub", "blub");
- initGraph(["app|foo.blub"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
transformer.pauseApply();
updateSources(["app|foo.blub"]);
@@ -169,10 +232,14 @@
test("a declaring transformer's output passes through a lazy transformer",
() {
var declaring = new DeclaringRewriteTransformer("one", "two");
- initGraph(["app|foo.one"], {"app": [
- [declaring],
- [new LazyRewriteTransformer("two", "three")]
- ]});
+ initGraph([
+ "app|foo.one"
+ ], {
+ "app": [
+ [declaring],
+ [new LazyRewriteTransformer("two", "three")]
+ ]
+ });
updateSources(["app|foo.one"]);
// Give the transformers time to declare their assets.
@@ -194,13 +261,20 @@
expect(declaring.numRuns, completion(equals(2)));
});
- test("a declaring transformer following a lazy transformer runs eagerly once "
+ test(
+ "a declaring transformer following a lazy transformer runs eagerly once "
"its input is available", () {
var declaring = new DeclaringRewriteTransformer("two", "three");
- initGraph(["app|foo.in"], {"app": [
- [new LazyAssetsTransformer(["app|out.one", "app|out.two"])],
- [declaring]
- ]});
+ initGraph([
+ "app|foo.in"
+ ], {
+ "app": [
+ [
+ new LazyAssetsTransformer(["app|out.one", "app|out.two"])
+ ],
+ [declaring]
+ ]
+ });
updateSources(["app|foo.in"]);
// Give the transformers time to declare their assets.
@@ -212,13 +286,20 @@
expect(declaring.numRuns, completion(equals(1)));
});
- test("a declaring transformer following a lazy transformer doesn't re-run if "
+ test(
+ "a declaring transformer following a lazy transformer doesn't re-run if "
"its input becomes available and then unavailable", () {
var declaring = new DeclaringRewriteTransformer("two", "three");
- initGraph(["app|foo.in"], {"app": [
- [new LazyAssetsTransformer(["app|out.one", "app|out.two"])],
- [declaring]
- ]});
+ initGraph([
+ "app|foo.in"
+ ], {
+ "app": [
+ [
+ new LazyAssetsTransformer(["app|out.one", "app|out.two"])
+ ],
+ [declaring]
+ ]
+ });
declaring.pauseApply();
updateSources(["app|foo.in"]);
@@ -251,14 +332,21 @@
expect(declaring.numRuns, completion(equals(2)));
});
- test("a declaring transformer following a lazy transformer does re-run if "
+ test(
+ "a declaring transformer following a lazy transformer does re-run if "
"its input becomes available, it's forced, and then its input becomes "
"unavailable", () {
var declaring = new DeclaringRewriteTransformer("two", "three");
- initGraph(["app|foo.in"], {"app": [
- [new LazyAssetsTransformer(["app|out.one", "app|out.two"])],
- [declaring]
- ]});
+ initGraph([
+ "app|foo.in"
+ ], {
+ "app": [
+ [
+ new LazyAssetsTransformer(["app|out.one", "app|out.two"])
+ ],
+ [declaring]
+ ]
+ });
declaring.pauseApply();
updateSources(["app|foo.in"]);
@@ -289,10 +377,16 @@
group("with an error in declareOutputs", () {
test("still runs apply", () {
- initGraph(["app|foo.txt"], {"app": [[
- new DeclaringBadTransformer("app|out.txt",
- declareError: true, applyError: false)
- ]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [
+ new DeclaringBadTransformer("app|out.txt",
+ declareError: true, applyError: false)
+ ]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|out.txt", "bad out");
@@ -300,11 +394,19 @@
buildShouldFail([isTransformerException(BadTransformer.ERROR)]);
});
- test("waits for apply to complete before passing through the input even if "
+ test(
+ "waits for apply to complete before passing through the input even if "
"consumePrimary was called", () {
var transformer = new DeclaringBadTransformer("app|out.txt",
- declareError: true, applyError: false)..consumePrimary = true;
- initGraph(["app|foo.txt"], {"app": [[transformer]]});
+ declareError: true, applyError: false)
+ ..consumePrimary = true;
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
transformer.pauseApply();
updateSources(["app|foo.txt"]);
@@ -319,21 +421,33 @@
});
test("with an error in apply still passes through the input", () {
- initGraph(["app|foo.txt"], {"app": [[
- new DeclaringBadTransformer("app|out.txt",
- declareError: false, applyError: true)
- ]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [
+ new DeclaringBadTransformer("app|out.txt",
+ declareError: false, applyError: true)
+ ]
+ ]
+ });
- updateSources(["app|foo.txt"]);
- expectNoAsset("app|out.txt");
- expectAsset("app|foo.txt", "foo");
- buildShouldFail([isTransformerException(BadTransformer.ERROR)]);
+ updateSources(["app|foo.txt"]);
+ expectNoAsset("app|out.txt");
+ expectAsset("app|foo.txt", "foo");
+ buildShouldFail([isTransformerException(BadTransformer.ERROR)]);
});
test("can emit outputs it didn't declare", () {
- initGraph(["app|foo.txt"], {"app": [
- [new DeclareAssetsTransformer([], emitted: ["app|out.txt"])]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [
+ new DeclareAssetsTransformer([], emitted: ["app|out.txt"])
+ ]
+ ]
+ });
updateSources(["app|foo.txt"]);
// There's probably going to be some time when "out.txt" is unavailable,
@@ -345,9 +459,15 @@
test("can overwrite the primary input even if it declared that it wouldn't",
() {
- var transformer = new DeclareAssetsTransformer(
- [], emitted: ["app|foo.txt"]);
- initGraph(["app|foo.txt"], {"app": [[transformer]]});
+ var transformer =
+ new DeclareAssetsTransformer([], emitted: ["app|foo.txt"]);
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
transformer.pauseApply();
updateSources(["app|foo.txt"]);
@@ -360,12 +480,18 @@
});
test("can declare outputs it doesn't emit", () {
- initGraph(["app|foo.txt"], {"app": [
- [new DeclareAssetsTransformer(["app|out.txt"], emitted: [])]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [
+ new DeclareAssetsTransformer(["app|out.txt"], emitted: [])
+ ]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectNoAsset("app|out.txt");
buildShouldSucceed();
});
-}
\ No newline at end of file
+}
diff --git a/packages/barback/test/package_graph/errors_test.dart b/packages/barback/test/package_graph/errors_test.dart
index 1b578a5..8860483 100644
--- a/packages/barback/test/package_graph/errors_test.dart
+++ b/packages/barback/test/package_graph/errors_test.dart
@@ -4,7 +4,6 @@
library barback.test.package_graph.source_test;
-import 'package:barback/src/utils.dart';
import 'package:scheduled_test/scheduled_test.dart';
import '../utils.dart';
@@ -28,24 +27,32 @@
});
test("reports an error for an unprovided source", () {
- initGraph(["app|known.txt"], {"app": [
- // Have a dummy transformer so that barback at least tries to load the
- // asset.
- [new RewriteTransformer("a", "b")]
- ]});
+ initGraph([
+ "app|known.txt"
+ ], {
+ "app": [
+ // Have a dummy transformer so that barback at least tries to load the
+ // asset.
+ [new RewriteTransformer("a", "b")]
+ ]
+ });
updateSources(["app|unknown.txt"]);
buildShouldFail([
- isAssetLoadException("app|unknown.txt",
- isAssetNotFoundException("app|unknown.txt"))
+ isAssetLoadException(
+ "app|unknown.txt", isAssetNotFoundException("app|unknown.txt"))
]);
});
test("reports missing input errors in results", () {
- initGraph({"app|a.txt": "a.inc"}, {"app": [
- [new ManyToOneTransformer("txt")]
- ]});
+ initGraph({
+ "app|a.txt": "a.inc"
+ }, {
+ "app": [
+ [new ManyToOneTransformer("txt")]
+ ]
+ });
updateSources(["app|a.txt"]);
expectNoAsset("app|a.out");
@@ -54,8 +61,12 @@
test("reports an error if a transformer emits an asset for another package",
() {
- initGraph(["app|foo.txt"], {
- "app": [[new CreateAssetTransformer("wrong|foo.txt")]]
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new CreateAssetTransformer("wrong|foo.txt")]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -68,9 +79,11 @@
"app|a.inc": "a",
"app|b.inc": "b",
"app|c.inc": "c"
- }, {"app": [
- [new ManyToOneTransformer("txt")]
- ]});
+ }, {
+ "app": [
+ [new ManyToOneTransformer("txt")]
+ ]
+ });
updateSources(["app|a.txt", "app|a.inc", "app|b.inc", "app|c.inc"]);
expectAsset("app|a.out", "abc");
@@ -82,9 +95,15 @@
});
test("catches transformer exceptions and reports them", () {
- initGraph(["app|foo.txt"], {"app": [
- [new BadTransformer(["app|foo.out"])]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [
+ new BadTransformer(["app|foo.out"])
+ ]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectNoAsset("app|foo.out");
@@ -92,7 +111,13 @@
});
test("catches errors even if nothing is waiting for process results", () {
- initGraph(["app|foo.txt"], {"app": [[new BadTransformer([])]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new BadTransformer([])]
+ ]
+ });
updateSources(["app|foo.txt"]);
// Note: No asset requests here.
@@ -100,17 +125,29 @@
});
test("discards outputs from failed transforms", () {
- initGraph(["app|foo.txt"], {"app": [
- [new BadTransformer(["a.out", "b.out"])]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [
+ new BadTransformer(["a.out", "b.out"])
+ ]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectNoAsset("app|a.out");
});
test("fails if only one package fails", () {
- initGraph(["pkg1|foo.txt", "pkg2|foo.txt"],
- {"pkg1": [[new BadTransformer([])]]});
+ initGraph([
+ "pkg1|foo.txt",
+ "pkg2|foo.txt"
+ ], {
+ "pkg1": [
+ [new BadTransformer([])]
+ ]
+ });
updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]);
expectAsset("pkg2|foo.txt", "foo");
@@ -118,9 +155,16 @@
});
test("emits multiple failures if multiple packages fail", () {
- initGraph(["pkg1|foo.txt", "pkg2|foo.txt"], {
- "pkg1": [[new BadTransformer([])]],
- "pkg2": [[new BadTransformer([])]]
+ initGraph([
+ "pkg1|foo.txt",
+ "pkg2|foo.txt"
+ ], {
+ "pkg1": [
+ [new BadTransformer([])]
+ ],
+ "pkg2": [
+ [new BadTransformer([])]
+ ]
});
updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]);
@@ -131,11 +175,15 @@
});
test("an error loading an asset removes the asset from the graph", () {
- initGraph(["app|foo.txt"], {"app": [
- // Have a dummy transformer so that barback at least tries to load the
- // asset.
- [new RewriteTransformer("a", "b")]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ // Have a dummy transformer so that barback at least tries to load the
+ // asset.
+ [new RewriteTransformer("a", "b")]
+ ]
+ });
setAssetError("app|foo.txt");
updateSources(["app|foo.txt"]);
@@ -147,11 +195,15 @@
test("a synchronous error loading an asset removes the asset from the graph",
() {
- initGraph(["app|foo.txt"], {"app": [
- // Have a dummy transformer so that barback at least tries to load the
- // asset.
- [new RewriteTransformer("a", "b")]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ // Have a dummy transformer so that barback at least tries to load the
+ // asset.
+ [new RewriteTransformer("a", "b")]
+ ]
+ });
setAssetError("app|foo.txt", async: false);
updateSources(["app|foo.txt"]);
@@ -162,7 +214,13 @@
});
test("an asset isn't passed through a transformer with an error", () {
- initGraph(["app|foo.txt"], {"app": [[new BadTransformer([])]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new BadTransformer([])]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectNoAsset("app|foo.txt");
@@ -170,9 +228,15 @@
});
test("a transformer that logs errors shouldn't produce output", () {
- initGraph(["app|foo.txt"], {"app": [
- [new BadLogTransformer(["app|out.txt"])]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [
+ new BadLogTransformer(["app|out.txt"])
+ ]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectNoAsset("app|foo.txt");
@@ -184,23 +248,30 @@
});
test("a transformer can catch an error loading a secondary input", () {
- initGraph(["app|foo.txt"], {"app": [
- [new CatchAssetNotFoundTransformer(".txt", "app|nothing")]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new CatchAssetNotFoundTransformer(".txt", "app|nothing")]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.txt", "failed to load app|nothing");
buildShouldSucceed();
});
- test("a transformer that fails due to a missing secondary input is re-run "
+ test(
+ "a transformer that fails due to a missing secondary input is re-run "
"when that input appears", () {
initGraph({
"app|foo.txt": "bar.inc",
"app|bar.inc": "bar"
- }, {"app": [
- [new ManyToOneTransformer("txt")]
- ]});
+ }, {
+ "app": [
+ [new ManyToOneTransformer("txt")]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectNoAsset("app|foo.out");
diff --git a/packages/barback/test/package_graph/get_all_assets_test.dart b/packages/barback/test/package_graph/get_all_assets_test.dart
index 08da238..7e60364 100644
--- a/packages/barback/test/package_graph/get_all_assets_test.dart
+++ b/packages/barback/test/package_graph/get_all_assets_test.dart
@@ -22,54 +22,72 @@
});
test("includes transformed outputs", () {
- initGraph(["app|a.txt", "app|foo.blub"], {"app": [
- [new RewriteTransformer("blub", "blab")]
- ]});
+ initGraph([
+ "app|a.txt",
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new RewriteTransformer("blub", "blab")]
+ ]
+ });
updateSources(["app|a.txt", "app|foo.blub"]);
expectAllAssets(["app|a.txt", "app|foo.blub", "app|foo.blab"]);
buildShouldSucceed();
});
test("includes overwritten outputs", () {
- initGraph(["app|a.txt", "app|foo.blub"], {"app": [
- [new RewriteTransformer("blub", "blub")]
- ]});
- updateSources(["app|a.txt", "app|foo.blub"]);
- expectAllAssets({
- "app|a.txt": "a",
- "app|foo.blub": "foo.blub"
+ initGraph([
+ "app|a.txt",
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new RewriteTransformer("blub", "blub")]
+ ]
});
+ updateSources(["app|a.txt", "app|foo.blub"]);
+ expectAllAssets({"app|a.txt": "a", "app|foo.blub": "foo.blub"});
buildShouldSucceed();
});
test("completes to an error if two transformers output the same file", () {
- initGraph(["app|foo.a"], {"app": [
- [
- new RewriteTransformer("a", "b"),
- new RewriteTransformer("a", "b")
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [new RewriteTransformer("a", "b"), new RewriteTransformer("a", "b")]
]
- ]});
+ });
updateSources(["app|foo.a"]);
expectAllAssetsShouldFail(isAssetCollisionException("app|foo.b"));
});
test("completes to an error if a transformer fails", () {
- initGraph(["app|foo.txt"], {"app": [
- [new BadTransformer(["app|foo.out"])]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [
+ new BadTransformer(["app|foo.out"])
+ ]
+ ]
+ });
updateSources(["app|foo.txt"]);
- expectAllAssetsShouldFail(isTransformerException(
- equals(BadTransformer.ERROR)));
+ expectAllAssetsShouldFail(
+ isTransformerException(equals(BadTransformer.ERROR)));
});
test("completes to an aggregate error if there are multiple errors", () {
- initGraph(["app|foo.txt"], {"app": [
- [
- new BadTransformer(["app|foo.out"]),
- new BadTransformer(["app|foo.out2"])
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [
+ new BadTransformer(["app|foo.out"]),
+ new BadTransformer(["app|foo.out2"])
+ ]
]
- ]});
+ });
updateSources(["app|foo.txt"]);
expectAllAssetsShouldFail(isAggregateException([
@@ -79,13 +97,11 @@
});
// Regression test.
- test("getAllAssets() is called synchronously after after initializing "
+ test(
+ "getAllAssets() is called synchronously after after initializing "
"barback", () {
- var provider = new MockProvider({
- "app|a.txt": "a",
- "app|b.txt": "b",
- "app|c.txt": "c"
- });
+ var provider = new MockProvider(
+ {"app|a.txt": "a", "app|b.txt": "b", "app|c.txt": "c"});
var barback = new Barback(provider);
barback.updateSources([
new AssetId.parse("app|a.txt"),
@@ -93,8 +109,10 @@
new AssetId.parse("app|c.txt")
]);
- expect(barback.getAllAssets().then((assets) {
- return Future.wait(assets.map((asset) => asset.readAsString()));
- }), completion(unorderedEquals(["a", "b", "c"])));
+ expect(
+ barback.getAllAssets().then((assets) {
+ return Future.wait(assets.map((asset) => asset.readAsString()));
+ }),
+ completion(unorderedEquals(["a", "b", "c"])));
});
}
diff --git a/packages/barback/test/package_graph/group_test.dart b/packages/barback/test/package_graph/group_test.dart
index 4e2cb44..e1d8dca 100644
--- a/packages/barback/test/package_graph/group_test.dart
+++ b/packages/barback/test/package_graph/group_test.dart
@@ -4,8 +4,6 @@
library barback.test.package_graph.group_test;
-import 'dart:async';
-
import 'package:barback/barback.dart';
import 'package:scheduled_test/scheduled_test.dart';
@@ -14,54 +12,77 @@
main() {
initConfig();
test("runs transforms in a group", () {
- initGraph(["app|foo.a"], {"app": [
- [new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ])]
- ]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.c", "foo.b.c");
buildShouldSucceed();
});
test("passes the output of a group to the next phase", () {
- initGraph(["app|foo.a"], {"app": [
- [new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ])],
- [new RewriteTransformer("c", "d")]
- ]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ])
+ ],
+ [new RewriteTransformer("c", "d")]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.d", "foo.b.c.d");
buildShouldSucceed();
});
test("passes the output of a previous phase to a group", () {
- initGraph(["app|foo.a"], {"app": [
- [new RewriteTransformer("a", "b")],
- [new TransformerGroup([
- [new RewriteTransformer("b", "c")],
- [new RewriteTransformer("c", "d")]
- ])]
- ]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [new RewriteTransformer("a", "b")],
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("b", "c")],
+ [new RewriteTransformer("c", "d")]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.d", "foo.b.c.d");
buildShouldSucceed();
});
- test("intermediate assets in a group are usable as secondary inputs within "
+ test(
+ "intermediate assets in a group are usable as secondary inputs within "
"that group", () {
initGraph({
"app|foo.a": "contents",
"app|bar.txt": "foo.inc"
- }, {"app": [
- [new TransformerGroup([
- [new RewriteTransformer("a", "inc")],
- [new ManyToOneTransformer("txt")]
- ])]
- ]});
+ }, {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "inc")],
+ [new ManyToOneTransformer("txt")]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.a", "app|bar.txt"]);
expectAsset("app|bar.out", "contents.inc");
@@ -69,18 +90,31 @@
});
test("groups can be nested", () {
- initGraph(["app|foo.a", "app|bar.x"], {"app": [
- [new TransformerGroup([
- [new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ]), new TransformerGroup([
- [new RewriteTransformer("x", "y"), new RewriteTransformer("a", "y")],
- [new RewriteTransformer("y", "z")]
- ])],
- [new RewriteTransformer("c", "d")]
- ])]
- ]});
+ initGraph([
+ "app|foo.a",
+ "app|bar.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ]),
+ new TransformerGroup([
+ [
+ new RewriteTransformer("x", "y"),
+ new RewriteTransformer("a", "y")
+ ],
+ [new RewriteTransformer("y", "z")]
+ ])
+ ],
+ [new RewriteTransformer("c", "d")]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.a", "app|bar.x"]);
expectAsset("app|foo.d", "foo.b.c.d");
expectAsset("app|foo.z", "foo.y.z");
@@ -89,12 +123,18 @@
});
test("an updated asset is propagated through a group", () {
- initGraph(["app|foo.a"], {"app": [
- [new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ])]
- ]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.c", "foo.b.c");
@@ -109,12 +149,19 @@
test("an updated asset only runs the necessary transforms in a group", () {
var rewriteA = new RewriteTransformer("a", "b");
var rewriteX = new RewriteTransformer("x", "b");
- initGraph(["app|foo.a", "app|bar.x"], {"app": [
- [new TransformerGroup([
- [rewriteA, rewriteX],
- [new RewriteTransformer("b", "c")]
- ])]
- ]});
+ initGraph([
+ "app|foo.a",
+ "app|bar.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [rewriteA, rewriteX],
+ [new RewriteTransformer("b", "c")]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.a", "app|bar.x"]);
expectAsset("app|foo.c", "foo.b.c");
@@ -132,13 +179,19 @@
group("encapsulation", () {
test("a group can't see a parallel transform's outputs", () {
- initGraph(["app|foo.x"], {"app": [[
- new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ]),
- new RewriteTransformer("x", "b")
- ]]});
+ initGraph([
+ "app|foo.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ]),
+ new RewriteTransformer("x", "b")
+ ]
+ ]
+ });
updateSources(["app|foo.x"]);
expectAsset("app|foo.b", "foo.b");
expectNoAsset("app|foo.c");
@@ -146,13 +199,19 @@
});
test("a parallel transform can't see a group's outputs", () {
- initGraph(["app|foo.a"], {"app": [[
- new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ]),
- new RewriteTransformer("c", "z")
- ]]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ]),
+ new RewriteTransformer("c", "z")
+ ]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.c", "foo.b.c");
expectNoAsset("app|foo.z");
@@ -160,13 +219,19 @@
});
test("a parallel transform can't see a group's intermediate assets", () {
- initGraph(["app|foo.a"], {"app": [[
- new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ]),
- new RewriteTransformer("b", "z")
- ]]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ]),
+ new RewriteTransformer("b", "z")
+ ]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.c", "foo.b.c");
expectNoAsset("app|foo.z");
@@ -174,15 +239,23 @@
});
test("parallel groups can't see one another's intermediate assets", () {
- initGraph(["app|foo.a", "app|bar.x"], {"app": [
- [new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ]), new TransformerGroup([
- [new RewriteTransformer("x", "b")],
- [new RewriteTransformer("b", "z")]
- ])]
- ]});
+ initGraph([
+ "app|foo.a",
+ "app|bar.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ]),
+ new TransformerGroup([
+ [new RewriteTransformer("x", "b")],
+ [new RewriteTransformer("b", "z")]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.a", "app|bar.x"]);
expectAsset("app|foo.c", "foo.b.c");
expectAsset("app|bar.z", "bar.b.z");
@@ -192,15 +265,23 @@
});
test("parallel groups' intermediate assets can't collide", () {
- initGraph(["app|foo.a", "app|foo.x"], {"app": [
- [new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")..consumePrimary = true]
- ]), new TransformerGroup([
- [new RewriteTransformer("x", "b")],
- [new RewriteTransformer("b", "z")..consumePrimary = true]
- ])]
- ]});
+ initGraph([
+ "app|foo.a",
+ "app|foo.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")..consumePrimary = true]
+ ]),
+ new TransformerGroup([
+ [new RewriteTransformer("x", "b")],
+ [new RewriteTransformer("b", "z")..consumePrimary = true]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.a", "app|foo.x"]);
expectAsset("app|foo.a");
expectAsset("app|foo.x");
@@ -212,12 +293,18 @@
group("pass-through", () {
test("passes an unused input through a group", () {
- initGraph(["app|foo.x"], {"app": [
- [new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ])]
- ]});
+ initGraph([
+ "app|foo.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.x"]);
expectNoAsset("app|foo.c");
expectAsset("app|foo.x", "foo");
@@ -225,12 +312,18 @@
});
test("passes non-overwritten inputs through a group", () {
- initGraph(["app|foo.a"], {"app": [
- [new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ])]
- ]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.a", "foo");
expectAsset("app|foo.b", "foo.b");
@@ -239,15 +332,22 @@
});
test("passes an unused input through parallel groups", () {
- initGraph(["app|foo.x"], {"app": [
- [new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ]), new TransformerGroup([
- [new RewriteTransformer("1", "2")],
- [new RewriteTransformer("2", "3")]
- ])]
- ]});
+ initGraph([
+ "app|foo.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ]),
+ new TransformerGroup([
+ [new RewriteTransformer("1", "2")],
+ [new RewriteTransformer("2", "3")]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.x"]);
expectNoAsset("app|foo.c");
expectNoAsset("app|foo.3");
@@ -256,13 +356,19 @@
});
test("passes an unused input through a group and a transform", () {
- initGraph(["app|foo.x"], {"app": [[
- new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ]),
- new RewriteTransformer("1", "2")
- ]]});
+ initGraph([
+ "app|foo.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ]),
+ new RewriteTransformer("1", "2")
+ ]
+ ]
+ });
updateSources(["app|foo.x"]);
expectNoAsset("app|foo.c");
expectNoAsset("app|foo.2");
@@ -270,84 +376,128 @@
buildShouldSucceed();
});
- test("doesn't pass through an input that's overwritten by a group but not "
+ test(
+ "doesn't pass through an input that's overwritten by a group but not "
"by transformers", () {
- initGraph(["app|foo.a"], {"app": [[
- new TransformerGroup([
- [new RewriteTransformer("a", "a")],
- ]),
- new RewriteTransformer("x", "y")
- ]]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "a")],
+ ]),
+ new RewriteTransformer("x", "y")
+ ]
+ ]
+ });
updateSources(["app|foo.a"]);
expectNoAsset("app|foo.y");
expectAsset("app|foo.a", "foo.a");
buildShouldSucceed();
});
- test("doesn't pass through an input that's overwritten by transformers but "
+ test(
+ "doesn't pass through an input that's overwritten by transformers but "
"not by a group", () {
- initGraph(["app|foo.x"], {"app": [[
- new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ]),
- new RewriteTransformer("x", "x")
- ]]});
+ initGraph([
+ "app|foo.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ]),
+ new RewriteTransformer("x", "x")
+ ]
+ ]
+ });
updateSources(["app|foo.x"]);
expectNoAsset("app|foo.c");
expectAsset("app|foo.x", "foo.x");
buildShouldSucceed();
});
- test("doesn't pass through an input that's consumed by a group but not "
+ test(
+ "doesn't pass through an input that's consumed by a group but not "
"by transformers", () {
- initGraph(["app|foo.a"], {"app": [[
- new TransformerGroup([
- [new RewriteTransformer("a", "b")..consumePrimary = true],
- ]),
- new RewriteTransformer("x", "y")
- ]]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")..consumePrimary = true],
+ ]),
+ new RewriteTransformer("x", "y")
+ ]
+ ]
+ });
updateSources(["app|foo.a"]);
expectNoAsset("app|foo.a");
expectAsset("app|foo.b", "foo.b");
buildShouldSucceed();
});
- test("doesn't pass through an input that's consumed by transformers but "
+ test(
+ "doesn't pass through an input that's consumed by transformers but "
"not by a group", () {
- initGraph(["app|foo.x"], {"app": [[
- new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ]),
- new RewriteTransformer("x", "y")..consumePrimary = true
- ]]});
+ initGraph([
+ "app|foo.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ]),
+ new RewriteTransformer("x", "y")..consumePrimary = true
+ ]
+ ]
+ });
updateSources(["app|foo.x"]);
expectNoAsset("app|foo.x");
expectAsset("app|foo.y", "foo.y");
buildShouldSucceed();
});
- test("doesn't detect a collision for an input that's modified in-place by "
+ test(
+ "doesn't detect a collision for an input that's modified in-place by "
"a transformer", () {
- initGraph(["app|foo.x"], {"app": [[
- new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ]),
- new RewriteTransformer("x", "x")
- ]]});
+ initGraph([
+ "app|foo.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ]),
+ new RewriteTransformer("x", "x")
+ ]
+ ]
+ });
updateSources(["app|foo.x"]);
expectAsset("app|foo.x", "foo.x");
buildShouldSucceed();
});
- test("doesn't detect a collision for an input that's modified in-place by "
+ test(
+ "doesn't detect a collision for an input that's modified in-place by "
"a group", () {
- initGraph(["app|foo.a"], {"app": [[
- new TransformerGroup([[new RewriteTransformer("a", "a")]]),
- new RewriteTransformer("x", "y")
- ]]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "a")]
+ ]),
+ new RewriteTransformer("x", "y")
+ ]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.a", "foo.a");
buildShouldSucceed();
@@ -356,19 +506,27 @@
test("runs transforms in an added group", () {
var rewrite = new RewriteTransformer("a", "z");
- initGraph(["app|foo.a"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.z", "foo.z");
buildShouldSucceed();
- updateTransformers("app", [[
- rewrite,
- new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ])
- ]]);
+ updateTransformers("app", [
+ [
+ rewrite,
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ])
+ ]
+ ]);
expectAsset("app|foo.z", "foo.z");
expectAsset("app|foo.c", "foo.b.c");
buildShouldSucceed();
@@ -377,8 +535,17 @@
test("doesn't re-run transforms in a re-added group", () {
var rewrite1 = new RewriteTransformer("a", "b");
var rewrite2 = new RewriteTransformer("b", "c");
- var group = new TransformerGroup([[rewrite1], [rewrite2]]);
- initGraph(["app|foo.a"], {"app": [[group]]});
+ var group = new TransformerGroup([
+ [rewrite1],
+ [rewrite2]
+ ]);
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [group]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.c", "foo.b.c");
@@ -398,8 +565,17 @@
test("doesn't run transforms in a removed group", () {
var rewrite1 = new RewriteTransformer("a", "b");
var rewrite2 = new RewriteTransformer("b", "c");
- var group = new TransformerGroup([[rewrite1], [rewrite2]]);
- initGraph(["app|foo.a"], {"app": [[group]]});
+ var group = new TransformerGroup([
+ [rewrite1],
+ [rewrite2]
+ ]);
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [group]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.c", "foo.b.c");
@@ -413,14 +589,25 @@
test("doesn't pass through an input that's overwritten by an added group",
() {
var rewrite = new RewriteTransformer("x", "z");
- initGraph(["app|foo.a"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.a", "foo");
buildShouldSucceed();
updateTransformers("app", [
- [rewrite, new TransformerGroup([[new RewriteTransformer("a", "a")]])]
+ [
+ rewrite,
+ new TransformerGroup([
+ [new RewriteTransformer("a", "a")]
+ ])
+ ]
]);
expectAsset("app|foo.a", "foo.a");
buildShouldSucceed();
@@ -428,43 +615,64 @@
// TODO(nweiz): make the collision error message nice
test("reports collisions within a group", () {
- initGraph(["app|foo.a", "app|foo.x"], {"app": [
- [new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("x", "b")]
- ])]
- ]});
+ initGraph([
+ "app|foo.a",
+ "app|foo.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("x", "b")]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.a", "app|foo.x"]);
buildShouldFail([isAssetCollisionException("app|foo.b")]);
});
test("reports collisions between a group and a non-grouped transform", () {
- initGraph(["app|foo.a", "app|foo.x"], {"app": [[
- new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ]),
- new RewriteTransformer("x", "c")
- ]]});
+ initGraph([
+ "app|foo.a",
+ "app|foo.x"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ]),
+ new RewriteTransformer("x", "c")
+ ]
+ ]
+ });
updateSources(["app|foo.a", "app|foo.x"]);
buildShouldFail([isAssetCollisionException("app|foo.c")]);
});
// Regression test for issue 18872.
- test("a multi-phase group's outputs should be visible as secondary inputs "
+ test(
+ "a multi-phase group's outputs should be visible as secondary inputs "
"for a following group", () {
initGraph({
"app|foo.txt": "bar.c",
"app|bar.a": "bar"
- }, {"app": [
- [new TransformerGroup([
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")]
- ])],
- [new TransformerGroup([
- [new ManyToOneTransformer("txt")]
- ])]
- ]});
+ }, {
+ "app": [
+ [
+ new TransformerGroup([
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")]
+ ])
+ ],
+ [
+ new TransformerGroup([
+ [new ManyToOneTransformer("txt")]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.txt", "app|bar.a"]);
expectAsset("app|foo.out", "bar.b.c");
diff --git a/packages/barback/test/package_graph/lazy_transformer_test.dart b/packages/barback/test/package_graph/lazy_transformer_test.dart
index 1503c47..e1f16bb 100644
--- a/packages/barback/test/package_graph/lazy_transformer_test.dart
+++ b/packages/barback/test/package_graph/lazy_transformer_test.dart
@@ -5,7 +5,6 @@
library barback.test.package_graph.lazy_asset_test;
import 'package:barback/barback.dart';
-import 'package:barback/src/utils.dart';
import 'package:scheduled_test/scheduled_test.dart';
import '../utils.dart';
@@ -13,9 +12,13 @@
main() {
initConfig();
test("requesting a lazy asset should cause it to be generated", () {
- initGraph(["app|foo.blub"], {"app": [
- [new LazyRewriteTransformer("blub", "blab")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("blub", "blab")]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blab", "foo.blab");
buildShouldSucceed();
@@ -23,17 +26,30 @@
test("calling getAllAssets should cause a lazy asset to be generated", () {
var transformer = new LazyRewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAllAssets(["app|foo.blub", "app|foo.blab"]);
buildShouldSucceed();
expect(transformer.numRuns, completion(equals(1)));
});
- test("requesting a lazy asset multiple times should only cause it to be "
+ test(
+ "requesting a lazy asset multiple times should only cause it to be "
"generated once", () {
var transformer = new LazyRewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blab", "foo.blab");
expectAsset("app|foo.blab", "foo.blab");
@@ -43,10 +59,14 @@
});
test("a lazy asset can be consumed by a non-lazy transformer", () {
- initGraph(["app|foo.blub"], {"app": [
- [new LazyRewriteTransformer("blub", "blab")],
- [new RewriteTransformer("blab", "blib")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("blub", "blab")],
+ [new RewriteTransformer("blab", "blib")]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blib", "foo.blab.blib");
buildShouldSucceed();
@@ -54,7 +74,13 @@
test("a lazy asset isn't eagerly compiled", () {
var transformer = new LazyRewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.blub"]);
buildShouldSucceed();
expect(transformer.numRuns, completion(equals(0)));
@@ -62,9 +88,17 @@
test("a lazy asset emitted by a group isn't eagerly compiled", () {
var transformer = new LazyRewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [
- [new TransformerGroup([[transformer]])]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [
+ new TransformerGroup([
+ [transformer]
+ ])
+ ]
+ ]
+ });
updateSources(["app|foo.blub"]);
buildShouldSucceed();
expect(transformer.numRuns, completion(equals(0)));
@@ -73,48 +107,71 @@
test("a lazy asset piped into a non-lazy transformer is eagerly compiled",
() {
var transformer = new LazyRewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [
- [transformer],
- [new RewriteTransformer("blab", "blib")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer],
+ [new RewriteTransformer("blab", "blib")]
+ ]
+ });
updateSources(["app|foo.blub"]);
buildShouldSucceed();
expect(transformer.numRuns, completion(equals(1)));
});
- test("a lazy asset piped into a declaring transformer isn't eagerly "
+ test(
+ "a lazy asset piped into a declaring transformer isn't eagerly "
"compiled", () {
var transformer1 = new LazyRewriteTransformer("blub", "blab");
var transformer2 = new DeclaringRewriteTransformer("blab", "blib");
- initGraph(["app|foo.blub"], {"app": [
- [transformer1], [transformer2]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer1],
+ [transformer2]
+ ]
+ });
updateSources(["app|foo.blub"]);
buildShouldSucceed();
expect(transformer1.numRuns, completion(equals(0)));
expect(transformer2.numRuns, completion(equals(0)));
});
- test("a lazy asset piped into a declaring transformer is compiled "
+ test(
+ "a lazy asset piped into a declaring transformer is compiled "
"on-demand", () {
- initGraph(["app|foo.blub"], {"app": [
- [new LazyRewriteTransformer("blub", "blab")],
- [new DeclaringRewriteTransformer("blab", "blib")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("blub", "blab")],
+ [new DeclaringRewriteTransformer("blab", "blib")]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blib", "foo.blab.blib");
buildShouldSucceed();
});
- test("a lazy asset piped through many declaring transformers isn't eagerly "
+ test(
+ "a lazy asset piped through many declaring transformers isn't eagerly "
"compiled", () {
var transformer1 = new LazyRewriteTransformer("one", "two");
var transformer2 = new DeclaringRewriteTransformer("two", "three");
var transformer3 = new DeclaringRewriteTransformer("three", "four");
var transformer4 = new DeclaringRewriteTransformer("four", "five");
- initGraph(["app|foo.one"], {"app": [
- [transformer1], [transformer2], [transformer3], [transformer4]
- ]});
+ initGraph([
+ "app|foo.one"
+ ], {
+ "app": [
+ [transformer1],
+ [transformer2],
+ [transformer3],
+ [transformer4]
+ ]
+ });
updateSources(["app|foo.one"]);
buildShouldSucceed();
expect(transformer1.numRuns, completion(equals(0)));
@@ -123,49 +180,69 @@
expect(transformer4.numRuns, completion(equals(0)));
});
- test("a lazy asset piped through many declaring transformers is compiled "
+ test(
+ "a lazy asset piped through many declaring transformers is compiled "
"on-demand", () {
- initGraph(["app|foo.one"], {"app": [
- [new LazyRewriteTransformer("one", "two")],
- [new DeclaringRewriteTransformer("two", "three")],
- [new DeclaringRewriteTransformer("three", "four")],
- [new DeclaringRewriteTransformer("four", "five")]
- ]});
+ initGraph([
+ "app|foo.one"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("one", "two")],
+ [new DeclaringRewriteTransformer("two", "three")],
+ [new DeclaringRewriteTransformer("three", "four")],
+ [new DeclaringRewriteTransformer("four", "five")]
+ ]
+ });
updateSources(["app|foo.one"]);
expectAsset("app|foo.five", "foo.two.three.four.five");
buildShouldSucceed();
});
- test("a lazy asset piped into a non-lazy transformer that doesn't use its "
+ test(
+ "a lazy asset piped into a non-lazy transformer that doesn't use its "
"outputs isn't eagerly compiled", () {
var transformer = new LazyRewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [
- [transformer],
- [new RewriteTransformer("txt", "out")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer],
+ [new RewriteTransformer("txt", "out")]
+ ]
+ });
updateSources(["app|foo.blub"]);
buildShouldSucceed();
expect(transformer.numRuns, completion(equals(0)));
});
- test("a lazy asset piped into a non-lazy transformer that doesn't use its "
+ test(
+ "a lazy asset piped into a non-lazy transformer that doesn't use its "
"outputs is compiled on-demand", () {
- initGraph(["app|foo.blub"], {"app": [
- [new LazyRewriteTransformer("blub", "blab")],
- [new RewriteTransformer("txt", "out")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("blub", "blab")],
+ [new RewriteTransformer("txt", "out")]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blab", "foo.blab");
buildShouldSucceed();
});
- test("a lazy transformer followed by a non-lazy transformer is re-run "
+ test(
+ "a lazy transformer followed by a non-lazy transformer is re-run "
"eagerly", () {
var rewrite = new LazyRewriteTransformer("one", "two");
- initGraph(["app|foo.one"], {"app": [
- [rewrite],
- [new RewriteTransformer("two", "three")]
- ]});
+ initGraph([
+ "app|foo.one"
+ ], {
+ "app": [
+ [rewrite],
+ [new RewriteTransformer("two", "three")]
+ ]
+ });
updateSources(["app|foo.one"]);
expectAsset("app|foo.three", "foo.two.three");
@@ -177,13 +254,18 @@
expect(rewrite.numRuns, completion(equals(2)));
});
- test("a lazy transformer followed by a declaring transformer isn't re-run "
+ test(
+ "a lazy transformer followed by a declaring transformer isn't re-run "
"eagerly", () {
var rewrite = new LazyRewriteTransformer("one", "two");
- initGraph(["app|foo.one"], {"app": [
- [rewrite],
- [new DeclaringRewriteTransformer("two", "three")]
- ]});
+ initGraph([
+ "app|foo.one"
+ ], {
+ "app": [
+ [rewrite],
+ [new DeclaringRewriteTransformer("two", "three")]
+ ]
+ });
updateSources(["app|foo.one"]);
expectAsset("app|foo.three", "foo.two.three");
@@ -195,17 +277,27 @@
expect(rewrite.numRuns, completion(equals(1)));
});
- test("a declaring transformer added after a materialized lazy transformer "
+ test(
+ "a declaring transformer added after a materialized lazy transformer "
"is still deferred", () {
var lazy = new LazyRewriteTransformer("one", "two");
var declaring = new DeclaringRewriteTransformer("two", "three");
- initGraph(["app|foo.one"], {"app": [[lazy]]});
+ initGraph([
+ "app|foo.one"
+ ], {
+ "app": [
+ [lazy]
+ ]
+ });
updateSources(["app|foo.one"]);
expectAsset("app|foo.two", "foo.two");
buildShouldSucceed();
- updateTransformers("app", [[lazy], [declaring]]);
+ updateTransformers("app", [
+ [lazy],
+ [declaring]
+ ]);
expectAsset("app|foo.three", "foo.two.three");
buildShouldSucceed();
@@ -220,11 +312,14 @@
initGraph({
"pkg1|foo.blub": "foo",
"pkg2|a.txt": "pkg1|foo.blab"
- }, {"pkg1": [
- [new LazyRewriteTransformer("blub", "blab")],
- ], "pkg2": [
- [new ManyToOneTransformer("txt")]
- ]});
+ }, {
+ "pkg1": [
+ [new LazyRewriteTransformer("blub", "blab")],
+ ],
+ "pkg2": [
+ [new ManyToOneTransformer("txt")]
+ ]
+ });
updateSources(["pkg1|foo.blub", "pkg2|a.txt"]);
expectAsset("pkg2|a.out", "foo.blab");
@@ -235,9 +330,11 @@
initGraph({
"app|a.inc": "a",
"app|a.txt": "a.inc"
- }, {"app": [
- [new LazyManyToOneTransformer("txt")]
- ]});
+ }, {
+ "app": [
+ [new LazyManyToOneTransformer("txt")]
+ ]
+ });
updateSources(["app|a.inc", "app|a.txt"]);
expectAsset("app|a.out", "a");
@@ -246,7 +343,13 @@
test("after being materialized a lazy transformer is still lazy", () {
var transformer = new LazyRewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.blub"]);
buildShouldSucceed();
@@ -264,7 +367,13 @@
test("after being materialized a lazy transformer can be materialized again",
() {
var transformer = new LazyRewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.blub"]);
buildShouldSucceed();
@@ -279,20 +388,32 @@
buildShouldSucceed();
});
- test("an error emitted in a lazy transformer's declareOutputs method is "
+ test(
+ "an error emitted in a lazy transformer's declareOutputs method is "
"caught and reported", () {
- initGraph(["app|foo.txt"], {"app": [
- [new LazyBadTransformer("app|foo.out")]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new LazyBadTransformer("app|foo.out")]
+ ]
+ });
updateSources(["app|foo.txt"]);
buildShouldFail([isTransformerException(equals(LazyBadTransformer.ERROR))]);
});
- test("an error emitted in a lazy transformer's declareOuputs method prevents "
+ test(
+ "an error emitted in a lazy transformer's declareOuputs method prevents "
"it from being materialized", () {
var transformer = new LazyBadTransformer("app|foo.out");
- initGraph(["app|foo.txt"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectNoAsset("app|foo.out");
@@ -301,9 +422,13 @@
});
test("a lazy transformer passes through inputs it doesn't apply to", () {
- initGraph(["app|foo.txt"], {"app": [
- [new LazyRewriteTransformer("blub", "blab")]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("blub", "blab")]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.txt");
@@ -311,9 +436,13 @@
});
test("a lazy transformer passes through inputs it doesn't overwrite", () {
- initGraph(["app|foo.txt"], {"app": [
- [new LazyRewriteTransformer("txt", "out")]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("txt", "out")]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.txt");
@@ -321,9 +450,13 @@
});
test("a lazy transformer doesn't pass through inputs it overwrites", () {
- initGraph(["app|foo.txt"], {"app": [
- [new LazyRewriteTransformer("txt", "txt")]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("txt", "txt")]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.txt", "foo.txt");
@@ -331,9 +464,13 @@
});
test("a lazy transformer doesn't pass through inputs it consumes", () {
- initGraph(["app|foo.txt"], {"app": [
- [new LazyRewriteTransformer("txt", "out")..consumePrimary = true]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("txt", "out")..consumePrimary = true]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectNoAsset("app|foo.txt");
@@ -341,9 +478,13 @@
});
test("a lazy transformer that doesn't apply does nothing when forced", () {
- initGraph(["app|foo.txt"], {"app": [
- [new LazyRewriteTransformer("blub", "blab")]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("blub", "blab")]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectNoAsset("app|foo.blab");
@@ -354,13 +495,22 @@
buildShouldSucceed();
});
- test("a lazy transformer that generates fewer outputs than it declares is "
+ test(
+ "a lazy transformer that generates fewer outputs than it declares is "
"forced when a declared but ungenerated output is requested", () {
- initGraph({"app|foo.txt": "no"}, {"app": [
- [new LazyCheckContentAndRenameTransformer(
- oldExtension: "txt", oldContent: "yes",
- newExtension: "out", newContent: "done")]
- ]});
+ initGraph({
+ "app|foo.txt": "no"
+ }, {
+ "app": [
+ [
+ new LazyCheckContentAndRenameTransformer(
+ oldExtension: "txt",
+ oldContent: "yes",
+ newExtension: "out",
+ newContent: "done")
+ ]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectNoAsset("app|foo.out");
@@ -376,9 +526,13 @@
test("a lazy transformer that doesn't apply updates its passed-through asset",
() {
- initGraph(["app|foo.txt"], {"app": [
- [new LazyRewriteTransformer("blub", "blab")]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("blub", "blab")]
+ ]
+ });
// Pause the provider so that the transformer will start forwarding the
// asset while it's dirty.
@@ -396,11 +550,19 @@
buildShouldSucceed();
});
- test("a lazy transformer is forced while the previous lazy transformer is "
+ test(
+ "a lazy transformer is forced while the previous lazy transformer is "
"available, then the previous transformer becomes unavailable", () {
var assets = new LazyAssetsTransformer(["app|out.one", "app|out.two"]);
var rewrite = new LazyRewriteTransformer("two", "three");
- initGraph(["app|foo.in"], {"app": [[assets], [rewrite]]});
+ initGraph([
+ "app|foo.in"
+ ], {
+ "app": [
+ [assets],
+ [rewrite]
+ ]
+ });
updateSources(["app|foo.in"]);
// Request out.one so that [assets] runs but the second does not.
diff --git a/packages/barback/test/package_graph/many_parallel_transformers_test.dart b/packages/barback/test/package_graph/many_parallel_transformers_test.dart
index 8c47241..d8c0b7f 100644
--- a/packages/barback/test/package_graph/many_parallel_transformers_test.dart
+++ b/packages/barback/test/package_graph/many_parallel_transformers_test.dart
@@ -16,7 +16,11 @@
currentSchedule.timeout *= 3;
var files = new List.generate(100, (i) => "app|$i.txt");
var rewrite = new RewriteTransformer("txt", "out");
- initGraph(files, {"app": [[rewrite]]});
+ initGraph(files, {
+ "app": [
+ [rewrite]
+ ]
+ });
// Pause and resume apply to simulate parallel long-running transformers.
rewrite.pauseApply();
diff --git a/packages/barback/test/package_graph/repetition_test.dart b/packages/barback/test/package_graph/repetition_test.dart
index 48462d8..2bb6180 100644
--- a/packages/barback/test/package_graph/repetition_test.dart
+++ b/packages/barback/test/package_graph/repetition_test.dart
@@ -4,7 +4,6 @@
library barback.test.package_graph.transform_test;
-import 'package:barback/src/utils.dart';
import 'package:scheduled_test/scheduled_test.dart';
import '../utils.dart';
@@ -19,8 +18,12 @@
initConfig();
test("updates sources many times", () {
- initGraph(["app|foo.txt"], {
- "app": [[new RewriteTransformer("txt", "out")]]
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new RewriteTransformer("txt", "out")]
+ ]
});
for (var i = 0; i < 1000; i++) {
@@ -32,8 +35,12 @@
});
test("updates and then removes sources many times", () {
- initGraph(["app|foo.txt"], {
- "app": [[new RewriteTransformer("txt", "out")]]
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new RewriteTransformer("txt", "out")]
+ ]
});
for (var i = 0; i < 1000; i++) {
@@ -48,11 +55,19 @@
test("updates transformers many times", () {
var rewrite = new RewriteTransformer("txt", "out");
- initGraph(["app|foo.txt"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
updateSources(["app|foo.txt"]);
for (var i = 0; i < 1000; i++) {
- updateTransformers("app", [[rewrite]]);
+ updateTransformers("app", [
+ [rewrite]
+ ]);
}
expectAsset("app|foo.out", "foo.out");
@@ -61,11 +76,19 @@
test("updates and removes transformers many times", () {
var rewrite = new RewriteTransformer("txt", "out");
- initGraph(["app|foo.txt"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
updateSources(["app|foo.txt"]);
for (var i = 0; i < 1000; i++) {
- updateTransformers("app", [[rewrite]]);
+ updateTransformers("app", [
+ [rewrite]
+ ]);
updateTransformers("app", [[]]);
}
diff --git a/packages/barback/test/package_graph/source_test.dart b/packages/barback/test/package_graph/source_test.dart
index b5763a8..8b8aecb 100644
--- a/packages/barback/test/package_graph/source_test.dart
+++ b/packages/barback/test/package_graph/source_test.dart
@@ -41,9 +41,13 @@
});
test("gets a source asset if not transformed", () {
- initGraph(["app|foo.txt"], {"app": [
- [new RewriteTransformer("nottxt", "whatever")]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new RewriteTransformer("nottxt", "whatever")]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.txt");
@@ -64,7 +68,13 @@
test("collapses redundant updates", () {
var transformer = new RewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
schedule(() {
// Make a bunch of synchronous update calls.
@@ -122,7 +132,14 @@
test("restarts a build if a source is updated while sources are loading", () {
var transformer = new RewriteTransformer("txt", "out");
- initGraph(["app|foo.txt", "app|other.bar"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.txt",
+ "app|other.bar"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
// Run the whole graph so all nodes are clean.
updateSources(["app|foo.txt", "app|other.bar"]);
diff --git a/packages/barback/test/package_graph/transform/aggregate_test.dart b/packages/barback/test/package_graph/transform/aggregate_test.dart
index d6fb050..eaca547 100644
--- a/packages/barback/test/package_graph/transform/aggregate_test.dart
+++ b/packages/barback/test/package_graph/transform/aggregate_test.dart
@@ -4,7 +4,6 @@
library barback.test.package_graph.transform.aggregate_test;
-import 'package:barback/src/utils.dart';
import 'package:scheduled_test/scheduled_test.dart';
import '../../utils.dart';
@@ -21,9 +20,11 @@
"app|dir/subdir/zap.png"
];
- initGraph(sources, {"app": [
- [new AggregateManyToOneTransformer("txt", "out.txt")]
- ]});
+ initGraph(sources, {
+ "app": [
+ [new AggregateManyToOneTransformer("txt", "out.txt")]
+ ]
+ });
updateSources(sources);
expectAsset("app|dir/out.txt", "bar\nfoo");
@@ -33,9 +34,14 @@
test("an aggregate transformer isn't run if there are no primary inputs", () {
var transformer = new AggregateManyToOneTransformer("txt", "out.txt");
- initGraph(["app|foo.zip", "app|bar.zap"], {"app": [
- [transformer]
- ]});
+ initGraph([
+ "app|foo.zip",
+ "app|bar.zap"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.zip", "app|bar.zap"]);
expectNoAsset("app|out.txt");
@@ -45,9 +51,14 @@
});
test("an aggregate transformer is re-run if a primary input changes", () {
- initGraph(["app|foo.txt", "app|bar.txt"], {"app": [
- [new AggregateManyToOneTransformer("txt", "out.txt")]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt"
+ ], {
+ "app": [
+ [new AggregateManyToOneTransformer("txt", "out.txt")]
+ ]
+ });
updateSources(["app|foo.txt", "app|bar.txt"]);
expectAsset("app|out.txt", "bar\nfoo");
@@ -60,9 +71,14 @@
});
test("an aggregate transformer is re-run if a primary input is removed", () {
- initGraph(["app|foo.txt", "app|bar.txt"], {"app": [
- [new AggregateManyToOneTransformer("txt", "out.txt")]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt"
+ ], {
+ "app": [
+ [new AggregateManyToOneTransformer("txt", "out.txt")]
+ ]
+ });
updateSources(["app|foo.txt", "app|bar.txt"]);
expectAsset("app|out.txt", "bar\nfoo");
@@ -74,9 +90,15 @@
});
test("an aggregate transformer is re-run if a primary input is added", () {
- initGraph(["app|foo.txt", "app|bar.txt", "app|baz.txt"], {"app": [
- [new AggregateManyToOneTransformer("txt", "out.txt")]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt",
+ "app|baz.txt"
+ ], {
+ "app": [
+ [new AggregateManyToOneTransformer("txt", "out.txt")]
+ ]
+ });
updateSources(["app|foo.txt", "app|bar.txt"]);
expectAsset("app|out.txt", "bar\nfoo");
@@ -87,11 +109,17 @@
buildShouldSucceed();
});
- test("an aggregate transformer ceases to run if all primary inputs are "
+ test(
+ "an aggregate transformer ceases to run if all primary inputs are "
"removed", () {
- initGraph(["app|foo.txt", "app|bar.txt"], {"app": [
- [new AggregateManyToOneTransformer("txt", "out.txt")]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt"
+ ], {
+ "app": [
+ [new AggregateManyToOneTransformer("txt", "out.txt")]
+ ]
+ });
updateSources(["app|foo.txt", "app|bar.txt"]);
expectAsset("app|out.txt", "bar\nfoo");
@@ -102,11 +130,17 @@
buildShouldSucceed();
});
- test("an aggregate transformer starts to run if new primary inputs are "
+ test(
+ "an aggregate transformer starts to run if new primary inputs are "
"added", () {
- initGraph(["app|foo.txt", "app|bar.txt"], {"app": [
- [new AggregateManyToOneTransformer("txt", "out.txt")]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt"
+ ], {
+ "app": [
+ [new AggregateManyToOneTransformer("txt", "out.txt")]
+ ]
+ });
updateSources([]);
expectNoAsset("app|out.txt");
@@ -118,11 +152,17 @@
});
group("pass-through", () {
- test("an aggregate transformer passes through its primary inputs by "
+ test(
+ "an aggregate transformer passes through its primary inputs by "
"default", () {
- initGraph(["app|foo.txt", "app|bar.txt"], {"app": [
- [new AggregateManyToOneTransformer("txt", "out.txt")]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt"
+ ], {
+ "app": [
+ [new AggregateManyToOneTransformer("txt", "out.txt")]
+ ]
+ });
updateSources(["app|foo.txt", "app|bar.txt"]);
expectAsset("app|foo.txt", "foo");
@@ -136,9 +176,14 @@
});
test("an aggregate transformer can overwrite its primary inputs", () {
- initGraph(["app|foo.txt", "app|bar.txt"], {"app": [
- [new AggregateManyToManyTransformer("txt")]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt"
+ ], {
+ "app": [
+ [new AggregateManyToManyTransformer("txt")]
+ ]
+ });
updateSources(["app|foo.txt", "app|bar.txt"]);
expectAsset("app|foo.txt", "modified foo");
@@ -148,11 +193,16 @@
test("an aggregate transformer can consume its primary inputs", () {
var transformer = new AggregateManyToOneTransformer("txt", "out.txt");
- transformer.consumePrimaries
- ..add("app|foo.txt")
- ..add("app|bar.txt");
+ transformer.consumePrimaries..add("app|foo.txt")..add("app|bar.txt");
- initGraph(["app|foo.txt", "app|bar.txt"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.txt", "app|bar.txt"]);
expectNoAsset("app|foo.txt");
@@ -161,9 +211,14 @@
});
test("an aggregate transformer passes through non-primary inputs", () {
- initGraph(["app|foo.jpg", "app|bar.png"], {"app": [
- [new AggregateManyToManyTransformer("txt")]
- ]});
+ initGraph([
+ "app|foo.jpg",
+ "app|bar.png"
+ ], {
+ "app": [
+ [new AggregateManyToManyTransformer("txt")]
+ ]
+ });
updateSources(["app|foo.jpg", "app|bar.png"]);
expectAsset("app|foo.jpg", "foo");
@@ -178,13 +233,19 @@
});
group("apply() transform stream", () {
- test("the primary input stream doesn't close if a previous phase is still "
+ test(
+ "the primary input stream doesn't close if a previous phase is still "
"running", () {
var rewrite = new RewriteTransformer("a", "b");
- initGraph(["app|foo.txt", "app|bar.a"], {"app": [
- [rewrite],
- [new AggregateManyToOneTransformer("txt", "out.txt")]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.a"
+ ], {
+ "app": [
+ [rewrite],
+ [new AggregateManyToOneTransformer("txt", "out.txt")]
+ ]
+ });
rewrite.pauseApply();
updateSources(["app|foo.txt", "app|bar.a"]);
@@ -195,13 +256,19 @@
buildShouldSucceed();
});
- test("the primary input stream doesn't close if a previous phase is "
+ test(
+ "the primary input stream doesn't close if a previous phase is "
"materializing a primary input", () {
var rewrite = new DeclaringRewriteTransformer("in", "txt");
- initGraph(["app|foo.txt", "app|bar.in"], {"app": [
- [rewrite],
- [new AggregateManyToOneTransformer("txt", "out.txt")]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.in"
+ ], {
+ "app": [
+ [rewrite],
+ [new AggregateManyToOneTransformer("txt", "out.txt")]
+ ]
+ });
rewrite.pauseApply();
updateSources(["app|foo.txt", "app|bar.in"]);
@@ -212,13 +279,19 @@
buildShouldSucceed();
});
- test("the primary input stream closes if a previous phase is only "
+ test(
+ "the primary input stream closes if a previous phase is only "
"materializing non-primary inputs", () {
var rewrite = new DeclaringRewriteTransformer("a", "b");
- initGraph(["app|foo.txt", "app|bar.a"], {"app": [
- [rewrite],
- [new AggregateManyToOneTransformer("txt", "out.txt")]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.a"
+ ], {
+ "app": [
+ [rewrite],
+ [new AggregateManyToOneTransformer("txt", "out.txt")]
+ ]
+ });
rewrite.pauseApply();
updateSources(["app|foo.txt", "app|bar.a"]);
@@ -228,14 +301,21 @@
buildShouldSucceed();
});
- test("a new primary input that arrives before the stream closes doesn't "
+ test(
+ "a new primary input that arrives before the stream closes doesn't "
"cause apply to restart", () {
var rewrite = new RewriteTransformer("a", "b");
var aggregate = new AggregateManyToOneTransformer("txt", "out.txt");
- initGraph(["app|foo.txt", "app|bar.txt", "app|baz.a"], {"app": [
- [rewrite],
- [aggregate]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt",
+ "app|baz.a"
+ ], {
+ "app": [
+ [rewrite],
+ [aggregate]
+ ]
+ });
// The stream won't close until [rewrite] finishes running `apply()`.
rewrite.pauseApply();
@@ -253,10 +333,18 @@
expect(aggregate.numRuns, completion(equals(1)));
});
- test("a new primary input that arrives after the stream closes causes "
+ test(
+ "a new primary input that arrives after the stream closes causes "
"apply to restart", () {
var aggregate = new AggregateManyToOneTransformer("txt", "out.txt");
- initGraph(["app|foo.txt", "app|bar.txt"], {"app": [[aggregate]]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt"
+ ], {
+ "app": [
+ [aggregate]
+ ]
+ });
aggregate.pauseApply();
updateSources(["app|foo.txt"]);
@@ -272,14 +360,20 @@
expect(aggregate.numRuns, completion(equals(2)));
});
- test("a primary input that's modified before the stream closes causes "
+ test(
+ "a primary input that's modified before the stream closes causes "
"apply to restart", () {
var rewrite = new RewriteTransformer("a", "b");
var aggregate = new AggregateManyToOneTransformer("txt", "out.txt");
- initGraph(["app|foo.txt", "app|bar.a"], {"app": [
- [rewrite],
- [aggregate]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.a"
+ ], {
+ "app": [
+ [rewrite],
+ [aggregate]
+ ]
+ });
// The stream won't close until [rewrite] finishes running `apply()`.
rewrite.pauseApply();
@@ -298,14 +392,21 @@
expect(aggregate.numRuns, completion(equals(2)));
});
- test("a primary input that's removed before the stream closes causes apply "
+ test(
+ "a primary input that's removed before the stream closes causes apply "
"to restart", () {
var rewrite = new RewriteTransformer("a", "b");
var aggregate = new AggregateManyToOneTransformer("txt", "out.txt");
- initGraph(["app|foo.txt", "app|bar.txt", "app|baz.a"], {"app": [
- [rewrite],
- [aggregate]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt",
+ "app|baz.a"
+ ], {
+ "app": [
+ [rewrite],
+ [aggregate]
+ ]
+ });
// The stream won't close until [rewrite] finishes running `apply()`.
rewrite.pauseApply();
@@ -323,4 +424,4 @@
expect(aggregate.numRuns, completion(equals(2)));
});
});
-}
\ No newline at end of file
+}
diff --git a/packages/barback/test/package_graph/transform/concurrency_test.dart b/packages/barback/test/package_graph/transform/concurrency_test.dart
index f8927bb..834ea9a 100644
--- a/packages/barback/test/package_graph/transform/concurrency_test.dart
+++ b/packages/barback/test/package_graph/transform/concurrency_test.dart
@@ -16,7 +16,13 @@
test("runs transforms in the same phase in parallel", () {
var transformerA = new RewriteTransformer("txt", "a");
var transformerB = new RewriteTransformer("txt", "b");
- initGraph(["app|foo.txt"], {"app": [[transformerA, transformerB]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [transformerA, transformerB]
+ ]
+ });
transformerA.pauseApply();
transformerB.pauseApply();
@@ -38,10 +44,17 @@
buildShouldSucceed();
});
- test("discards outputs from a transform whose primary input is removed "
+ test(
+ "discards outputs from a transform whose primary input is removed "
"during processing", () {
var rewrite = new RewriteTransformer("txt", "out");
- initGraph(["app|foo.txt"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
rewrite.pauseApply();
updateSources(["app|foo.txt"]);
@@ -59,7 +72,11 @@
var check2 = new CheckContentTransformer("second", "#2");
initGraph({
"app|foo.txt": "first",
- }, {"app": [[check1, check2]]});
+ }, {
+ "app": [
+ [check1, check2]
+ ]
+ });
check1.pauseIsPrimary("app|foo.txt");
updateSources(["app|foo.txt"]);
@@ -74,13 +91,18 @@
buildShouldSucceed();
});
- test("applies the correct transform if an asset is removed and added during "
+ test(
+ "applies the correct transform if an asset is removed and added during "
"isPrimary", () {
var check1 = new CheckContentTransformer("first", "#1");
var check2 = new CheckContentTransformer("second", "#2");
initGraph({
"app|foo.txt": "first",
- }, {"app": [[check1, check2]]});
+ }, {
+ "app": [
+ [check1, check2]
+ ]
+ });
check1.pauseIsPrimary("app|foo.txt");
updateSources(["app|foo.txt"]);
@@ -98,7 +120,13 @@
test("restarts processing if a change occurs during processing", () {
var transformer = new RewriteTransformer("txt", "out");
- initGraph(["app|foo.txt"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
transformer.pauseApply();
@@ -118,7 +146,13 @@
test("aborts processing if the primary input is removed during processing",
() {
var transformer = new RewriteTransformer("txt", "out");
- initGraph(["app|foo.txt"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
transformer.pauseApply();
@@ -135,13 +169,18 @@
expect(transformer.numRuns, completion(equals(1)));
});
- test("restarts processing if a change to a new secondary input occurs during "
+ test(
+ "restarts processing if a change to a new secondary input occurs during "
"processing", () {
var transformer = new ManyToOneTransformer("txt");
initGraph({
"app|foo.txt": "bar.inc",
"app|bar.inc": "bar"
- }, {"app": [[transformer]]});
+ }, {
+ "app": [
+ [transformer]
+ ]
+ });
transformer.pauseApply();
@@ -166,14 +205,19 @@
expect(transformer.numRuns, completion(equals(2)));
});
- test("doesn't restart processing if a change to an old secondary input "
+ test(
+ "doesn't restart processing if a change to an old secondary input "
"occurs during processing", () {
var transformer = new ManyToOneTransformer("txt");
initGraph({
"app|foo.txt": "bar.inc",
"app|bar.inc": "bar",
"app|baz.inc": "baz"
- }, {"app": [[transformer]]});
+ }, {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.txt", "app|bar.inc", "app|baz.inc"]);
expectAsset("app|foo.out", "bar");
@@ -203,8 +247,15 @@
test("restarts before finishing later phases when a change occurs", () {
var txtToInt = new RewriteTransformer("txt", "int");
var intToOut = new RewriteTransformer("int", "out");
- initGraph(["app|foo.txt", "app|bar.txt"],
- {"app": [[txtToInt], [intToOut]]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt"
+ ], {
+ "app": [
+ [txtToInt],
+ [intToOut]
+ ]
+ });
txtToInt.pauseApply();
@@ -225,10 +276,14 @@
});
test("doesn't return an asset until it's finished rebuilding", () {
- initGraph(["app|foo.in"], {"app": [
- [new RewriteTransformer("in", "mid")],
- [new RewriteTransformer("mid", "out")]
- ]});
+ initGraph([
+ "app|foo.in"
+ ], {
+ "app": [
+ [new RewriteTransformer("in", "mid")],
+ [new RewriteTransformer("mid", "out")]
+ ]
+ });
updateSources(["app|foo.in"]);
expectAsset("app|foo.out", "foo.mid.out");
@@ -247,7 +302,13 @@
test("doesn't return an asset until its in-place transform is done", () {
var rewrite = new RewriteTransformer("txt", "txt");
- initGraph(["app|foo.txt"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
rewrite.pauseApply();
updateSources(["app|foo.txt"]);
@@ -260,7 +321,13 @@
test("doesn't return an asset that's removed during isPrimary", () {
var rewrite = new RewriteTransformer("txt", "txt");
- initGraph(["app|foo.txt"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
rewrite.pauseIsPrimary("app|foo.txt");
updateSources(["app|foo.txt"]);
@@ -273,12 +340,17 @@
buildShouldSucceed();
});
- test("doesn't transform an asset that goes from primary to non-primary "
+ test(
+ "doesn't transform an asset that goes from primary to non-primary "
"during isPrimary", () {
var check = new CheckContentTransformer(new RegExp(r"^do$"), "ne");
initGraph({
"app|foo.txt": "do"
- }, {"app": [[check]]});
+ }, {
+ "app": [
+ [check]
+ ]
+ });
check.pauseIsPrimary("app|foo.txt");
updateSources(["app|foo.txt"]);
@@ -293,12 +365,17 @@
buildShouldSucceed();
});
- test("transforms an asset that goes from non-primary to primary "
+ test(
+ "transforms an asset that goes from non-primary to primary "
"during isPrimary", () {
var check = new CheckContentTransformer("do", "ne");
initGraph({
"app|foo.txt": "don't"
- }, {"app": [[check]]});
+ }, {
+ "app": [
+ [check]
+ ]
+ });
check.pauseIsPrimary("app|foo.txt");
updateSources(["app|foo.txt"]);
@@ -313,11 +390,19 @@
buildShouldSucceed();
});
- test("doesn't return an asset that's removed during another transformer's "
+ test(
+ "doesn't return an asset that's removed during another transformer's "
"isPrimary", () {
var rewrite1 = new RewriteTransformer("txt", "txt");
var rewrite2 = new RewriteTransformer("md", "md");
- initGraph(["app|foo.txt", "app|foo.md"], {"app": [[rewrite1, rewrite2]]});
+ initGraph([
+ "app|foo.txt",
+ "app|foo.md"
+ ], {
+ "app": [
+ [rewrite1, rewrite2]
+ ]
+ });
rewrite2.pauseIsPrimary("app|foo.md");
updateSources(["app|foo.txt", "app|foo.md"]);
@@ -331,14 +416,19 @@
buildShouldSucceed();
});
- test("doesn't transform an asset that goes from primary to non-primary "
+ test(
+ "doesn't transform an asset that goes from primary to non-primary "
"during another transformer's isPrimary", () {
var rewrite = new RewriteTransformer("md", "md");
var check = new CheckContentTransformer(new RegExp(r"^do$"), "ne");
initGraph({
"app|foo.txt": "do",
"app|foo.md": "foo"
- }, {"app": [[rewrite, check]]});
+ }, {
+ "app": [
+ [rewrite, check]
+ ]
+ });
rewrite.pauseIsPrimary("app|foo.md");
updateSources(["app|foo.txt", "app|foo.md"]);
@@ -354,14 +444,19 @@
buildShouldSucceed();
});
- test("transforms an asset that goes from non-primary to primary "
+ test(
+ "transforms an asset that goes from non-primary to primary "
"during another transformer's isPrimary", () {
var rewrite = new RewriteTransformer("md", "md");
var check = new CheckContentTransformer("do", "ne");
initGraph({
"app|foo.txt": "don't",
"app|foo.md": "foo"
- }, {"app": [[rewrite, check]]});
+ }, {
+ "app": [
+ [rewrite, check]
+ ]
+ });
rewrite.pauseIsPrimary("app|foo.md");
updateSources(["app|foo.txt", "app|foo.md"]);
@@ -381,7 +476,11 @@
initGraph([
"app|foo.in",
"app|bar.in",
- ], {"app": [[new RewriteTransformer("in", "out")]]});
+ ], {
+ "app": [
+ [new RewriteTransformer("in", "out")]
+ ]
+ });
updateSources(["app|foo.in", "app|bar.in"]);
expectAsset("app|foo.out", "foo.out");
@@ -403,7 +502,11 @@
test("doesn't report AssetNotFound until all builds are finished", () {
initGraph([
"app|foo.in",
- ], {"app": [[new RewriteTransformer("in", "out")]]});
+ ], {
+ "app": [
+ [new RewriteTransformer("in", "out")]
+ ]
+ });
updateSources(["app|foo.in"]);
expectAsset("app|foo.out", "foo.out");
@@ -426,7 +529,14 @@
initGraph([
"pkg1|foo.txt",
"pkg2|foo.txt"
- ], {"pkg1": [[rewrite]], "pkg2": [[rewrite]]});
+ ], {
+ "pkg1": [
+ [rewrite]
+ ],
+ "pkg2": [
+ [rewrite]
+ ]
+ });
// First, run both packages' transformers so both packages are successful.
updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]);
@@ -447,11 +557,18 @@
buildShouldSucceed();
});
- test("one transformer takes a long time while the other finishes, then "
+ test(
+ "one transformer takes a long time while the other finishes, then "
"the input is removed", () {
var rewrite1 = new RewriteTransformer("txt", "out1");
var rewrite2 = new RewriteTransformer("txt", "out2");
- initGraph(["app|foo.txt"], {"app": [[rewrite1, rewrite2]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [rewrite1, rewrite2]
+ ]
+ });
rewrite1.pauseApply();
@@ -471,16 +588,19 @@
expectNoAsset("app|foo.out2");
});
- test("a transformer in a later phase gets a slow secondary input from an "
+ test(
+ "a transformer in a later phase gets a slow secondary input from an "
"earlier phase", () {
var rewrite = new RewriteTransformer("in", "in");
initGraph({
"app|foo.in": "foo",
"app|bar.txt": "foo.in"
- }, {"app": [
- [rewrite],
- [new ManyToOneTransformer("txt")]
- ]});
+ }, {
+ "app": [
+ [rewrite],
+ [new ManyToOneTransformer("txt")]
+ ]
+ });
rewrite.pauseApply();
updateSources(["app|foo.in", "app|bar.txt"]);
@@ -491,11 +611,16 @@
buildShouldSucceed();
});
- test("materializes a passed-through asset that was emitted before it was "
+ test(
+ "materializes a passed-through asset that was emitted before it was "
"available", () {
- initGraph(["app|foo.in"], {"app": [
- [new RewriteTransformer("txt", "txt")]
- ]});
+ initGraph([
+ "app|foo.in"
+ ], {
+ "app": [
+ [new RewriteTransformer("txt", "txt")]
+ ]
+ });
pauseProvider();
updateSources(["app|foo.in"]);
@@ -512,10 +637,12 @@
initGraph([
"app|foo.txt"
- ], {"app": [
- [transformer1],
- [transformer2]
- ]});
+ ], {
+ "app": [
+ [transformer1],
+ [transformer2]
+ ]
+ });
transformer2.pausePrimaryInput();
updateSources(["app|foo.txt"]);
@@ -541,7 +668,8 @@
});
// Regression test for issue 19038.
- test("a secondary input that's marked dirty followed by the primary input "
+ test(
+ "a secondary input that's marked dirty followed by the primary input "
"being synchronously marked dirty re-runs a transformer", () {
// Issue 19038 was caused by the following sequence of events:
//
@@ -568,15 +696,17 @@
"app|foo.txt": "one",
"app|one.in": "1",
"app|two.in": "2"
- }, {"app": [
- // We need to use CheckContentTransformer here so that
- // ManyToOneTransformer reads its primary input from memory rather than
- // from the filesystem. If it read from the filesystem, it might
- // accidentally get the correct output despite accessing the incorrect
- // asset, which would cause false positives for the test.
- [new CheckContentTransformer(new RegExp("one|two"), ".in")],
- [new ManyToOneTransformer("txt")]
- ]});
+ }, {
+ "app": [
+ // We need to use CheckContentTransformer here so that
+ // ManyToOneTransformer reads its primary input from memory rather than
+ // from the filesystem. If it read from the filesystem, it might
+ // accidentally get the correct output despite accessing the incorrect
+ // asset, which would cause false positives for the test.
+ [new CheckContentTransformer(new RegExp("one|two"), ".in")],
+ [new ManyToOneTransformer("txt")]
+ ]
+ });
updateSources(["app|foo.txt", "app|one.in", "app|two.in"]);
expectAsset("app|foo.out", "1");
diff --git a/packages/barback/test/package_graph/transform/consume_input_test.dart b/packages/barback/test/package_graph/transform/consume_input_test.dart
index 2580f5d..4aac1d4 100644
--- a/packages/barback/test/package_graph/transform/consume_input_test.dart
+++ b/packages/barback/test/package_graph/transform/consume_input_test.dart
@@ -4,7 +4,6 @@
library barback.test.package_graph.transform.pass_through_test;
-import 'package:barback/src/utils.dart';
import 'package:scheduled_test/scheduled_test.dart';
import '../../utils.dart';
@@ -15,7 +14,9 @@
initGraph([
"app|foo.txt"
], {
- "app": [[new RewriteTransformer("txt", "out")..consumePrimary = true]]
+ "app": [
+ [new RewriteTransformer("txt", "out")..consumePrimary = true]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -28,10 +29,12 @@
initGraph([
"app|foo.txt"
], {
- "app": [[
- new RewriteTransformer("txt", "out")..consumePrimary = true,
- new RewriteTransformer("txt", "txt")
- ]]
+ "app": [
+ [
+ new RewriteTransformer("txt", "out")..consumePrimary = true,
+ new RewriteTransformer("txt", "txt")
+ ]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -44,9 +47,9 @@
initGraph({
"app|foo.txt": "yes"
}, {
- "app": [[
- new ConditionallyConsumePrimaryTransformer("txt", "out", "yes")
- ]]
+ "app": [
+ [new ConditionallyConsumePrimaryTransformer("txt", "out", "yes")]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -62,11 +65,15 @@
});
test("two sibling transforms both consume their input", () {
- initGraph(["app|foo.txt"], {
- "app": [[
- new RewriteTransformer("txt", "one")..consumePrimary = true,
- new RewriteTransformer("txt", "two")..consumePrimary = true
- ]]
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [
+ new RewriteTransformer("txt", "one")..consumePrimary = true,
+ new RewriteTransformer("txt", "two")..consumePrimary = true
+ ]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -76,15 +83,18 @@
buildShouldSucceed();
});
- test("a transform stops consuming its input but a sibling is still "
+ test(
+ "a transform stops consuming its input but a sibling is still "
"consuming it", () {
initGraph({
"app|foo.txt": "yes"
}, {
- "app": [[
- new RewriteTransformer("txt", "one")..consumePrimary = true,
- new ConditionallyConsumePrimaryTransformer("txt", "two", "yes")
- ]]
+ "app": [
+ [
+ new RewriteTransformer("txt", "one")..consumePrimary = true,
+ new ConditionallyConsumePrimaryTransformer("txt", "two", "yes")
+ ]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -105,7 +115,9 @@
initGraph([
"app|foo.txt"
], {
- "app": [[new EmitNothingTransformer("txt")..consumePrimary = true]]
+ "app": [
+ [new EmitNothingTransformer("txt")..consumePrimary = true]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -117,7 +129,9 @@
initGraph([
"app|foo.txt"
], {
- "app": [[new RewriteTransformer("txt", "out")..consumePrimary = true]]
+ "app": [
+ [new RewriteTransformer("txt", "out")..consumePrimary = true]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -131,12 +145,13 @@
buildShouldSucceed();
});
- test("a transform consumes its input and emits nothing, then is removed",
- () {
+ test("a transform consumes its input and emits nothing, then is removed", () {
initGraph([
"app|foo.txt"
], {
- "app": [[new EmitNothingTransformer("txt")..consumePrimary = true]]
+ "app": [
+ [new EmitNothingTransformer("txt")..consumePrimary = true]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -160,11 +175,11 @@
expectAsset("app|foo.txt", "foo");
buildShouldSucceed();
- updateTransformers("app", [[
- new RewriteTransformer("txt", "out")..consumePrimary = true
- ]]);
+ updateTransformers("app", [
+ [new RewriteTransformer("txt", "out")..consumePrimary = true]
+ ]);
expectAsset("app|foo.out", "foo.out");
expectNoAsset("app|foo.txt");
buildShouldSucceed();
});
-}
\ No newline at end of file
+}
diff --git a/packages/barback/test/package_graph/transform/cross_package_test.dart b/packages/barback/test/package_graph/transform/cross_package_test.dart
index b499604..f91c897 100644
--- a/packages/barback/test/package_graph/transform/cross_package_test.dart
+++ b/packages/barback/test/package_graph/transform/cross_package_test.dart
@@ -4,7 +4,6 @@
library barback.test.package_graph.transform.pass_through_test;
-import 'package:barback/src/utils.dart';
import 'package:scheduled_test/scheduled_test.dart';
import '../../utils.dart';
@@ -15,7 +14,11 @@
initGraph({
"pkg1|a.txt": "pkg2|a.inc",
"pkg2|a.inc": "a"
- }, {"pkg1": [[new ManyToOneTransformer("txt")]]});
+ }, {
+ "pkg1": [
+ [new ManyToOneTransformer("txt")]
+ ]
+ });
updateSources(["pkg1|a.txt", "pkg2|a.inc"]);
expectAsset("pkg1|a.out", "a");
@@ -27,8 +30,12 @@
"pkg1|a.txt": "pkg2|a.inc",
"pkg2|a.txt": "a"
}, {
- "pkg1": [[new ManyToOneTransformer("txt")]],
- "pkg2": [[new RewriteTransformer("txt", "inc")]]
+ "pkg1": [
+ [new ManyToOneTransformer("txt")]
+ ],
+ "pkg2": [
+ [new RewriteTransformer("txt", "inc")]
+ ]
});
updateSources(["pkg1|a.txt", "pkg2|a.txt"]);
@@ -41,7 +48,9 @@
"pkg1|a.txt": "pkg2|a.inc",
"pkg2|a.inc": "a"
}, {
- "pkg1": [[new ManyToOneTransformer("txt")]]
+ "pkg1": [
+ [new ManyToOneTransformer("txt")]
+ ]
});
updateSources(["pkg1|a.txt", "pkg2|a.inc"]);
@@ -54,14 +63,19 @@
buildShouldSucceed();
});
- test("re-runs a transform when a transformed input from another package "
+ test(
+ "re-runs a transform when a transformed input from another package "
"changes", () {
initGraph({
"pkg1|a.txt": "pkg2|a.inc",
"pkg2|a.txt": "a"
}, {
- "pkg1": [[new ManyToOneTransformer("txt")]],
- "pkg2": [[new RewriteTransformer("txt", "inc")]]
+ "pkg1": [
+ [new ManyToOneTransformer("txt")]
+ ],
+ "pkg2": [
+ [new RewriteTransformer("txt", "inc")]
+ ]
});
updateSources(["pkg1|a.txt", "pkg2|a.txt"]);
@@ -74,14 +88,17 @@
buildShouldSucceed();
});
- test("doesn't complete the build until all packages' transforms are "
+ test(
+ "doesn't complete the build until all packages' transforms are "
"finished running", () {
var transformer = new ManyToOneTransformer("txt");
initGraph({
"pkg1|a.txt": "pkg2|a.inc",
"pkg2|a.inc": "a"
}, {
- "pkg1": [[transformer]]
+ "pkg1": [
+ [transformer]
+ ]
});
updateSources(["pkg1|a.txt", "pkg2|a.inc"]);
@@ -126,7 +143,8 @@
buildShouldSucceed();
});
- test("doesn't run a transform that's removed because of a change in "
+ test(
+ "doesn't run a transform that's removed because of a change in "
"another package", () {
initGraph({
"pkg1|a.txt": "pkg2|a.inc",
@@ -151,14 +169,19 @@
buildShouldSucceed();
});
- test("sees a transformer that's newly applied to a cross-package "
+ test(
+ "sees a transformer that's newly applied to a cross-package "
"dependency", () {
initGraph({
"pkg1|a.txt": "pkg2|a.inc",
"pkg2|a.inc": "a"
}, {
- "pkg1": [[new ManyToOneTransformer("txt")]],
- "pkg2": [[new CheckContentTransformer("b", " transformed")]]
+ "pkg1": [
+ [new ManyToOneTransformer("txt")]
+ ],
+ "pkg2": [
+ [new CheckContentTransformer("b", " transformed")]
+ ]
});
updateSources(["pkg1|a.txt", "pkg2|a.inc"]);
@@ -171,14 +194,19 @@
buildShouldSucceed();
});
- test("doesn't see a transformer that's newly not applied to a "
+ test(
+ "doesn't see a transformer that's newly not applied to a "
"cross-package dependency", () {
initGraph({
"pkg1|a.txt": "pkg2|a.inc",
"pkg2|a.inc": "a"
}, {
- "pkg1": [[new ManyToOneTransformer("txt")]],
- "pkg2": [[new CheckContentTransformer("a", " transformed")]]
+ "pkg1": [
+ [new ManyToOneTransformer("txt")]
+ ],
+ "pkg2": [
+ [new CheckContentTransformer("a", " transformed")]
+ ]
});
updateSources(["pkg1|a.txt", "pkg2|a.inc"]);
@@ -190,4 +218,4 @@
expectAsset("pkg1|a.out", "b");
buildShouldSucceed();
});
-}
\ No newline at end of file
+}
diff --git a/packages/barback/test/package_graph/transform/declaring_aggregate_test.dart b/packages/barback/test/package_graph/transform/declaring_aggregate_test.dart
index 3465f26..884a541 100644
--- a/packages/barback/test/package_graph/transform/declaring_aggregate_test.dart
+++ b/packages/barback/test/package_graph/transform/declaring_aggregate_test.dart
@@ -13,9 +13,15 @@
initConfig();
group("a declaring aggregate transformer", () {
test("is eager by default", () {
- var transformer = new DeclaringAggregateManyToOneTransformer(
- "txt", "out.txt");
- initGraph(["app|foo.txt"], {"app": [[transformer]]});
+ var transformer =
+ new DeclaringAggregateManyToOneTransformer("txt", "out.txt");
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.txt"]);
buildShouldSucceed();
@@ -25,11 +31,17 @@
test("is deferred if any primary input is deferred", () {
var rewrite = new LazyRewriteTransformer("in", "txt");
- var aggregate = new DeclaringAggregateManyToOneTransformer(
- "txt", "out.txt");
- initGraph(["app|foo.in", "app|bar.txt", "app|baz.txt"], {"app": [
- [rewrite]
- ]});
+ var aggregate =
+ new DeclaringAggregateManyToOneTransformer("txt", "out.txt");
+ initGraph([
+ "app|foo.in",
+ "app|bar.txt",
+ "app|baz.txt"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
updateSources(["app|foo.in", "app|bar.txt", "app|baz.txt"]);
buildShouldSucceed();
@@ -37,7 +49,10 @@
// Add [aggregate] to the graph after a build has been completed so that
// all its inputs are available immediately. Otherwise it could start
// applying eagerly before receiving its lazy input.
- updateTransformers("app", [[rewrite], [aggregate]]);
+ updateTransformers("app", [
+ [rewrite],
+ [aggregate]
+ ]);
buildShouldSucceed();
expect(aggregate.numRuns, completion(equals(0)));
@@ -48,12 +63,18 @@
test("switches from eager to deferred if a deferred primary input is added",
() {
- var transformer = new DeclaringAggregateManyToOneTransformer(
- "txt", "out.txt");
- initGraph(["app|foo.in", "app|bar.txt", "app|baz.txt"], {"app": [
- [new LazyRewriteTransformer("in", "txt")],
- [transformer]
- ]});
+ var transformer =
+ new DeclaringAggregateManyToOneTransformer("txt", "out.txt");
+ initGraph([
+ "app|foo.in",
+ "app|bar.txt",
+ "app|baz.txt"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("in", "txt")],
+ [transformer]
+ ]
+ });
updateSources(["app|bar.txt", "app|baz.txt"]);
buildShouldSucceed();
@@ -68,14 +89,21 @@
expect(transformer.numRuns, completion(equals(2)));
});
- test("switches from deferred to eager if its last deferred primary input "
+ test(
+ "switches from deferred to eager if its last deferred primary input "
"is removed", () {
var rewrite = new LazyRewriteTransformer("in", "txt");
- var aggregate = new DeclaringAggregateManyToOneTransformer(
- "txt", "out.txt");
- initGraph(["app|foo.in", "app|bar.txt", "app|baz.txt"], {"app": [
- [rewrite]
- ]});
+ var aggregate =
+ new DeclaringAggregateManyToOneTransformer("txt", "out.txt");
+ initGraph([
+ "app|foo.in",
+ "app|bar.txt",
+ "app|baz.txt"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
updateSources(["app|foo.in", "app|bar.txt", "app|baz.txt"]);
buildShouldSucceed();
@@ -83,7 +111,10 @@
// Add [aggregate] to the graph after a build has been completed so that
// all its inputs are available immediately. Otherwise it could start
// applying eagerly before receiving its lazy input.
- updateTransformers("app", [[rewrite], [aggregate]]);
+ updateTransformers("app", [
+ [rewrite],
+ [aggregate]
+ ]);
buildShouldSucceed();
expect(aggregate.numRuns, completion(equals(0)));
@@ -92,7 +123,8 @@
expect(aggregate.numRuns, completion(equals(1)));
});
- test("begins running eagerly when all its deferred primary inputs become "
+ test(
+ "begins running eagerly when all its deferred primary inputs become "
"available", () {
var lazyPhase = [
new LazyAssetsTransformer(["app|foo.txt", "app|foo.x"],
@@ -100,11 +132,17 @@
new LazyAssetsTransformer(["app|bar.txt", "app|bar.x"],
input: "app|bar.in")
];
- var transformer = new DeclaringAggregateManyToOneTransformer(
- "txt", "out.txt");
- initGraph(["app|foo.in", "app|bar.in", "app|baz.txt"], {"app": [
- lazyPhase,
- ]});
+ var transformer =
+ new DeclaringAggregateManyToOneTransformer("txt", "out.txt");
+ initGraph([
+ "app|foo.in",
+ "app|bar.in",
+ "app|baz.txt"
+ ], {
+ "app": [
+ lazyPhase,
+ ]
+ });
updateSources(["app|foo.in", "app|bar.in", "app|baz.txt"]);
buildShouldSucceed();
@@ -112,7 +150,10 @@
// Add [transformer] to the graph after a build has been completed so that
// all its inputs are available immediately. Otherwise it could start
// applying eagerly before receiving its lazy inputs.
- updateTransformers("app", [lazyPhase, [transformer]]);
+ updateTransformers("app", [
+ lazyPhase,
+ [transformer]
+ ]);
buildShouldSucceed();
expect(transformer.numRuns, completion(equals(0)));
@@ -129,7 +170,8 @@
expect(transformer.numRuns, completion(equals(1)));
});
- test("stops running eagerly when any of its deferred primary inputs become "
+ test(
+ "stops running eagerly when any of its deferred primary inputs become "
"unavailable", () {
var lazyPhase = [
new LazyAssetsTransformer(["app|foo.txt", "app|foo.x"],
@@ -137,11 +179,15 @@
new LazyAssetsTransformer(["app|bar.txt", "app|bar.x"],
input: "app|bar.in")
];
- var transformer = new DeclaringAggregateManyToOneTransformer(
- "txt", "out.txt");
- initGraph(["app|foo.in", "app|bar.in", "app|baz.txt"], {"app": [
- lazyPhase
- ]});
+ var transformer =
+ new DeclaringAggregateManyToOneTransformer("txt", "out.txt");
+ initGraph([
+ "app|foo.in",
+ "app|bar.in",
+ "app|baz.txt"
+ ], {
+ "app": [lazyPhase]
+ });
updateSources(["app|foo.in", "app|bar.in", "app|baz.txt"]);
expectAsset("app|foo.x", "app|foo.x");
@@ -151,7 +197,10 @@
// Add [transformer] to the graph after a build has been completed so that
// all its inputs are available immediately. Otherwise it could start
// applying eagerly before receiving its lazy inputs.
- updateTransformers("app", [lazyPhase, [transformer]]);
+ updateTransformers("app", [
+ lazyPhase,
+ [transformer]
+ ]);
buildShouldSucceed();
expect(transformer.numRuns, completion(equals(1)));
@@ -162,10 +211,16 @@
});
test("re-declares its outputs for a new primary input", () {
- initGraph(["app|foo.in", "app|bar.txt", "app|baz.txt"], {"app": [
- [new LazyRewriteTransformer("in", "txt")],
- [new DeclaringAggregateManyToManyTransformer("txt")]
- ]});
+ initGraph([
+ "app|foo.in",
+ "app|bar.txt",
+ "app|baz.txt"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("in", "txt")],
+ [new DeclaringAggregateManyToManyTransformer("txt")]
+ ]
+ });
updateSources(["app|foo.in", "app|bar.txt"]);
buildShouldSucceed();
@@ -179,13 +234,20 @@
expectAsset("app|baz.txt", "modified baz");
});
- test("re-declares its outputs for a new primary input received while "
+ test(
+ "re-declares its outputs for a new primary input received while "
"applying", () {
var transformer = new DeclaringAggregateManyToManyTransformer("txt");
- initGraph(["app|foo.in", "app|bar.txt", "app|baz.txt"], {"app": [
- [new LazyRewriteTransformer("in", "txt")],
- [transformer]
- ]});
+ initGraph([
+ "app|foo.in",
+ "app|bar.txt",
+ "app|baz.txt"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("in", "txt")],
+ [transformer]
+ ]
+ });
transformer.pauseApply();
updateSources(["app|foo.in", "app|bar.txt"]);
@@ -200,13 +262,20 @@
expectAsset("app|baz.txt", "modified baz");
});
- test("re-declares its outputs for a new primary input received while "
+ test(
+ "re-declares its outputs for a new primary input received while "
"applying after a primary input was modified", () {
var transformer = new DeclaringAggregateManyToManyTransformer("txt");
- initGraph(["app|foo.in", "app|bar.txt", "app|baz.txt"], {"app": [
- [new LazyRewriteTransformer("in", "txt")],
- [transformer]
- ]});
+ initGraph([
+ "app|foo.in",
+ "app|bar.txt",
+ "app|baz.txt"
+ ], {
+ "app": [
+ [new LazyRewriteTransformer("in", "txt")],
+ [transformer]
+ ]
+ });
transformer.pauseApply();
updateSources(["app|foo.in", "app|bar.txt"]);
@@ -230,7 +299,13 @@
group("a lazy aggregate transformer", () {
test("doesn't run eagerly", () {
var transformer = new LazyAggregateManyToOneTransformer("txt", "out.txt");
- initGraph(["app|foo.txt"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.txt"]);
buildShouldSucceed();
@@ -239,9 +314,13 @@
});
test("runs when an output is requested", () {
- initGraph(["app|foo.txt"], {"app": [[
- new LazyAggregateManyToOneTransformer("txt", "out.txt")
- ]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new LazyAggregateManyToOneTransformer("txt", "out.txt")]
+ ]
+ });
updateSources(["app|foo.txt"]);
buildShouldSucceed();
diff --git a/packages/barback/test/package_graph/transform/pass_through_test.dart b/packages/barback/test/package_graph/transform/pass_through_test.dart
index 1e5f4b3..5189c95 100644
--- a/packages/barback/test/package_graph/transform/pass_through_test.dart
+++ b/packages/barback/test/package_graph/transform/pass_through_test.dart
@@ -15,11 +15,13 @@
initGraph([
"app|foo.in",
"app|bar.zip",
- ], {"app": [
- [new RewriteTransformer("in", "mid")],
- [new RewriteTransformer("zip", "zap")],
- [new RewriteTransformer("mid", "out")],
- ]});
+ ], {
+ "app": [
+ [new RewriteTransformer("in", "mid")],
+ [new RewriteTransformer("zip", "zap")],
+ [new RewriteTransformer("mid", "out")],
+ ]
+ });
updateSources(["app|foo.in", "app|bar.zip"]);
expectAsset("app|foo.out", "foo.mid.out");
@@ -30,11 +32,13 @@
test("passes an asset through a phase in which a transform uses it", () {
initGraph([
"app|foo.in",
- ], {"app": [
- [new RewriteTransformer("in", "mid")],
- [new RewriteTransformer("mid", "phase2")],
- [new RewriteTransformer("mid", "phase3")],
- ]});
+ ], {
+ "app": [
+ [new RewriteTransformer("in", "mid")],
+ [new RewriteTransformer("mid", "phase2")],
+ [new RewriteTransformer("mid", "phase3")],
+ ]
+ });
updateSources(["app|foo.in"]);
expectAsset("app|foo.in", "foo");
@@ -47,11 +51,16 @@
// If the asset were to get passed through, it might either cause a collision
// or silently supersede the overwriting asset. We want to assert that that
// doesn't happen.
- test("doesn't pass an asset through a phase in which a transform "
+ test(
+ "doesn't pass an asset through a phase in which a transform "
"overwrites it", () {
initGraph([
"app|foo.txt"
- ], {"app": [[new RewriteTransformer("txt", "txt")]]});
+ ], {
+ "app": [
+ [new RewriteTransformer("txt", "txt")]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.txt", "foo.txt");
@@ -62,10 +71,12 @@
initGraph([
"app|foo.in",
"app|bar.zip",
- ], {"app": [
- [new RewriteTransformer("zip", "zap")],
- [new RewriteTransformer("in", "out")],
- ]});
+ ], {
+ "app": [
+ [new RewriteTransformer("zip", "zap")],
+ [new RewriteTransformer("in", "out")],
+ ]
+ });
updateSources(["app|foo.in", "app|bar.zip"]);
expectAsset("app|foo.out", "foo.out");
@@ -81,10 +92,12 @@
initGraph([
"app|foo.in",
"app|bar.zip",
- ], {"app": [
- [new RewriteTransformer("zip", "zap")],
- [new RewriteTransformer("in", "out")],
- ]});
+ ], {
+ "app": [
+ [new RewriteTransformer("zip", "zap")],
+ [new RewriteTransformer("in", "out")],
+ ]
+ });
updateSources(["app|foo.in", "app|bar.zip"]);
expectAsset("app|foo.out", "foo.out");
@@ -96,15 +109,18 @@
buildShouldSucceed();
});
- test("passes an asset through a phase in which transforms have ceased to "
+ test(
+ "passes an asset through a phase in which transforms have ceased to "
"apply", () {
initGraph([
"app|foo.in",
- ], {"app": [
- [new RewriteTransformer("in", "mid")],
- [new CheckContentTransformer("foo.mid", ".phase2")],
- [new CheckContentTransformer(new RegExp(r"\.mid$"), ".phase3")],
- ]});
+ ], {
+ "app": [
+ [new RewriteTransformer("in", "mid")],
+ [new CheckContentTransformer("foo.mid", ".phase2")],
+ [new CheckContentTransformer(new RegExp(r"\.mid$"), ".phase3")],
+ ]
+ });
updateSources(["app|foo.in"]);
expectAsset("app|foo.mid", "foo.mid.phase2");
@@ -116,15 +132,18 @@
buildShouldSucceed();
});
- test("doesn't pass an asset through a phase in which transforms have "
+ test(
+ "doesn't pass an asset through a phase in which transforms have "
"started to apply", () {
initGraph([
"app|foo.in",
- ], {"app": [
- [new RewriteTransformer("in", "mid")],
- [new CheckContentTransformer("bar.mid", ".phase2")],
- [new CheckContentTransformer(new RegExp(r"\.mid$"), ".phase3")],
- ]});
+ ], {
+ "app": [
+ [new RewriteTransformer("in", "mid")],
+ [new CheckContentTransformer("bar.mid", ".phase2")],
+ [new CheckContentTransformer(new RegExp(r"\.mid$"), ".phase3")],
+ ]
+ });
updateSources(["app|foo.in"]);
expectAsset("app|foo.mid", "foo.mid.phase3");
@@ -138,7 +157,13 @@
test("doesn't pass an asset through if it's removed during isPrimary", () {
var check = new CheckContentTransformer("bar", " modified");
- initGraph(["app|foo.txt"], {"app": [[check]]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [check]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.txt", "foo");
@@ -156,10 +181,17 @@
buildShouldSucceed();
});
- test("passes an asset through when its overwriting transform becomes "
+ test(
+ "passes an asset through when its overwriting transform becomes "
"non-primary during apply", () {
var check = new CheckContentTransformer("yes", " modified");
- initGraph({"app|foo.txt": "yes"}, {"app": [[check]]});
+ initGraph({
+ "app|foo.txt": "yes"
+ }, {
+ "app": [
+ [check]
+ ]
+ });
check.pauseApply();
updateSources(["app|foo.txt"]);
@@ -173,13 +205,16 @@
buildShouldSucceed();
});
- test("doesn't pass an asset through when its overwriting transform becomes "
+ test(
+ "doesn't pass an asset through when its overwriting transform becomes "
"non-primary during apply if another transform overwrites it", () {
var check = new CheckContentTransformer("yes", " modified");
initGraph({
"app|foo.txt": "yes"
}, {
- "app": [[check, new RewriteTransformer("txt", "txt")]]
+ "app": [
+ [check, new RewriteTransformer("txt", "txt")]
+ ]
});
check.pauseApply();
@@ -195,15 +230,18 @@
buildShouldSucceed();
});
- test("doesn't pass an asset through when one overwriting transform becomes "
+ test(
+ "doesn't pass an asset through when one overwriting transform becomes "
"non-primary if another transform still overwrites it", () {
initGraph({
"app|foo.txt": "yes"
}, {
- "app": [[
- new CheckContentTransformer("yes", " modified"),
- new RewriteTransformer("txt", "txt")
- ]]
+ "app": [
+ [
+ new CheckContentTransformer("yes", " modified"),
+ new RewriteTransformer("txt", "txt")
+ ]
+ ]
});
updateSources(["app|foo.txt"]);
@@ -218,10 +256,17 @@
buildShouldSucceed();
});
- test("doesn't return a pass-through asset until we know it won't be "
+ test(
+ "doesn't return a pass-through asset until we know it won't be "
"overwritten", () {
var rewrite = new RewriteTransformer("txt", "txt");
- initGraph(["app|foo.a"], {"app": [[rewrite]]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [rewrite]
+ ]
+ });
rewrite.pauseIsPrimary("app|foo.a");
updateSources(["app|foo.a"]);
@@ -232,13 +277,18 @@
buildShouldSucceed();
});
- test("doesn't return a pass-through asset until we know it won't be "
+ test(
+ "doesn't return a pass-through asset until we know it won't be "
"overwritten when secondary inputs change", () {
var manyToOne = new ManyToOneTransformer("txt");
initGraph({
"app|foo.txt": "bar.in",
"app|bar.in": "bar"
- }, {"app": [[manyToOne]]});
+ }, {
+ "app": [
+ [manyToOne]
+ ]
+ });
updateSources(["app|foo.txt", "app|bar.in"]);
expectAsset("app|foo.txt", "bar.in");
@@ -252,4 +302,4 @@
expectAsset("app|foo.txt", "bar.in");
buildShouldSucceed();
});
-}
\ No newline at end of file
+}
diff --git a/packages/barback/test/package_graph/transform/transform_test.dart b/packages/barback/test/package_graph/transform/transform_test.dart
index 17af1ef..e6f3dea 100644
--- a/packages/barback/test/package_graph/transform/transform_test.dart
+++ b/packages/barback/test/package_graph/transform/transform_test.dart
@@ -6,7 +6,6 @@
// happening concurrently or other complex asynchronous timing behavior.
library barback.test.package_graph.transform.transform_test;
-import 'package:barback/src/utils.dart';
import 'package:scheduled_test/scheduled_test.dart';
import '../../utils.dart';
@@ -14,40 +13,53 @@
main() {
initConfig();
test("gets a transformed asset with a different path", () {
- initGraph(["app|foo.blub"], {"app": [
- [new RewriteTransformer("blub", "blab")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new RewriteTransformer("blub", "blab")]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blab", "foo.blab");
buildShouldSucceed();
});
test("gets a transformed asset with the same path", () {
- initGraph(["app|foo.blub"], {"app": [
- [new RewriteTransformer("blub", "blub")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new RewriteTransformer("blub", "blub")]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blub", "foo.blub");
buildShouldSucceed();
});
test("doesn't find an output from a later phase", () {
- initGraph(["app|foo.a"], {"app": [
- [new RewriteTransformer("b", "c")],
- [new RewriteTransformer("a", "b")]
- ]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [new RewriteTransformer("b", "c")],
+ [new RewriteTransformer("a", "b")]
+ ]
+ });
updateSources(["app|foo.a"]);
expectNoAsset("app|foo.c");
buildShouldSucceed();
});
test("doesn't find an output from the same phase", () {
- initGraph(["app|foo.a"], {"app": [
- [
- new RewriteTransformer("a", "b"),
- new RewriteTransformer("b", "c")
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [new RewriteTransformer("a", "b"), new RewriteTransformer("b", "c")]
]
- ]});
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.b", "foo.b");
expectNoAsset("app|foo.c");
@@ -55,32 +67,40 @@
});
test("finds the latest output before the transformer's phase", () {
- initGraph(["app|foo.blub"], {"app": [
- [new RewriteTransformer("blub", "blub")],
- [
- new RewriteTransformer("blub", "blub"),
- new RewriteTransformer("blub", "done")
- ],
- [new RewriteTransformer("blub", "blub")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new RewriteTransformer("blub", "blub")],
+ [
+ new RewriteTransformer("blub", "blub"),
+ new RewriteTransformer("blub", "done")
+ ],
+ [new RewriteTransformer("blub", "blub")]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.done", "foo.blub.done");
buildShouldSucceed();
});
test("applies multiple transformations to an asset", () {
- initGraph(["app|foo.a"], {"app": [
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("b", "c")],
- [new RewriteTransformer("c", "d")],
- [new RewriteTransformer("d", "e")],
- [new RewriteTransformer("e", "f")],
- [new RewriteTransformer("f", "g")],
- [new RewriteTransformer("g", "h")],
- [new RewriteTransformer("h", "i")],
- [new RewriteTransformer("i", "j")],
- [new RewriteTransformer("j", "k")],
- ]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("b", "c")],
+ [new RewriteTransformer("c", "d")],
+ [new RewriteTransformer("d", "e")],
+ [new RewriteTransformer("e", "f")],
+ [new RewriteTransformer("f", "g")],
+ [new RewriteTransformer("g", "h")],
+ [new RewriteTransformer("h", "i")],
+ [new RewriteTransformer("i", "j")],
+ [new RewriteTransformer("j", "k")],
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.k", "foo.b.c.d.e.f.g.h.i.j.k");
buildShouldSucceed();
@@ -88,7 +108,13 @@
test("only runs a transform once for all of its outputs", () {
var transformer = new RewriteTransformer("blub", "a b c");
- initGraph(["app|foo.blub"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.a", "foo.a");
expectAsset("app|foo.b", "foo.b");
@@ -98,10 +124,14 @@
});
test("outputs are passed through transformers by default", () {
- initGraph(["app|foo.a"], {"app": [
- [new RewriteTransformer("a", "b")],
- [new RewriteTransformer("a", "c")]
- ]});
+ initGraph([
+ "app|foo.a"
+ ], {
+ "app": [
+ [new RewriteTransformer("a", "b")],
+ [new RewriteTransformer("a", "c")]
+ ]
+ });
updateSources(["app|foo.a"]);
expectAsset("app|foo.a", "foo");
expectAsset("app|foo.b", "foo.b");
@@ -111,7 +141,13 @@
test("does not reapply transform when inputs are not modified", () {
var transformer = new RewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blab", "foo.blab");
expectAsset("app|foo.blab", "foo.blab");
@@ -123,7 +159,13 @@
test("reapplies a transform when its input is modified", () {
var transformer = new RewriteTransformer("blub", "blab");
- initGraph(["app|foo.blub"], {"app": [[transformer]]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blab", "foo.blab");
@@ -146,7 +188,11 @@
"app|a.txt": "a.inc,b.inc",
"app|a.inc": "a",
"app|b.inc": "b"
- }, {"app": [[transformer]]});
+ }, {
+ "app": [
+ [transformer]
+ ]
+ });
updateSources(["app|a.txt", "app|a.inc", "app|b.inc"]);
@@ -170,9 +216,13 @@
});
test("allows a transform to generate multiple outputs", () {
- initGraph({"app|foo.txt": "a.out,b.out"}, {"app": [
- [new OneToManyTransformer("txt")]
- ]});
+ initGraph({
+ "app|foo.txt": "a.out,b.out"
+ }, {
+ "app": [
+ [new OneToManyTransformer("txt")]
+ ]
+ });
updateSources(["app|foo.txt"]);
@@ -186,10 +236,15 @@
var aa = new RewriteTransformer("aa", "aaa");
var b = new RewriteTransformer("b", "bb");
var bb = new RewriteTransformer("bb", "bbb");
- initGraph(["app|foo.a", "app|foo.b"], {"app": [
- [a, b],
- [aa, bb],
- ]});
+ initGraph([
+ "app|foo.a",
+ "app|foo.b"
+ ], {
+ "app": [
+ [a, b],
+ [aa, bb],
+ ]
+ });
updateSources(["app|foo.a"]);
updateSources(["app|foo.b"]);
@@ -209,9 +264,13 @@
test("doesn't get an output from a transform whose primary input is removed",
() {
- initGraph(["app|foo.txt"], {"app": [
- [new RewriteTransformer("txt", "out")]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new RewriteTransformer("txt", "out")]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.out", "foo.out");
@@ -226,7 +285,11 @@
initGraph({
"app|a.txt": "a.inc",
"app|a.inc": "a"
- }, {"app": [[new ManyToOneTransformer("txt")]]});
+ }, {
+ "app": [
+ [new ManyToOneTransformer("txt")]
+ ]
+ });
updateSources(["app|a.txt", "app|a.inc"]);
expectAsset("app|a.out", "a");
@@ -242,7 +305,11 @@
test("applies a transform when it becomes newly primary", () {
initGraph({
"app|foo.txt": "this",
- }, {"app": [[new CheckContentTransformer("that", " and the other")]]});
+ }, {
+ "app": [
+ [new CheckContentTransformer("that", " and the other")]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.txt", "this");
@@ -260,9 +327,11 @@
initGraph({
"app|a.a": "a.out,shared.out",
"app|b.b": "b.out"
- }, {"app": [
- [new OneToManyTransformer("a"), new OneToManyTransformer("b")]
- ]});
+ }, {
+ "app": [
+ [new OneToManyTransformer("a"), new OneToManyTransformer("b")]
+ ]
+ });
updateSources(["app|a.a", "app|b.b"]);
@@ -289,7 +358,14 @@
initGraph([
"pkg1|foo.txt",
"pkg2|foo.txt"
- ], {"pkg1": [[rewrite1]], "pkg2": [[rewrite2]]});
+ ], {
+ "pkg1": [
+ [rewrite1]
+ ],
+ "pkg2": [
+ [rewrite2]
+ ]
+ });
updateSources(["pkg1|foo.txt", "pkg2|foo.txt"]);
expectAsset("pkg1|foo.out1", "foo.out1");
@@ -300,7 +376,16 @@
test("transforms don't see generated assets in other packages", () {
var fooToBar = new RewriteTransformer("foo", "bar");
var barToBaz = new RewriteTransformer("bar", "baz");
- initGraph(["pkg1|file.foo"], {"pkg1": [[fooToBar]], "pkg2": [[barToBaz]]});
+ initGraph([
+ "pkg1|file.foo"
+ ], {
+ "pkg1": [
+ [fooToBar]
+ ],
+ "pkg2": [
+ [barToBaz]
+ ]
+ });
updateSources(["pkg1|file.foo"]);
expectAsset("pkg1|file.bar", "file.bar");
@@ -310,10 +395,14 @@
test("removes pipelined transforms when the root primary input is removed",
() {
- initGraph(["app|foo.txt"], {"app": [
- [new RewriteTransformer("txt", "mid")],
- [new RewriteTransformer("mid", "out")]
- ]});
+ initGraph([
+ "app|foo.txt"
+ ], {
+ "app": [
+ [new RewriteTransformer("txt", "mid")],
+ [new RewriteTransformer("mid", "out")]
+ ]
+ });
updateSources(["app|foo.txt"]);
expectAsset("app|foo.out", "foo.mid.out");
@@ -324,12 +413,17 @@
buildShouldSucceed();
});
- test("removes pipelined transforms when the parent ceases to generate the "
+ test(
+ "removes pipelined transforms when the parent ceases to generate the "
"primary input", () {
- initGraph({"app|foo.txt": "foo.mid"}, {'app': [
- [new OneToManyTransformer('txt')],
- [new RewriteTransformer('mid', 'out')]
- ]});
+ initGraph({
+ "app|foo.txt": "foo.mid"
+ }, {
+ 'app': [
+ [new OneToManyTransformer('txt')],
+ [new RewriteTransformer('mid', 'out')]
+ ]
+ });
updateSources(['app|foo.txt']);
expectAsset('app|foo.out', 'spread txt.out');
@@ -343,9 +437,13 @@
});
test("gets an asset transformed by a sync transformer", () {
- initGraph(["app|foo.blub"], {"app": [
- [new SyncRewriteTransformer("blub", "blab")]
- ]});
+ initGraph([
+ "app|foo.blub"
+ ], {
+ "app": [
+ [new SyncRewriteTransformer("blub", "blab")]
+ ]
+ });
updateSources(["app|foo.blub"]);
expectAsset("app|foo.blab", "new.blab");
buildShouldSucceed();
@@ -353,9 +451,17 @@
group("Transform.hasInput", () {
test("returns whether an input exists", () {
- initGraph(["app|foo.txt", "app|bar.txt"], {'app': [
- [new HasInputTransformer(['app|foo.txt', 'app|bar.txt', 'app|baz.txt'])]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt"
+ ], {
+ 'app': [
+ [
+ new HasInputTransformer(
+ ['app|foo.txt', 'app|bar.txt', 'app|baz.txt'])
+ ]
+ ]
+ });
updateSources(['app|foo.txt', 'app|bar.txt']);
expectAsset('app|foo.txt',
@@ -364,9 +470,16 @@
});
test("re-runs the transformer when an input stops existing", () {
- initGraph(["app|foo.txt", "app|bar.txt"], {'app': [
- [new HasInputTransformer(['app|bar.txt'])]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt"
+ ], {
+ 'app': [
+ [
+ new HasInputTransformer(['app|bar.txt'])
+ ]
+ ]
+ });
updateSources(['app|foo.txt', 'app|bar.txt']);
expectAsset('app|foo.txt', 'app|bar.txt: true');
@@ -378,14 +491,21 @@
});
test("re-runs the transformer when an input starts existing", () {
- initGraph(["app|foo.txt", "app|bar.txt"], {'app': [
- [new HasInputTransformer(['app|bar.txt'])]
- ]});
-
+ initGraph([
+ "app|foo.txt",
+ "app|bar.txt"
+ ], {
+ 'app': [
+ [
+ new HasInputTransformer(['app|bar.txt'])
+ ]
+ ]
+ });
+
updateSources(['app|foo.txt']);
expectAsset('app|foo.txt', 'app|bar.txt: false');
buildShouldSucceed();
-
+
updateSources(['app|bar.txt']);
expectAsset('app|foo.txt', 'app|bar.txt: true');
buildShouldSucceed();
@@ -393,20 +513,33 @@
group("on an input in another package", () {
test("returns whether it exists", () {
- initGraph(["app|foo.txt", "other|bar.txt"], {'app': [
- [new HasInputTransformer(['other|bar.txt', 'other|baz.txt'])]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "other|bar.txt"
+ ], {
+ 'app': [
+ [
+ new HasInputTransformer(['other|bar.txt', 'other|baz.txt'])
+ ]
+ ]
+ });
updateSources(['app|foo.txt', 'other|bar.txt']);
- expectAsset('app|foo.txt',
- 'other|bar.txt: true, other|baz.txt: false');
+ expectAsset('app|foo.txt', 'other|bar.txt: true, other|baz.txt: false');
buildShouldSucceed();
});
test("re-runs the transformer when it stops existing", () {
- initGraph(["app|foo.txt", "other|bar.txt"], {'app': [
- [new HasInputTransformer(['other|bar.txt'])]
- ]});
+ initGraph([
+ "app|foo.txt",
+ "other|bar.txt"
+ ], {
+ 'app': [
+ [
+ new HasInputTransformer(['other|bar.txt'])
+ ]
+ ]
+ });
updateSources(['app|foo.txt', 'other|bar.txt']);
expectAsset('app|foo.txt', 'other|bar.txt: true');
@@ -418,14 +551,21 @@
});
test("re-runs the transformer when it starts existing", () {
- initGraph(["app|foo.txt", "other|bar.txt"], {'app': [
- [new HasInputTransformer(['other|bar.txt'])]
- ]});
-
+ initGraph([
+ "app|foo.txt",
+ "other|bar.txt"
+ ], {
+ 'app': [
+ [
+ new HasInputTransformer(['other|bar.txt'])
+ ]
+ ]
+ });
+
updateSources(['app|foo.txt']);
expectAsset('app|foo.txt', 'other|bar.txt: false');
buildShouldSucceed();
-
+
updateSources(['other|bar.txt']);
expectAsset('app|foo.txt', 'other|bar.txt: true');
buildShouldSucceed();
diff --git a/packages/barback/test/static_provider_test.dart b/packages/barback/test/static_provider_test.dart
index 4bd44f9..7efeb37 100644
--- a/packages/barback/test/static_provider_test.dart
+++ b/packages/barback/test/static_provider_test.dart
@@ -25,8 +25,12 @@
initStaticGraph({
"static|b.inc": "b",
"app|a.txt": "static|b.inc"
- }, staticPackages: ["static"], transformers: {
- "app": [[new ManyToOneTransformer("txt")]]
+ }, staticPackages: [
+ "static"
+ ], transformers: {
+ "app": [
+ [new ManyToOneTransformer("txt")]
+ ]
});
updateSources(["app|a.txt"]);
expectAsset("app|a.out", "b");
diff --git a/packages/barback/test/stream_pool_test.dart b/packages/barback/test/stream_pool_test.dart
index ed590f3..b7f4bf9 100644
--- a/packages/barback/test/stream_pool_test.dart
+++ b/packages/barback/test/stream_pool_test.dart
@@ -50,18 +50,21 @@
controller1.add("fifth");
expect(newFuture(() {
- return pool.stream.transform(new StreamTransformer.fromHandlers(
- handleData: (data, sink) => sink.add(["data", data]),
- handleError: (error, stackTrace, sink) {
- sink.add(["error", error]);
- })).toList();
- }), completion(equals([
- ["data", "first"],
- ["data", "second"],
- ["error", "third"],
- ["error", "fourth"],
- ["data", "fifth"]
- ])));
+ return pool.stream
+ .transform(new StreamTransformer.fromHandlers(
+ handleData: (data, sink) => sink.add(["data", data]),
+ handleError: (error, stackTrace, sink) {
+ sink.add(["error", error]);
+ }))
+ .toList();
+ }),
+ completion(equals([
+ ["data", "first"],
+ ["data", "second"],
+ ["error", "third"],
+ ["error", "fourth"],
+ ["data", "fifth"]
+ ])));
pumpEventQueue().then((_) => pool.close());
});
@@ -113,9 +116,12 @@
controller2.addError("second");
expect(newFuture(() {
- return pool.stream.transform(new StreamTransformer.fromHandlers(
- handleData: (data, sink) => sink.add(data),
- handleError: (error, stackTrace, sink) { sink.add(error); }))
+ return pool.stream
+ .transform(new StreamTransformer.fromHandlers(
+ handleData: (data, sink) => sink.add(data),
+ handleError: (error, stackTrace, sink) {
+ sink.add(error);
+ }))
.toList();
}), completion(isEmpty));
@@ -140,10 +146,8 @@
group(type, () {
var pool;
var bufferedController;
- var bufferedStream;
var bufferedSyncController;
var broadcastController;
- var broadcastStream;
var broadcastSyncController;
setUp(() {
@@ -163,7 +167,7 @@
pool.add(broadcastController.stream);
broadcastSyncController =
- new StreamController<String>.broadcast(sync: true);
+ new StreamController<String>.broadcast(sync: true);
pool.add(broadcastSyncController.stream);
});
@@ -202,17 +206,19 @@
expect(pool.stream.toList(), completion(equals(["first", "third"])));
bufferedController.add("first");
- expect(pumpEventQueue().then((_) {
- pool.remove(bufferedController.stream);
- bufferedController.add("second");
- }).then((_) {
- broadcastController.add("third");
- return pumpEventQueue();
- }).then((_) {
- pool.remove(broadcastController.stream);
- broadcastController.add("fourth");
- pool.close();
- }), completes);
+ expect(
+ pumpEventQueue().then((_) {
+ pool.remove(bufferedController.stream);
+ bufferedController.add("second");
+ }).then((_) {
+ broadcastController.add("third");
+ return pumpEventQueue();
+ }).then((_) {
+ pool.remove(broadcastController.stream);
+ broadcastController.add("fourth");
+ pool.close();
+ }),
+ completes);
});
});
}
diff --git a/packages/barback/test/stream_replayer_test.dart b/packages/barback/test/stream_replayer_test.dart
index 802db14..a0b6f1a 100644
--- a/packages/barback/test/stream_replayer_test.dart
+++ b/packages/barback/test/stream_replayer_test.dart
@@ -15,7 +15,8 @@
main() {
initConfig();
- test("a replay that's retrieved before the stream is finished replays the "
+ test(
+ "a replay that's retrieved before the stream is finished replays the "
"stream", () {
var controller = new StreamController<int>();
var replay = new StreamReplayer<int>(controller.stream).getReplay();
@@ -28,7 +29,8 @@
expect(replay.toList(), completion(equals([1, 2, 3])));
});
- test("a replay that's retrieved after the stream is finished replays the "
+ test(
+ "a replay that's retrieved after the stream is finished replays the "
"stream", () {
var controller = new StreamController<int>();
var replayer = new StreamReplayer<int>(controller.stream);
@@ -68,13 +70,15 @@
controller.add(2);
controller.add(3);
- expect(pumpEventQueue().then((_) {
- expect(isClosed, isFalse);
- controller.close();
- return pumpEventQueue();
- }).then((_) {
- expect(isClosed, isTrue);
- }), completes);
+ expect(
+ pumpEventQueue().then((_) {
+ expect(isClosed, isFalse);
+ controller.close();
+ return pumpEventQueue();
+ }).then((_) {
+ expect(isClosed, isTrue);
+ }),
+ completes);
});
test("the wrapped stream isn't opened if there are no replays", () {
@@ -82,7 +86,7 @@
var controller = new StreamController<int>(onListen: () {
isOpened = true;
});
- var replayer = new StreamReplayer<int>(controller.stream);
+ new StreamReplayer<int>(controller.stream);
expect(pumpEventQueue().then((_) => isOpened), completion(isFalse));
});
diff --git a/packages/barback/test/too_many_open_files_test.dart b/packages/barback/test/too_many_open_files_test.dart
index b45af71..0fca29a 100644
--- a/packages/barback/test/too_many_open_files_test.dart
+++ b/packages/barback/test/too_many_open_files_test.dart
@@ -43,13 +43,15 @@
// Create a large number of assets, larger than the file descriptor limit
// of most machines and start reading from all of them.
- var futures = [];
+ var futures = <Future>[];
for (var i = 0; i < 1000; i++) {
var asset = new Asset.fromPath(id, filePath);
futures.add(assetHandler(asset));
}
- expect(Future.wait(futures).whenComplete(() {
- new Directory(tempDir).delete(recursive: true);
- }), completes);
-}
\ No newline at end of file
+ expect(
+ Future.wait(futures).whenComplete(() {
+ new Directory(tempDir).delete(recursive: true);
+ }),
+ completes);
+}
diff --git a/packages/barback/test/transformer/aggregate_many_to_many.dart b/packages/barback/test/transformer/aggregate_many_to_many.dart
index 6e3c8a1..92b0e91 100644
--- a/packages/barback/test/transformer/aggregate_many_to_many.dart
+++ b/packages/barback/test/transformer/aggregate_many_to_many.dart
@@ -27,8 +27,8 @@
Future doApply(AggregateTransform transform) {
return getPrimaryInputs(transform).asyncMap((asset) {
return asset.readAsString().then((contents) {
- transform.addOutput(new Asset.fromString(
- asset.id, "modified $contents"));
+ transform
+ .addOutput(new Asset.fromString(asset.id, "modified $contents"));
});
}).toList();
}
diff --git a/packages/barback/test/transformer/aggregate_many_to_one.dart b/packages/barback/test/transformer/aggregate_many_to_one.dart
index af3bbaa..6586f59 100644
--- a/packages/barback/test/transformer/aggregate_many_to_one.dart
+++ b/packages/barback/test/transformer/aggregate_many_to_one.dart
@@ -35,10 +35,10 @@
Future doApply(AggregateTransform transform) async {
var assets = await getPrimaryInputs(transform).toList();
assets.sort((asset1, asset2) => asset1.id.path.compareTo(asset2.id.path));
- var contents = await Future.wait(
- assets.map((asset) => asset.readAsString()));
- var id = new AssetId(transform.package,
- path.url.join(transform.key, output));
+ var contents =
+ await Future.wait(assets.map((asset) => asset.readAsString()));
+ var id =
+ new AssetId(transform.package, path.url.join(transform.key, output));
transform.addOutput(new Asset.fromString(id, contents.join('\n')));
}
diff --git a/packages/barback/test/transformer/catch_asset_not_found.dart b/packages/barback/test/transformer/catch_asset_not_found.dart
index b43eeb7..8916b56 100644
--- a/packages/barback/test/transformer/catch_asset_not_found.dart
+++ b/packages/barback/test/transformer/catch_asset_not_found.dart
@@ -26,8 +26,8 @@
Future doApply(Transform transform) {
return transform.getInput(input).then((_) {
- transform.addOutput(new Asset.fromString(
- transform.primaryInput.id, "success"));
+ transform.addOutput(
+ new Asset.fromString(transform.primaryInput.id, "success"));
}).catchError((e) {
if (e is! AssetNotFoundException) throw e;
transform.addOutput(new Asset.fromString(
diff --git a/packages/barback/test/transformer/check_content.dart b/packages/barback/test/transformer/check_content.dart
index d9cecfa..5cadfc1 100644
--- a/packages/barback/test/transformer/check_content.dart
+++ b/packages/barback/test/transformer/check_content.dart
@@ -24,8 +24,8 @@
return primary.readAsString().then((value) {
if (!value.contains(content)) return;
- transform.addOutput(
- new Asset.fromString(primary.id, "$value$addition"));
+ transform
+ .addOutput(new Asset.fromString(primary.id, "$value$addition"));
});
});
}
diff --git a/packages/barback/test/transformer/check_content_and_rename.dart b/packages/barback/test/transformer/check_content_and_rename.dart
index dffad37..6ffc635 100644
--- a/packages/barback/test/transformer/check_content_and_rename.dart
+++ b/packages/barback/test/transformer/check_content_and_rename.dart
@@ -18,8 +18,11 @@
final String newExtension;
final String newContent;
- CheckContentAndRenameTransformer({this.oldExtension, this.oldContent,
- this.newExtension, this.newContent}) {
+ CheckContentAndRenameTransformer(
+ {this.oldExtension,
+ this.oldContent,
+ this.newExtension,
+ this.newContent}) {
assert(oldExtension != null);
assert(oldContent != null);
assert(newExtension != null);
diff --git a/packages/barback/test/transformer/create_asset.dart b/packages/barback/test/transformer/create_asset.dart
index 82e80b3..0f23fc4 100644
--- a/packages/barback/test/transformer/create_asset.dart
+++ b/packages/barback/test/transformer/create_asset.dart
@@ -17,7 +17,7 @@
bool doIsPrimary(AssetId id) => true;
void doApply(Transform transform) {
- transform.addOutput(
- new Asset.fromString(new AssetId.parse(output), output));
+ transform
+ .addOutput(new Asset.fromString(new AssetId.parse(output), output));
}
}
diff --git a/packages/barback/test/transformer/declare_assets.dart b/packages/barback/test/transformer/declare_assets.dart
index 03418ed..85c5810 100644
--- a/packages/barback/test/transformer/declare_assets.dart
+++ b/packages/barback/test/transformer/declare_assets.dart
@@ -22,11 +22,12 @@
/// If this is non-`null`, assets are only declared for this input.
final AssetId input;
- DeclareAssetsTransformer(Iterable<String> declared, {Iterable<String> emitted,
- String input})
+ DeclareAssetsTransformer(Iterable<String> declared,
+ {Iterable<String> emitted, String input})
: this.declared = declared.map((id) => new AssetId.parse(id)).toList(),
this.emitted = (emitted == null ? declared : emitted)
- .map((id) => new AssetId.parse(id)).toList(),
+ .map((id) => new AssetId.parse(id))
+ .toList(),
this.input = input == null ? null : new AssetId.parse(input);
bool doIsPrimary(AssetId id) => input == null || id == input;
diff --git a/packages/barback/test/transformer/declaring_aggregate_many_to_many.dart b/packages/barback/test/transformer/declaring_aggregate_many_to_many.dart
index 2377345..0917973 100644
--- a/packages/barback/test/transformer/declaring_aggregate_many_to_many.dart
+++ b/packages/barback/test/transformer/declaring_aggregate_many_to_many.dart
@@ -15,8 +15,7 @@
class DeclaringAggregateManyToManyTransformer
extends AggregateManyToManyTransformer
implements DeclaringAggregateTransformer {
- DeclaringAggregateManyToManyTransformer(String extension)
- : super(extension);
+ DeclaringAggregateManyToManyTransformer(String extension) : super(extension);
Future declareOutputs(DeclaringAggregateTransform transform) =>
transform.primaryIds.asyncMap(transform.declareOutput).toList();
diff --git a/packages/barback/test/transformer/declaring_aggregate_many_to_one.dart b/packages/barback/test/transformer/declaring_aggregate_many_to_one.dart
index 7f18741..bfdd750 100644
--- a/packages/barback/test/transformer/declaring_aggregate_many_to_one.dart
+++ b/packages/barback/test/transformer/declaring_aggregate_many_to_one.dart
@@ -17,7 +17,7 @@
: super(extension, output);
void declareOutputs(DeclaringAggregateTransform transform) {
- transform.declareOutput(new AssetId(transform.package,
- path.url.join(transform.key, output)));
+ transform.declareOutput(
+ new AssetId(transform.package, path.url.join(transform.key, output)));
}
}
diff --git a/packages/barback/test/transformer/declaring_bad.dart b/packages/barback/test/transformer/declaring_bad.dart
index 6643b0f..3d023aa 100644
--- a/packages/barback/test/transformer/declaring_bad.dart
+++ b/packages/barback/test/transformer/declaring_bad.dart
@@ -22,8 +22,8 @@
/// The id of the output asset to emit.
final AssetId output;
- DeclaringBadTransformer(String output, {bool declareError: true,
- bool applyError: false})
+ DeclaringBadTransformer(String output,
+ {bool declareError: true, bool applyError: false})
: this.output = new AssetId.parse(output),
this.declareError = declareError,
this.applyError = applyError;
diff --git a/packages/barback/test/transformer/declaring_check_content_and_rename.dart b/packages/barback/test/transformer/declaring_check_content_and_rename.dart
index 5783e67..988d53c 100644
--- a/packages/barback/test/transformer/declaring_check_content_and_rename.dart
+++ b/packages/barback/test/transformer/declaring_check_content_and_rename.dart
@@ -9,15 +9,20 @@
import 'check_content_and_rename.dart';
class DeclaringCheckContentAndRenameTransformer
- extends CheckContentAndRenameTransformer
- implements DeclaringTransformer {
- DeclaringCheckContentAndRenameTransformer({String oldExtension,
- String oldContent, String newExtension, String newContent})
- : super(oldExtension: oldExtension, oldContent: oldContent,
- newExtension: newExtension, newContent: newContent);
+ extends CheckContentAndRenameTransformer implements DeclaringTransformer {
+ DeclaringCheckContentAndRenameTransformer(
+ {String oldExtension,
+ String oldContent,
+ String newExtension,
+ String newContent})
+ : super(
+ oldExtension: oldExtension,
+ oldContent: oldContent,
+ newExtension: newExtension,
+ newContent: newContent);
void declareOutputs(DeclaringTransform transform) {
- transform.declareOutput(
- transform.primaryId.changeExtension('.$newExtension'));
+ transform
+ .declareOutput(transform.primaryId.changeExtension('.$newExtension'));
}
}
diff --git a/packages/barback/test/transformer/declaring_rewrite.dart b/packages/barback/test/transformer/declaring_rewrite.dart
index 8ab8a15..fc44bfe 100644
--- a/packages/barback/test/transformer/declaring_rewrite.dart
+++ b/packages/barback/test/transformer/declaring_rewrite.dart
@@ -11,8 +11,7 @@
/// Like [RewriteTransformer], but declares its assets ahead of time.
class DeclaringRewriteTransformer extends RewriteTransformer
implements DeclaringTransformer {
- DeclaringRewriteTransformer(String from, String to)
- : super(from, to);
+ DeclaringRewriteTransformer(String from, String to) : super(from, to);
void declareOutputs(DeclaringTransform transform) {
if (consumePrimary) transform.consumePrimary();
diff --git a/packages/barback/test/transformer/has_input.dart b/packages/barback/test/transformer/has_input.dart
index dfb89c5..bdf074c 100644
--- a/packages/barback/test/transformer/has_input.dart
+++ b/packages/barback/test/transformer/has_input.dart
@@ -25,8 +25,8 @@
return Future.wait(inputs.map((input) {
return transform.hasInput(input).then((hasInput) => "$input: $hasInput");
})).then((results) {
- transform.addOutput(new Asset.fromString(
- transform.primaryInput.id, results.join(', ')));
+ transform.addOutput(
+ new Asset.fromString(transform.primaryInput.id, results.join(', ')));
});
}
diff --git a/packages/barback/test/transformer/lazy_aggregate_many_to_many.dart b/packages/barback/test/transformer/lazy_aggregate_many_to_many.dart
index 6c010a4..8dfe2b8 100644
--- a/packages/barback/test/transformer/lazy_aggregate_many_to_many.dart
+++ b/packages/barback/test/transformer/lazy_aggregate_many_to_many.dart
@@ -13,6 +13,5 @@
class LazyAggregateManyToManyTransformer
extends DeclaringAggregateManyToManyTransformer
implements LazyAggregateTransformer {
- LazyAggregateManyToManyTransformer(String extension)
- : super(extension);
+ LazyAggregateManyToManyTransformer(String extension) : super(extension);
}
diff --git a/packages/barback/test/transformer/lazy_assets.dart b/packages/barback/test/transformer/lazy_assets.dart
index 5fa81d0..d57ccf2 100644
--- a/packages/barback/test/transformer/lazy_assets.dart
+++ b/packages/barback/test/transformer/lazy_assets.dart
@@ -11,7 +11,7 @@
/// Like [DeclareAssetsTransformer], but lazy.
class LazyAssetsTransformer extends DeclareAssetsTransformer
implements LazyTransformer {
- LazyAssetsTransformer(Iterable<String> declared, {Iterable<String> emitted,
- String input})
+ LazyAssetsTransformer(Iterable<String> declared,
+ {Iterable<String> emitted, String input})
: super(declared, emitted: emitted, input: input);
}
diff --git a/packages/barback/test/transformer/lazy_check_content_and_rename.dart b/packages/barback/test/transformer/lazy_check_content_and_rename.dart
index 30ba6c2..4b1757d 100644
--- a/packages/barback/test/transformer/lazy_check_content_and_rename.dart
+++ b/packages/barback/test/transformer/lazy_check_content_and_rename.dart
@@ -11,8 +11,14 @@
class LazyCheckContentAndRenameTransformer
extends DeclaringCheckContentAndRenameTransformer
implements LazyTransformer {
- LazyCheckContentAndRenameTransformer({String oldExtension,
- String oldContent, String newExtension, String newContent})
- : super(oldExtension: oldExtension, oldContent: oldContent,
- newExtension: newExtension, newContent: newContent);
+ LazyCheckContentAndRenameTransformer(
+ {String oldExtension,
+ String oldContent,
+ String newExtension,
+ String newContent})
+ : super(
+ oldExtension: oldExtension,
+ oldContent: oldContent,
+ newExtension: newExtension,
+ newContent: newContent);
}
diff --git a/packages/barback/test/transformer/lazy_many_to_one.dart b/packages/barback/test/transformer/lazy_many_to_one.dart
index ef407ef..1153c9d 100644
--- a/packages/barback/test/transformer/lazy_many_to_one.dart
+++ b/packages/barback/test/transformer/lazy_many_to_one.dart
@@ -12,8 +12,7 @@
/// the conglomeration until it's materialized.
class LazyManyToOneTransformer extends ManyToOneTransformer
implements LazyTransformer {
- LazyManyToOneTransformer(String extension)
- : super(extension);
+ LazyManyToOneTransformer(String extension) : super(extension);
void declareOutputs(DeclaringTransform transform) {
transform.declareOutput(transform.primaryId.changeExtension(".out"));
diff --git a/packages/barback/test/transformer/lazy_rewrite.dart b/packages/barback/test/transformer/lazy_rewrite.dart
index 63bffb6..35ce733 100644
--- a/packages/barback/test/transformer/lazy_rewrite.dart
+++ b/packages/barback/test/transformer/lazy_rewrite.dart
@@ -12,6 +12,5 @@
/// rewrite until it's materialized.
class LazyRewriteTransformer extends DeclaringRewriteTransformer
implements LazyTransformer {
- LazyRewriteTransformer(String from, String to)
- : super(from, to);
+ LazyRewriteTransformer(String from, String to) : super(from, to);
}
diff --git a/packages/barback/test/transformer/log.dart b/packages/barback/test/transformer/log.dart
index 4e3dd72..bfa8b93 100644
--- a/packages/barback/test/transformer/log.dart
+++ b/packages/barback/test/transformer/log.dart
@@ -4,10 +4,7 @@
library barback.test.transformer.log;
-import 'dart:async';
-
import 'package:barback/barback.dart';
-import 'package:barback/src/utils.dart';
import 'mock.dart';
@@ -29,10 +26,18 @@
var parts = entry.split(":");
var logFn;
switch (parts[0]) {
- case "error": logFn = transform.logger.error; break;
- case "warning": logFn = transform.logger.warning; break;
- case "info": logFn = transform.logger.info; break;
- case "fine": logFn = transform.logger.fine; break;
+ case "error":
+ logFn = transform.logger.error;
+ break;
+ case "warning":
+ logFn = transform.logger.warning;
+ break;
+ case "info":
+ logFn = transform.logger.info;
+ break;
+ case "fine":
+ logFn = transform.logger.fine;
+ break;
}
logFn(parts[1].trim());
diff --git a/packages/barback/test/transformer/mock.dart b/packages/barback/test/transformer/mock.dart
index 09c3628..b6120e2 100644
--- a/packages/barback/test/transformer/mock.dart
+++ b/packages/barback/test/transformer/mock.dart
@@ -49,7 +49,7 @@
///
/// Once this transformer finishes running, this is reset to a new completer,
/// so it can be used multiple times.
- var _started = new Completer();
+ var _started = new Completer<Null>();
/// `true` if any transforms are currently running.
///
diff --git a/packages/barback/test/transformer/mock_aggregate.dart b/packages/barback/test/transformer/mock_aggregate.dart
index 1b1fefd..b020637 100644
--- a/packages/barback/test/transformer/mock_aggregate.dart
+++ b/packages/barback/test/transformer/mock_aggregate.dart
@@ -51,7 +51,7 @@
///
/// Once this transformer finishes running, this is reset to a new completer,
/// so it can be used multiple times.
- var _started = new Completer();
+ var _started = new Completer<Null>();
/// `true` if any transforms are currently running.
///
diff --git a/packages/barback/test/transformer_test.dart b/packages/barback/test/transformer_test.dart
index 5ff96c8..119fc1e 100644
--- a/packages/barback/test/transformer_test.dart
+++ b/packages/barback/test/transformer_test.dart
@@ -7,7 +7,6 @@
import 'dart:async';
import 'package:barback/barback.dart';
-import 'package:barback/src/utils.dart';
import 'package:unittest/unittest.dart';
import 'utils.dart';
@@ -61,4 +60,4 @@
ExtensionTransformer(this.allowedExtensions);
Future apply(Transform transform) => new Future.value();
-}
\ No newline at end of file
+}
diff --git a/packages/barback/test/utils.dart b/packages/barback/test/utils.dart
index edfbf65..c69af30 100644
--- a/packages/barback/test/utils.dart
+++ b/packages/barback/test/utils.dart
@@ -83,19 +83,18 @@
///
/// [transformers] is a map from package names to the transformers for each
/// package.
-void initGraph([assets,
- Map<String, Iterable<Iterable<Transformer>>> transformers]) =>
+void initGraph([assets, Map<String, Iterable<Iterable>> transformers]) =>
initStaticGraph(assets, transformers: transformers);
-void initStaticGraph(assets, {Iterable<String> staticPackages,
+void initStaticGraph(assets,
+ {Iterable<String> staticPackages,
Map<String, Iterable<Iterable<Transformer>>> transformers}) {
if (assets == null) assets = [];
if (staticPackages == null) staticPackages = [];
if (transformers == null) transformers = {};
_provider = new MockProvider(assets,
- staticPackages: staticPackages,
- additionalPackages: transformers.keys);
+ staticPackages: staticPackages, additionalPackages: transformers.keys);
_barback = new Barback(_provider);
// Add a dummy listener to the log so it doesn't print to stdout.
_barback.log.listen((_) {});
@@ -115,8 +114,8 @@
/// parsed as one.
void updateSources(Iterable assets) {
var parsed = _parseAssets(assets);
- schedule(() => _barback.updateSources(parsed),
- "updating ${parsed.join(', ')}");
+ schedule(
+ () => _barback.updateSources(parsed), "updating ${parsed.join(', ')}");
}
/// Updates [assets] in the current [PackageProvider].
@@ -133,8 +132,8 @@
/// parsed as one.
void removeSources(Iterable assets) {
var parsed = _parseAssets(assets);
- schedule(() => _barback.removeSources(parsed),
- "removing ${parsed.join(', ')}");
+ schedule(
+ () => _barback.removeSources(parsed), "removing ${parsed.join(', ')}");
}
/// Removes [assets] from the current [PackageProvider].
@@ -201,20 +200,20 @@
/// [buildShouldFail], so those can be used to validate build results before and
/// after this.
void buildShouldNotBeDone() {
- _futureShouldNotCompleteUntil(
- _barback.results.elementAt(_nextBuildResult),
- schedule(() => pumpEventQueue(), "build should not terminate"),
- "build");
+ _futureShouldNotCompleteUntil(_barback.results.elementAt(_nextBuildResult),
+ schedule(() => pumpEventQueue(), "build should not terminate"), "build");
}
/// Expects that the next [BuildResult] is a build success.
void buildShouldSucceed() {
- expect(_getNextBuildResult("build should succeed").then((result) {
- for (var error in result.errors) {
- currentSchedule.signalError(error);
- }
- expect(result.succeeded, isTrue);
- }), completes);
+ expect(
+ _getNextBuildResult("build should succeed").then((result) {
+ for (var error in result.errors) {
+ currentSchedule.signalError(error);
+ }
+ expect(result.succeeded, isTrue);
+ }),
+ completes);
}
/// Expects that the next [BuildResult] emitted is a failure.
@@ -223,33 +222,36 @@
/// build to fail. Every matcher is expected to match an error, but the order of
/// matchers is unimportant.
void buildShouldFail(List matchers) {
- expect(_getNextBuildResult("build should fail").then((result) {
- expect(result.succeeded, isFalse);
- expect(result.errors.length, equals(matchers.length));
- for (var matcher in matchers) {
- expect(result.errors, contains(matcher));
- }
- }), completes);
+ expect(
+ _getNextBuildResult("build should fail").then((result) {
+ expect(result.succeeded, isFalse);
+ expect(result.errors.length, equals(matchers.length));
+ for (var matcher in matchers) {
+ expect(result.errors, contains(matcher));
+ }
+ }),
+ completes);
}
/// Expects that the nexted logged [LogEntry] matches [matcher] which may be
/// either a [Matcher] or a string to match a literal string.
void buildShouldLog(LogLevel level, matcher) {
- expect(_getNextLog("build should log").then((log) {
- expect(log.level, equals(level));
- expect(log.message, matcher);
- }), completes);
+ expect(
+ _getNextLog("build should log").then((log) {
+ expect(log.level, equals(level));
+ expect(log.message, matcher);
+ }),
+ completes);
}
Future<BuildResult> _getNextBuildResult(String description) {
- var result = currentSchedule.wrapFuture(
- _barback.results.elementAt(_nextBuildResult++));
+ var result = currentSchedule
+ .wrapFuture(_barback.results.elementAt(_nextBuildResult++));
return schedule(() => result, description);
}
Future<LogEntry> _getNextLog(String description) {
- var result = currentSchedule.wrapFuture(
- _barback.log.elementAt(_nextLog++));
+ var result = currentSchedule.wrapFuture(_barback.log.elementAt(_nextLog++));
return schedule(() => result, description);
}
@@ -350,9 +352,7 @@
schedule(() {
return _futureShouldNotCompleteUntil(
- _barback.getAssetById(id),
- pumpEventQueue(),
- "asset $id");
+ _barback.getAssetById(id), pumpEventQueue(), "asset $id");
}, "asset $id should not complete");
}
@@ -368,8 +368,8 @@
// Make sure its contained errors match the matchers.
for (var error in errors) {
- matchers.add(transform((error) => error.errors, contains(error),
- error.toString()));
+ matchers.add(
+ transform((error) => error.errors, contains(error), error.toString()));
}
return allOf(matchers);
@@ -378,32 +378,28 @@
/// Returns a matcher for an [AssetNotFoundException] with the given [id].
Matcher isAssetNotFoundException(String name) {
var id = new AssetId.parse(name);
- return allOf(
- new isInstanceOf<AssetNotFoundException>(),
+ return allOf(new isInstanceOf<AssetNotFoundException>(),
predicate((error) => error.id == id, 'id == $name'));
}
/// Returns a matcher for an [AssetCollisionException] with the given [id].
Matcher isAssetCollisionException(String name) {
var id = new AssetId.parse(name);
- return allOf(
- new isInstanceOf<AssetCollisionException>(),
+ return allOf(new isInstanceOf<AssetCollisionException>(),
predicate((error) => error.id == id, 'id == $name'));
}
/// Returns a matcher for a [MissingInputException] with the given [id].
Matcher isMissingInputException(String name) {
var id = new AssetId.parse(name);
- return allOf(
- new isInstanceOf<MissingInputException>(),
+ return allOf(new isInstanceOf<MissingInputException>(),
predicate((error) => error.id == id, 'id == $name'));
}
/// Returns a matcher for an [InvalidOutputException] with the given id.
Matcher isInvalidOutputException(String name) {
var id = new AssetId.parse(name);
- return allOf(
- new isInstanceOf<InvalidOutputException>(),
+ return allOf(new isInstanceOf<InvalidOutputException>(),
predicate((error) => error.id == id, 'id == $name'));
}
@@ -420,16 +416,14 @@
/// Returns a matcher for a [TransformerException] with a wrapped error that
/// matches [error].
Matcher isTransformerException(error) {
- return allOf(
- new isInstanceOf<TransformerException>(),
+ return allOf(new isInstanceOf<TransformerException>(),
transform((error) => error.error, wrapMatcher(error), 'error'));
}
/// Returns a matcher for a [MockLoadException] with the given [id].
Matcher isMockLoadException(String name) {
var id = new AssetId.parse(name);
- return allOf(
- new isInstanceOf<MockLoadException>(),
+ return allOf(new isInstanceOf<MockLoadException>(),
predicate((error) => error.id == id, 'id == $name'));
}
@@ -439,7 +433,7 @@
/// [description] should be a noun phrase that describes the relation of the
/// output of [transformation] to its input.
Matcher transform(transformation(value), matcher, String description) =>
- new _TransformMatcher(transformation, wrapMatcher(matcher), description);
+ new _TransformMatcher(transformation, wrapMatcher(matcher), description);
class _TransformMatcher extends Matcher {
final Function _transformation;
@@ -449,10 +443,10 @@
_TransformMatcher(this._transformation, this._matcher, this._description);
bool matches(item, Map matchState) =>
- _matcher.matches(_transformation(item), matchState);
+ _matcher.matches(_transformation(item), matchState);
Description describe(Description description) =>
- description.add(_description).add(' ').addDescriptionOf(_matcher);
+ description.add(_description).add(' ').addDescriptionOf(_matcher);
}
/// Asserts that [future] shouldn't complete until after [delay] completes.
@@ -461,8 +455,8 @@
/// error.
///
/// [description] should describe [future].
-Future _futureShouldNotCompleteUntil(Future future, Future delay,
- String description) {
+Future _futureShouldNotCompleteUntil(
+ Future future, Future delay, String description) {
var trace = new Trace.current();
var cancelable = new CancelableFuture(future);
cancelable.then((result) {
@@ -512,14 +506,14 @@
_pauseCompleter = null;
}
- MockProvider(assets, {Iterable<String> staticPackages,
- Iterable<String> additionalPackages})
- : staticPackages = staticPackages == null ? new Set() :
- staticPackages.toSet(),
+ MockProvider(assets,
+ {Iterable<String> staticPackages, Iterable<String> additionalPackages})
+ : staticPackages =
+ staticPackages == null ? new Set() : staticPackages.toSet(),
_assets = _normalizeAssets(assets, additionalPackages);
- static Map<String, AssetSet> _normalizeAssets(assets,
- Iterable<String> additionalPackages) {
+ static Map<String, AssetSet> _normalizeAssets(
+ assets, Iterable<String> additionalPackages) {
Iterable<Asset> assetList;
if (assets is Map) {
assetList = assets.keys.map((asset) {
@@ -534,8 +528,7 @@
});
}
- var assetMap = mapMapValues(
- groupBy(assetList, (asset) => asset.id.package),
+ var assetMap = mapMapValues(groupBy(assetList, (asset) => asset.id.package),
(_, assets) => new AssetSet.from(assets));
// Make sure that packages that have transformers but no assets are
diff --git a/packages/charcode/lib/charcode.dart b/packages/charcode/lib/charcode.dart
index 6a702d7..67f30b3 100644
--- a/packages/charcode/lib/charcode.dart
+++ b/packages/charcode/lib/charcode.dart
@@ -14,4 +14,4 @@
library charcode;
export "ascii.dart";
-export "html_entity.dart" hide $minus, $tilde, $sub;
+export "html_entity4.dart" hide $minus, $tilde, $sub;
diff --git a/packages/charcode/lib/html_entity.dart b/packages/charcode/lib/html_entity.dart
deleted file mode 100644
index fa7c493..0000000
--- a/packages/charcode/lib/html_entity.dart
+++ /dev/null
@@ -1,769 +0,0 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-/// Character codes based on HTML 4.01 character entity names.
-///
-/// For each entity name, e.g., `nbsp`,
-/// a constant with that name prefixed by `$` is defined
-/// for that entity's code point.
-///
-/// The HTML entities include the non-ASCII Latin-1 characters and
-/// symbols, mathematical symbols and Greek litters.
-///
-/// The five characters that are ASCII
-/// are exported from the `ascii.dart` library.
-///
-/// Three names conflict with `ascii.dart`: `$minus`, `$sub` and `$tilde`.
-/// If importing both libraries, these three should be hidden from one of the
-/// libraries.
-library charcode.htmlentity.dollar_lowercase;
-
-export "ascii.dart" show $quot, $amp, $apos, $lt, $gt;
-
-/// no-break space (non-breaking space)
-const int $nbsp = 0x00A0;
-
-/// inverted exclamation mark ('¡')
-const int $iexcl = 0x00A1;
-
-/// cent sign ('¢')
-const int $cent = 0x00A2;
-
-/// pound sign ('£')
-const int $pound = 0x00A3;
-
-/// currency sign ('¤')
-const int $curren = 0x00A4;
-
-/// yen sign (yuan sign) ('¥')
-const int $yen = 0x00A5;
-
-/// broken bar (broken vertical bar) ('¦')
-const int $brvbar = 0x00A6;
-
-/// section sign ('§')
-const int $sect = 0x00A7;
-
-/// diaeresis (spacing diaeresis); see Germanic umlaut ('¨')
-const int $uml = 0x00A8;
-
-/// copyright symbol ('©')
-const int $copy = 0x00A9;
-
-/// feminine ordinal indicator ('ª')
-const int $ordf = 0x00AA;
-
-/// left-pointing double angle quotation mark (left pointing guillemet) ('«')
-const int $laquo = 0x00AB;
-
-/// not sign ('¬')
-const int $not = 0x00AC;
-
-/// soft hyphen (discretionary hyphen)
-const int $shy = 0x00AD;
-
-/// registered sign (registered trademark symbol) ('®')
-const int $reg = 0x00AE;
-
-/// macron (spacing macron, overline, APL overbar) ('¯')
-const int $macr = 0x00AF;
-
-/// degree symbol ('°')
-const int $deg = 0x00B0;
-
-/// plus-minus sign (plus-or-minus sign) ('±')
-const int $plusmn = 0x00B1;
-
-/// superscript two (superscript digit two, squared) ('²')
-const int $sup2 = 0x00B2;
-
-/// superscript three (superscript digit three, cubed) ('³')
-const int $sup3 = 0x00B3;
-
-/// acute accent (spacing acute) ('´')
-const int $acute = 0x00B4;
-
-/// micro sign ('µ')
-const int $micro = 0x00B5;
-
-/// pilcrow sign (paragraph sign) ('¶')
-const int $para = 0x00B6;
-
-/// middle dot (Georgian comma, Greek middle dot) ('·')
-const int $middot = 0x00B7;
-
-/// cedilla (spacing cedilla) ('¸')
-const int $cedil = 0x00B8;
-
-/// superscript one (superscript digit one) ('¹')
-const int $sup1 = 0x00B9;
-
-/// masculine ordinal indicator ('º')
-const int $ordm = 0x00BA;
-
-/// right-pointing double angle quotation mark (right pointing guillemet) ('»')
-const int $raquo = 0x00BB;
-
-/// vulgar fraction one quarter (fraction one quarter) ('¼')
-const int $frac14 = 0x00BC;
-
-/// vulgar fraction one half (fraction one half) ('½')
-const int $frac12 = 0x00BD;
-
-/// vulgar fraction three quarters (fraction three quarters) ('¾')
-const int $frac34 = 0x00BE;
-
-/// inverted question mark (turned question mark) ('¿')
-const int $iquest = 0x00BF;
-
-/// Latin capital letter A with grave accent (Latin capital letter A grave) ('À')
-const int $Agrave = 0x00C0;
-
-/// Latin capital letter A with acute accent ('Á')
-const int $Aacute = 0x00C1;
-
-/// Latin capital letter A with circumflex ('Â')
-const int $Acirc = 0x00C2;
-
-/// Latin capital letter A with tilde ('Ã')
-const int $Atilde = 0x00C3;
-
-/// Latin capital letter A with diaeresis ('Ä')
-const int $Auml = 0x00C4;
-
-/// Latin capital letter A with ring above (Latin capital letter A ring) ('Å')
-const int $Aring = 0x00C5;
-
-/// Latin capital letter AE (Latin capital ligature AE) ('Æ')
-const int $AElig = 0x00C6;
-
-/// Latin capital letter C with cedilla ('Ç')
-const int $Ccedil = 0x00C7;
-
-/// Latin capital letter E with grave accent ('È')
-const int $Egrave = 0x00C8;
-
-/// Latin capital letter E with acute accent ('É')
-const int $Eacute = 0x00C9;
-
-/// Latin capital letter E with circumflex ('Ê')
-const int $Ecirc = 0x00CA;
-
-/// Latin capital letter E with diaeresis ('Ë')
-const int $Euml = 0x00CB;
-
-/// Latin capital letter I with grave accent ('Ì')
-const int $Igrave = 0x00CC;
-
-/// Latin capital letter I with acute accent ('Í')
-const int $Iacute = 0x00CD;
-
-/// Latin capital letter I with circumflex ('Î')
-const int $Icirc = 0x00CE;
-
-/// Latin capital letter I with diaeresis ('Ï')
-const int $Iuml = 0x00CF;
-
-/// Latin capital letter Eth ('Ð')
-const int $ETH = 0x00D0;
-
-/// Latin capital letter N with tilde ('Ñ')
-const int $Ntilde = 0x00D1;
-
-/// Latin capital letter O with grave accent ('Ò')
-const int $Ograve = 0x00D2;
-
-/// Latin capital letter O with acute accent ('Ó')
-const int $Oacute = 0x00D3;
-
-/// Latin capital letter O with circumflex ('Ô')
-const int $Ocirc = 0x00D4;
-
-/// Latin capital letter O with tilde ('Õ')
-const int $Otilde = 0x00D5;
-
-/// Latin capital letter O with diaeresis ('Ö')
-const int $Ouml = 0x00D6;
-
-/// multiplication sign ('×')
-const int $times = 0x00D7;
-
-/// Latin capital letter O with stroke (Latin capital letter O slash) ('Ø')
-const int $Oslash = 0x00D8;
-
-/// Latin capital letter U with grave accent ('Ù')
-const int $Ugrave = 0x00D9;
-
-/// Latin capital letter U with acute accent ('Ú')
-const int $Uacute = 0x00DA;
-
-/// Latin capital letter U with circumflex ('Û')
-const int $Ucirc = 0x00DB;
-
-/// Latin capital letter U with diaeresis ('Ü')
-const int $Uuml = 0x00DC;
-
-/// Latin capital letter Y with acute accent ('Ý')
-const int $Yacute = 0x00DD;
-
-/// Latin capital letter THORN ('Þ')
-const int $THORN = 0x00DE;
-
-/// Latin small letter sharp s (ess-zed); see German Eszett ('ß')
-const int $szlig = 0x00DF;
-
-/// Latin small letter a with grave accent ('à')
-const int $agrave = 0x00E0;
-
-/// Latin small letter a with acute accent ('á')
-const int $aacute = 0x00E1;
-
-/// Latin small letter a with circumflex ('â')
-const int $acirc = 0x00E2;
-
-/// Latin small letter a with tilde ('ã')
-const int $atilde = 0x00E3;
-
-/// Latin small letter a with diaeresis ('ä')
-const int $auml = 0x00E4;
-
-/// Latin small letter a with ring above ('å')
-const int $aring = 0x00E5;
-
-/// Latin small letter ae (Latin small ligature ae) ('æ')
-const int $aelig = 0x00E6;
-
-/// Latin small letter c with cedilla ('ç')
-const int $ccedil = 0x00E7;
-
-/// Latin small letter e with grave accent ('è')
-const int $egrave = 0x00E8;
-
-/// Latin small letter e with acute accent ('é')
-const int $eacute = 0x00E9;
-
-/// Latin small letter e with circumflex ('ê')
-const int $ecirc = 0x00EA;
-
-/// Latin small letter e with diaeresis ('ë')
-const int $euml = 0x00EB;
-
-/// Latin small letter i with grave accent ('ì')
-const int $igrave = 0x00EC;
-
-/// Latin small letter i with acute accent ('í')
-const int $iacute = 0x00ED;
-
-/// Latin small letter i with circumflex ('î')
-const int $icirc = 0x00EE;
-
-/// Latin small letter i with diaeresis ('ï')
-const int $iuml = 0x00EF;
-
-/// Latin small letter eth ('ð')
-const int $eth = 0x00F0;
-
-/// Latin small letter n with tilde ('ñ')
-const int $ntilde = 0x00F1;
-
-/// Latin small letter o with grave accent ('ò')
-const int $ograve = 0x00F2;
-
-/// Latin small letter o with acute accent ('ó')
-const int $oacute = 0x00F3;
-
-/// Latin small letter o with circumflex ('ô')
-const int $ocirc = 0x00F4;
-
-/// Latin small letter o with tilde ('õ')
-const int $otilde = 0x00F5;
-
-/// Latin small letter o with diaeresis ('ö')
-const int $ouml = 0x00F6;
-
-/// division sign (obelus) ('÷')
-const int $divide = 0x00F7;
-
-/// Latin small letter o with stroke (Latin small letter o slash) ('ø')
-const int $oslash = 0x00F8;
-
-/// Latin small letter u with grave accent ('ù')
-const int $ugrave = 0x00F9;
-
-/// Latin small letter u with acute accent ('ú')
-const int $uacute = 0x00FA;
-
-/// Latin small letter u with circumflex ('û')
-const int $ucirc = 0x00FB;
-
-/// Latin small letter u with diaeresis ('ü')
-const int $uuml = 0x00FC;
-
-/// Latin small letter y with acute accent ('ý')
-const int $yacute = 0x00FD;
-
-/// Latin small letter thorn ('þ')
-const int $thorn = 0x00FE;
-
-/// Latin small letter y with diaeresis ('ÿ')
-const int $yuml = 0x00FF;
-
-/// Latin capital ligature oe ('Œ')
-const int $OElig = 0x0152;
-
-/// Latin small ligature oe ('œ')
-const int $oelig = 0x0153;
-
-/// Latin capital letter s with caron ('Š')
-const int $Scaron = 0x0160;
-
-/// Latin small letter s with caron ('š')
-const int $scaron = 0x0161;
-
-/// Latin capital letter y with diaeresis ('Ÿ')
-const int $Yuml = 0x0178;
-
-/// Latin small letter f with hook (function, florin) ('ƒ')
-const int $fnof = 0x0192;
-
-/// modifier letter circumflex accent ('ˆ')
-const int $circ = 0x02C6;
-
-/// small tilde ('˜')
-const int $tilde = 0x02DC;
-
-/// Greek capital letter Alpha ('Α')
-const int $Alpha = 0x0391;
-
-/// Greek capital letter Beta ('Β')
-const int $Beta = 0x0392;
-
-/// Greek capital letter Gamma ('Γ')
-const int $Gamma = 0x0393;
-
-/// Greek capital letter Delta ('Δ')
-const int $Delta = 0x0394;
-
-/// Greek capital letter Epsilon ('Ε')
-const int $Epsilon = 0x0395;
-
-/// Greek capital letter Zeta ('Ζ')
-const int $Zeta = 0x0396;
-
-/// Greek capital letter Eta ('Η')
-const int $Eta = 0x0397;
-
-/// Greek capital letter Theta ('Θ')
-const int $Theta = 0x0398;
-
-/// Greek capital letter Iota ('Ι')
-const int $Iota = 0x0399;
-
-/// Greek capital letter Kappa ('Κ')
-const int $Kappa = 0x039A;
-
-/// Greek capital letter Lambda ('Λ')
-const int $Lambda = 0x039B;
-
-/// Greek capital letter Mu ('Μ')
-const int $Mu = 0x039C;
-
-/// Greek capital letter Nu ('Ν')
-const int $Nu = 0x039D;
-
-/// Greek capital letter Xi ('Ξ')
-const int $Xi = 0x039E;
-
-/// Greek capital letter Omicron ('Ο')
-const int $Omicron = 0x039F;
-
-/// Greek capital letter Pi ('Π')
-const int $Pi = 0x03A0;
-
-/// Greek capital letter Rho ('Ρ')
-const int $Rho = 0x03A1;
-
-/// Greek capital letter Sigma ('Σ')
-const int $Sigma = 0x03A3;
-
-/// Greek capital letter Tau ('Τ')
-const int $Tau = 0x03A4;
-
-/// Greek capital letter Upsilon ('Υ')
-const int $Upsilon = 0x03A5;
-
-/// Greek capital letter Phi ('Φ')
-const int $Phi = 0x03A6;
-
-/// Greek capital letter Chi ('Χ')
-const int $Chi = 0x03A7;
-
-/// Greek capital letter Psi ('Ψ')
-const int $Psi = 0x03A8;
-
-/// Greek capital letter Omega ('Ω')
-const int $Omega = 0x03A9;
-
-/// Greek small letter alpha ('α')
-const int $alpha = 0x03B1;
-
-/// Greek small letter beta ('β')
-const int $beta = 0x03B2;
-
-/// Greek small letter gamma ('γ')
-const int $gamma = 0x03B3;
-
-/// Greek small letter delta ('δ')
-const int $delta = 0x03B4;
-
-/// Greek small letter epsilon ('ε')
-const int $epsilon = 0x03B5;
-
-/// Greek small letter zeta ('ζ')
-const int $zeta = 0x03B6;
-
-/// Greek small letter eta ('η')
-const int $eta = 0x03B7;
-
-/// Greek small letter theta ('θ')
-const int $theta = 0x03B8;
-
-/// Greek small letter iota ('ι')
-const int $iota = 0x03B9;
-
-/// Greek small letter kappa ('κ')
-const int $kappa = 0x03BA;
-
-/// Greek small letter lambda ('λ')
-const int $lambda = 0x03BB;
-
-/// Greek small letter mu ('μ')
-const int $mu = 0x03BC;
-
-/// Greek small letter nu ('ν')
-const int $nu = 0x03BD;
-
-/// Greek small letter xi ('ξ')
-const int $xi = 0x03BE;
-
-/// Greek small letter omicron ('ο')
-const int $omicron = 0x03BF;
-
-/// Greek small letter pi ('π')
-const int $pi = 0x03C0;
-
-/// Greek small letter rho ('ρ')
-const int $rho = 0x03C1;
-
-/// Greek small letter final sigma ('ς')
-const int $sigmaf = 0x03C2;
-
-/// Greek small letter sigma ('σ')
-const int $sigma = 0x03C3;
-
-/// Greek small letter tau ('τ')
-const int $tau = 0x03C4;
-
-/// Greek small letter upsilon ('υ')
-const int $upsilon = 0x03C5;
-
-/// Greek small letter phi ('φ')
-const int $phi = 0x03C6;
-
-/// Greek small letter chi ('χ')
-const int $chi = 0x03C7;
-
-/// Greek small letter psi ('ψ')
-const int $psi = 0x03C8;
-
-/// Greek small letter omega ('ω')
-const int $omega = 0x03C9;
-
-/// Greek theta symbol ('ϑ')
-const int $thetasym = 0x03D1;
-
-/// Greek Upsilon with hook symbol ('ϒ')
-const int $upsih = 0x03D2;
-
-/// Greek pi symbol ('ϖ')
-const int $piv = 0x03D6;
-
-/// en space
-const int $ensp = 0x2002;
-
-/// em space
-const int $emsp = 0x2003;
-
-/// thin space
-const int $thinsp = 0x2009;
-
-/// zero-width non-joiner
-const int $zwnj = 0x200C;
-
-/// zero-width joiner
-const int $zwj = 0x200D;
-
-/// left-to-right mark
-const int $lrm = 0x200E;
-
-/// right-to-left mark
-const int $rlm = 0x200F;
-
-/// en dash ('–')
-const int $ndash = 0x2013;
-
-/// em dash ('—')
-const int $mdash = 0x2014;
-
-/// left single quotation mark ('‘')
-const int $lsquo = 0x2018;
-
-/// right single quotation mark ('’')
-const int $rsquo = 0x2019;
-
-/// single low-9 quotation mark ('‚')
-const int $sbquo = 0x201A;
-
-/// left double quotation mark ('“')
-const int $ldquo = 0x201C;
-
-/// right double quotation mark ('”')
-const int $rdquo = 0x201D;
-
-/// double low-9 quotation mark ('„')
-const int $bdquo = 0x201E;
-
-/// dagger, obelisk ('†')
-const int $dagger = 0x2020;
-
-/// double dagger, double obelisk ('‡')
-const int $Dagger = 0x2021;
-
-/// bullet (black small circle) ('•')
-const int $bull = 0x2022;
-
-/// horizontal ellipsis (three dot leader) ('…')
-const int $hellip = 0x2026;
-
-/// per mille sign ('‰')
-const int $permil = 0x2030;
-
-/// prime (minutes, feet) ('′')
-const int $prime = 0x2032;
-
-/// double prime (seconds, inches) ('″')
-const int $Prime = 0x2033;
-
-/// single left-pointing angle quotation mark ('‹')
-const int $lsaquo = 0x2039;
-
-/// single right-pointing angle quotation mark ('›')
-const int $rsaquo = 0x203A;
-
-/// overline (spacing overscore) ('‾')
-const int $oline = 0x203E;
-
-/// fraction slash (solidus) ('⁄')
-const int $frasl = 0x2044;
-
-/// euro sign ('€')
-const int $euro = 0x20AC;
-
-/// black-letter capital I (imaginary part) ('ℑ')
-const int $image = 0x2111;
-
-/// script capital P (power set, Weierstrass p) ('℘')
-const int $weierp = 0x2118;
-
-/// black-letter capital R (real part symbol) ('ℜ')
-const int $real = 0x211C;
-
-/// trademark symbol ('™')
-const int $trade = 0x2122;
-
-/// alef symbol (first transfinite cardinal) ('ℵ')
-const int $alefsym = 0x2135;
-
-/// leftwards arrow ('←')
-const int $larr = 0x2190;
-
-/// upwards arrow ('↑')
-const int $uarr = 0x2191;
-
-/// rightwards arrow ('→')
-const int $rarr = 0x2192;
-
-/// downwards arrow ('↓')
-const int $darr = 0x2193;
-
-/// left right arrow ('↔')
-const int $harr = 0x2194;
-
-/// downwards arrow with corner leftwards (carriage return) ('↵')
-const int $crarr = 0x21B5;
-
-/// leftwards double arrow ('⇐')
-const int $lArr = 0x21D0;
-
-/// upwards double arrow ('⇑')
-const int $uArr = 0x21D1;
-
-/// rightwards double arrow ('⇒')
-const int $rArr = 0x21D2;
-
-/// downwards double arrow ('⇓')
-const int $dArr = 0x21D3;
-
-/// left right double arrow ('⇔')
-const int $hArr = 0x21D4;
-
-/// for all ('∀')
-const int $forall = 0x2200;
-
-/// partial differential ('∂')
-const int $part = 0x2202;
-
-/// there exists ('∃')
-const int $exist = 0x2203;
-
-/// empty set (null set); see also U+8960, ⌀ ('∅')
-const int $empty = 0x2205;
-
-/// del or nabla (vector differential operator) ('∇')
-const int $nabla = 0x2207;
-
-/// element of ('∈')
-const int $isin = 0x2208;
-
-/// not an element of ('∉')
-const int $notin = 0x2209;
-
-/// contains as member ('∋')
-const int $ni = 0x220B;
-
-/// n-ary product (product sign) ('∏')
-const int $prod = 0x220F;
-
-/// n-ary summation ('∑')
-const int $sum = 0x2211;
-
-/// minus sign ('−')
-const int $minus = 0x2212;
-
-/// asterisk operator ('∗')
-const int $lowast = 0x2217;
-
-/// square root (radical sign) ('√')
-const int $radic = 0x221A;
-
-/// proportional to ('∝')
-const int $prop = 0x221D;
-
-/// infinity ('∞')
-const int $infin = 0x221E;
-
-/// angle ('∠')
-const int $ang = 0x2220;
-
-/// logical and (wedge) ('∧')
-const int $and = 0x2227;
-
-/// logical or (vee) ('∨')
-const int $or = 0x2228;
-
-/// intersection (cap) ('∩')
-const int $cap = 0x2229;
-
-/// union (cup) ('∪')
-const int $cup = 0x222A;
-
-/// integral ('∫')
-const int $int = 0x222B;
-
-/// therefore sign ('∴')
-const int $there4 = 0x2234;
-
-/// tilde operator (varies with, similar to) ('∼')
-const int $sim = 0x223C;
-
-/// congruent to ('≅')
-const int $cong = 0x2245;
-
-/// almost equal to (asymptotic to) ('≈')
-const int $asymp = 0x2248;
-
-/// not equal to ('≠')
-const int $ne = 0x2260;
-
-/// identical to; sometimes used for 'equivalent to' ('≡')
-const int $equiv = 0x2261;
-
-/// less-than or equal to ('≤')
-const int $le = 0x2264;
-
-/// greater-than or equal to ('≥')
-const int $ge = 0x2265;
-
-/// subset of ('⊂')
-const int $sub = 0x2282;
-
-/// superset of ('⊃')
-const int $sup = 0x2283;
-
-/// not a subset of ('⊄')
-const int $nsub = 0x2284;
-
-/// subset of or equal to ('⊆')
-const int $sube = 0x2286;
-
-/// superset of or equal to ('⊇')
-const int $supe = 0x2287;
-
-/// circled plus (direct sum) ('⊕')
-const int $oplus = 0x2295;
-
-/// circled times (vector product) ('⊗')
-const int $otimes = 0x2297;
-
-/// up tack (orthogonal to, perpendicular) ('⊥')
-const int $perp = 0x22A5;
-
-/// dot operator ('⋅')
-const int $sdot = 0x22C5;
-
-/// vertical ellipsis ('â‹®')
-const int $vellip = 0x22EE;
-
-/// left ceiling (APL upstile) ('⌈')
-const int $lceil = 0x2308;
-
-/// right ceiling ('⌉')
-const int $rceil = 0x2309;
-
-/// left floor (APL downstile) ('⌊')
-const int $lfloor = 0x230A;
-
-/// right floor ('⌋')
-const int $rfloor = 0x230B;
-
-/// left-pointing angle bracket (bra) ('〈')
-const int $lang = 0x2329;
-
-/// right-pointing angle bracket (ket) ('〉')
-const int $rang = 0x232A;
-
-/// lozenge ('◊')
-const int $loz = 0x25CA;
-
-/// black spade suit ('♠')
-const int $spades = 0x2660;
-
-/// black club suit (shamrock) ('♣')
-const int $clubs = 0x2663;
-
-/// black heart suit (valentine) ('♥')
-const int $hearts = 0x2665;
-
-/// black diamond suit ('♦')
-const int $diams = 0x2666;
diff --git a/packages/cli_util/.travis.yml b/packages/cli_util/.travis.yml
index b1279b7..7fe752e 100644
--- a/packages/cli_util/.travis.yml
+++ b/packages/cli_util/.travis.yml
@@ -1,3 +1,4 @@
language: dart
script: ./tool/travis.sh
+dist: trusty
sudo: false
diff --git a/packages/cli_util/CHANGELOG.md b/packages/cli_util/CHANGELOG.md
index 7a7bfa4..372cddd 100644
--- a/packages/cli_util/CHANGELOG.md
+++ b/packages/cli_util/CHANGELOG.md
@@ -1,4 +1,6 @@
-# Changelog
+## 0.1.2+1
+
+- Remove unneeded change to Dart SDK constraint.
## 0.1.2
@@ -11,7 +13,9 @@
## 0.1.0
-- Use the new `Platform.resolvedExecutable` API to locate the SDK
+- Added a new `getSdkPath()` method to get the location of the SDK (this uses the new
+ `Platform.resolvedExecutable` API to locate the SDK)
+- Deprecated `getSdkDir()` in favor of `getSdkPath()`
- Add the `cli_logging.dart` library - utilities to display output and progress
## 0.0.1+3
diff --git a/packages/cli_util/pubspec.yaml b/packages/cli_util/pubspec.yaml
index 05ccd97..d7ee512 100644
--- a/packages/cli_util/pubspec.yaml
+++ b/packages/cli_util/pubspec.yaml
@@ -1,11 +1,11 @@
name: cli_util
-version: 0.1.2
+version: 0.1.2+1
author: Dart Team <misc@dartlang.org>
description: A library to help in building Dart command-line apps.
homepage: https://github.com/dart-lang/cli_util
environment:
- sdk: '>=1.11.0 <2.0.0-dev.infinity'
+ sdk: '>=1.11.0 <2.0.0'
dependencies:
path: '>=1.0.0 <2.0.0'
diff --git a/packages/crypto/.travis.yml b/packages/crypto/.travis.yml
index 2760c00..04b3dd1 100644
--- a/packages/crypto/.travis.yml
+++ b/packages/crypto/.travis.yml
@@ -3,10 +3,6 @@
dart:
- stable
- dev
- - 1.22.1
- - 1.21.1
- - 1.20.1
- - 1.19.1
dart_task:
- test: -p vm
- test: -p firefox
@@ -14,6 +10,11 @@
install_dartium: true
- dartfmt
- dartanalyzer
+
+# Only building master means that we don't run two builds for each pull request.
+branches:
+ only: [master]
+
cache:
directories:
- $HOME/.pub-cache
diff --git a/packages/crypto/CHANGELOG.md b/packages/crypto/CHANGELOG.md
index 1417775..9538d91 100644
--- a/packages/crypto/CHANGELOG.md
+++ b/packages/crypto/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.0.2+1
+
+* Fix SDK constraint.
+
## 2.0.2
* Prepare `HashSink` implementation for limiting integers to 64 bits in Dart
diff --git a/packages/crypto/analysis_options.yaml b/packages/crypto/analysis_options.yaml
index 092773b..2592ade 100644
--- a/packages/crypto/analysis_options.yaml
+++ b/packages/crypto/analysis_options.yaml
@@ -1,29 +1,30 @@
analyzer:
- strong-mode: true
+ strong-mode: true
linter:
rules:
- # Errors
- - avoid_empty_else
- - comment_references
- - control_flow_in_finally
- - empty_statements
- - hash_and_equals
- - test_types_in_equals
- - throw_in_finally
- - unrelated_type_equality_checks
- - valid_regexps
+ # Errors
+ - avoid_empty_else
+ - comment_references
+ - control_flow_in_finally
+ - empty_statements
+ - hash_and_equals
+ - test_types_in_equals
+ - throw_in_finally
+ - unrelated_type_equality_checks
+ - valid_regexps
- # Style
- - annotate_overrides
- - avoid_init_to_null
- - avoid_return_types_on_setters
- - await_only_futures
- - camel_case_types
- - empty_catches
- - empty_constructor_bodies
- - library_names
- - library_prefixes
- - non_constant_identifier_names
- - prefer_is_not_empty
- - slash_for_doc_comments
- - type_init_formals
+ # Style
+ - annotate_overrides
+ - avoid_init_to_null
+ - avoid_return_types_on_setters
+ - await_only_futures
+ - camel_case_types
+ - empty_catches
+ - empty_constructor_bodies
+ - library_names
+ - library_prefixes
+ - non_constant_identifier_names
+ - prefer_is_not_empty
+ - prefer_single_quotes
+ - slash_for_doc_comments
+ - type_init_formals
diff --git a/packages/crypto/lib/src/hash_sink.dart b/packages/crypto/lib/src/hash_sink.dart
index 369d3e3..ef38780 100644
--- a/packages/crypto/lib/src/hash_sink.dart
+++ b/packages/crypto/lib/src/hash_sink.dart
@@ -127,7 +127,7 @@
if (_lengthInBytes > _maxMessageLengthInBytes) {
throw new UnsupportedError(
- "Hashing is unsupported for messages with more than 2^64 bits.");
+ 'Hashing is unsupported for messages with more than 2^64 bits.');
}
var lengthInBits = _lengthInBytes * bitsPerByte;
diff --git a/packages/crypto/lib/src/hmac.dart b/packages/crypto/lib/src/hmac.dart
index 5caed75..b043a56 100644
--- a/packages/crypto/lib/src/hmac.dart
+++ b/packages/crypto/lib/src/hmac.dart
@@ -85,13 +85,13 @@
@override
void add(List<int> data) {
- if (_isClosed) throw new StateError("HMAC is closed");
+ if (_isClosed) throw new StateError('HMAC is closed');
_innerSink.add(data);
}
@override
void addSlice(List<int> data, int start, int end, bool isLast) {
- if (_isClosed) throw new StateError("HMAC is closed");
+ if (_isClosed) throw new StateError('HMAC is closed');
_innerSink.addSlice(data, start, end, isLast);
}
diff --git a/packages/crypto/lib/src/md5.dart b/packages/crypto/lib/src/md5.dart
index f666ef1..2729c5c 100644
--- a/packages/crypto/lib/src/md5.dart
+++ b/packages/crypto/lib/src/md5.dart
@@ -89,8 +89,8 @@
var c = digest[2];
var d = digest[3];
- var e;
- var f;
+ int e;
+ int f;
for (var i = 0; i < 64; i++) {
if (i < 16) {
diff --git a/packages/crypto/pubspec.yaml b/packages/crypto/pubspec.yaml
index a0e1343..3cb1170 100644
--- a/packages/crypto/pubspec.yaml
+++ b/packages/crypto/pubspec.yaml
@@ -1,10 +1,10 @@
name: crypto
-version: 2.0.2
+version: 2.0.2+1
author: Dart Team <misc@dartlang.org>
description: Library of cryptographic functions.
homepage: https://www.github.com/dart-lang/crypto
environment:
- sdk: '>=1.16.0 <2.0.0-dev.infinity'
+ sdk: '>=1.16.0 <2.0.0'
dependencies:
collection: '^1.0.0'
convert: '>=1.0.0 <3.0.0'
diff --git a/packages/crypto/test/hmac_md5_test.dart b/packages/crypto/test/hmac_md5_test.dart
index 68fa473..49e60f7 100644
--- a/packages/crypto/test/hmac_md5_test.dart
+++ b/packages/crypto/test/hmac_md5_test.dart
@@ -2,13 +2,13 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import "package:crypto/crypto.dart";
-import "package:test/test.dart";
+import 'package:crypto/crypto.dart';
+import 'package:test/test.dart';
import 'utils.dart';
void main() {
- group("standard vector", () {
+ group('standard vector', () {
for (var i = 0; i < _inputs.length; i++) {
test(_macs[i], () {
expectHmacEquals(md5, _inputs[i], _keys[i], _macs[i]);
diff --git a/packages/crypto/test/hmac_sha1_test.dart b/packages/crypto/test/hmac_sha1_test.dart
index 28eec21..c80b115 100644
--- a/packages/crypto/test/hmac_sha1_test.dart
+++ b/packages/crypto/test/hmac_sha1_test.dart
@@ -3,13 +3,13 @@
// BSD-style license that can be found in the LICENSE file.
// Library tag to allow the test to run on Dartium.
-import "package:crypto/crypto.dart";
-import "package:test/test.dart";
+import 'package:crypto/crypto.dart';
+import 'package:test/test.dart';
import 'utils.dart';
void main() {
- group("standard vector", () {
+ group('standard vector', () {
for (var i = 0; i < _inputs.length; i++) {
test(_macs[i], () {
expectHmacEquals(sha1, _inputs[i], _keys[i], _macs[i]);
diff --git a/packages/crypto/test/hmac_sha256_test.dart b/packages/crypto/test/hmac_sha256_test.dart
index 6c63268..a707813 100644
--- a/packages/crypto/test/hmac_sha256_test.dart
+++ b/packages/crypto/test/hmac_sha256_test.dart
@@ -3,13 +3,13 @@
// BSD-style license that can be found in the LICENSE file.
// Library tag to allow the test to run on Dartium.
-import "package:crypto/crypto.dart";
-import "package:test/test.dart";
+import 'package:crypto/crypto.dart';
+import 'package:test/test.dart';
import 'utils.dart';
void main() {
- group("standard vector", () {
+ group('standard vector', () {
for (var i = 0; i < _inputs.length; i++) {
test(_macs[i], () {
expectHmacEquals(sha256, _inputs[i], _keys[i], _macs[i]);
diff --git a/packages/crypto/test/sha1_test.dart b/packages/crypto/test/sha1_test.dart
index c0575e3..dffb400 100644
--- a/packages/crypto/test/sha1_test.dart
+++ b/packages/crypto/test/sha1_test.dart
@@ -2,14 +2,14 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import "dart:async";
-import "dart:convert";
+import 'dart:async';
+import 'dart:convert';
-import "package:crypto/crypto.dart";
-import "package:test/test.dart";
+import 'package:crypto/crypto.dart';
+import 'package:test/test.dart';
void main() {
- group("with a chunked converter", () {
+ group('with a chunked converter', () {
test('add may not be called after close', () {
var sink =
sha1.startChunkedConversion(new StreamController<Digest>().sink);
@@ -31,7 +31,7 @@
expectAsync1((accumulated) {
expect(accumulated.length, equals(1));
expect(accumulated.first.toString(),
- equals("da39a3ee5e6b4b0d3255bfef95601890afd80709"));
+ equals('da39a3ee5e6b4b0d3255bfef95601890afd80709'));
}));
var outer = sha1.startChunkedConversion(inner);
@@ -39,7 +39,7 @@
});
});
- group("standard vector", () {
+ group('standard vector', () {
for (var i = 0; i < _inputs.length; i++) {
test(_digests[i], () {
expect(sha1.convert(_inputs[i]).toString(), equals(_digests[i]));
@@ -51,7 +51,7 @@
// Standard test vectors from:
// http://csrc.nist.gov/groups/STM/cavp/documents/shs/shabytetestvectors.zip
-const _inputs = const [
+const _inputs = const <List<int>>[
const [],
const [0x36],
const [0x19, 0x5a],
diff --git a/packages/crypto/test/sha256_test.dart b/packages/crypto/test/sha256_test.dart
index 50ae0b2..aa3f2b8 100644
--- a/packages/crypto/test/sha256_test.dart
+++ b/packages/crypto/test/sha256_test.dart
@@ -2,14 +2,14 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import "dart:async";
-import "dart:convert";
+import 'dart:async';
+import 'dart:convert';
-import "package:test/test.dart";
-import "package:crypto/crypto.dart";
+import 'package:test/test.dart';
+import 'package:crypto/crypto.dart';
void main() {
- group("with a chunked converter", () {
+ group('with a chunked converter', () {
test('add may not be called after close', () {
var sink =
sha256.startChunkedConversion(new StreamController<Digest>().sink);
@@ -33,8 +33,8 @@
expect(
accumulated.first.toString(),
equals(
- "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8"
- "55"));
+ 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8'
+ '55'));
}));
var outer = sha256.startChunkedConversion(inner);
@@ -42,7 +42,7 @@
});
});
- group("standard vector", () {
+ group('standard vector', () {
for (var i = 0; i < _inputs.length; i++) {
test(_digests[i], () {
expect(sha256.convert(_inputs[i]).toString(), equals(_digests[i]));
@@ -54,7 +54,7 @@
// Standard test vectors from:
// http://csrc.nist.gov/groups/STM/cavp/documents/shs/shabytetestvectors.zip
-const _inputs = const [
+const _inputs = const <List<int>>[
const [],
const [0xd3],
const [0x11, 0xaf],
diff --git a/packages/csslib/.analysis_options b/packages/csslib/.analysis_options
deleted file mode 100644
index a10d4c5..0000000
--- a/packages/csslib/.analysis_options
+++ /dev/null
@@ -1,2 +0,0 @@
-analyzer:
- strong-mode: true
diff --git a/packages/csslib/CHANGELOG.md b/packages/csslib/CHANGELOG.md
index 8662956..213cb82 100644
--- a/packages/csslib/CHANGELOG.md
+++ b/packages/csslib/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 0.14.1
+
+* Deprecated `package:csslib/css.dart`.
+ Use `parser.dart` and `visitor.dart` instead.
+
## 0.14.0
### New features
diff --git a/packages/csslib/README.md b/packages/csslib/README.md
index 1610d3b..8a71da4 100644
--- a/packages/csslib/README.md
+++ b/packages/csslib/README.md
@@ -13,13 +13,12 @@
Parsing CSS is easy!
```dart
-import 'package:csslib/parser.dart' show parse;
-import 'package:csslib/css.dart';
+import 'package:csslib/parser.dart';
main() {
var stylesheet = parse(
'.foo { color: red; left: 20px; top: 20px; width: 100px; height:200px }');
- print(stylesheet.toString());
+ print(stylesheet.toDebugString());
}
```
diff --git a/packages/csslib/example/call_parser.dart b/packages/csslib/example/call_parser.dart
index 9a993ea..85325e4 100644
--- a/packages/csslib/example/call_parser.dart
+++ b/packages/csslib/example/call_parser.dart
@@ -43,7 +43,7 @@
'}',
errors: errors);
- if (!errors.isEmpty) {
+ if (errors.isNotEmpty) {
print("Got ${errors.length} errors.\n");
for (var error in errors) {
print(error);
@@ -61,7 +61,7 @@
'}',
errors: errors);
- if (!errors.isEmpty) {
+ if (errors.isNotEmpty) {
print("Got ${errors.length} errors.\n");
for (var error in errors) {
print(error);
@@ -75,7 +75,7 @@
print(' ===================================');
stylesheetError = parseCss('# div1 { color: red; }', errors: errors);
- if (!errors.isEmpty) {
+ if (errors.isNotEmpty) {
print("Detected ${errors.length} problem in checked mode.\n");
for (var error in errors) {
print(error);
@@ -88,7 +88,7 @@
print('4. Parse a selector only:');
print(' ======================');
var selectorAst = css.selector('#div .foo', errors: errors);
- if (!errors.isEmpty) {
+ if (errors.isNotEmpty) {
print("Got ${errors.length} errors.\n");
for (var error in errors) {
print(error);
diff --git a/packages/csslib/lib/css.dart b/packages/csslib/lib/css.dart
index e7ef534..98c9b2a 100644
--- a/packages/csslib/lib/css.dart
+++ b/packages/csslib/lib/css.dart
@@ -2,10 +2,12 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+@Deprecated('Will be removed in v0.15.0')
library css;
import 'dart:io';
+import 'package:args/args.dart';
import 'package:path/path.dart' as path;
import 'package:source_span/source_span.dart';
@@ -15,7 +17,7 @@
void main(List<String> arguments) {
// TODO(jmesserly): fix this to return a proper exit code
- var options = PreprocessorOptions.parse(arguments);
+ var options = _parseOptions(arguments);
if (options == null) return;
messages = new Messages(options: options);
@@ -35,7 +37,7 @@
// Read the file.
var filename = path.basename(inputPath);
var contents = new File(inputPath).readAsStringSync();
- var file = new SourceFile(contents, url: path.toUri(inputPath));
+ var file = new SourceFile.fromString(contents, url: path.toUri(inputPath));
// Parse the CSS.
StyleSheet tree = _time(
@@ -78,3 +80,67 @@
buf..write(duration)..write(' ms');
print(buf.toString());
}
+
+PreprocessorOptions _fromArgs(ArgResults args) => new PreprocessorOptions(
+ warningsAsErrors: args['warnings_as_errors'],
+ throwOnWarnings: args['throw_on_warnings'],
+ throwOnErrors: args['throw_on_errors'],
+ verbose: args['verbose'],
+ checked: args['checked'],
+ lessSupport: args['less'],
+ useColors: args['colors'],
+ polyfill: args['polyfill'],
+ inputFile: args.rest.length > 0 ? args.rest[0] : null);
+
+// tool.dart [options...] <css file>
+PreprocessorOptions _parseOptions(List<String> arguments) {
+ var parser = new ArgParser()
+ ..addFlag('verbose',
+ abbr: 'v',
+ defaultsTo: false,
+ negatable: false,
+ help: 'Display detail info')
+ ..addFlag('checked',
+ defaultsTo: false,
+ negatable: false,
+ help: 'Validate CSS values invalid value display a warning message')
+ ..addFlag('less',
+ defaultsTo: true,
+ negatable: true,
+ help: 'Supports subset of Less syntax')
+ ..addFlag('suppress_warnings',
+ defaultsTo: true, help: 'Warnings not displayed')
+ ..addFlag('warnings_as_errors',
+ defaultsTo: false, help: 'Warning handled as errors')
+ ..addFlag('throw_on_errors',
+ defaultsTo: false, help: 'Throw on errors encountered')
+ ..addFlag('throw_on_warnings',
+ defaultsTo: false, help: 'Throw on warnings encountered')
+ ..addFlag('colors',
+ defaultsTo: true, help: 'Display errors/warnings in colored text')
+ ..addFlag('polyfill',
+ defaultsTo: false, help: 'Generate polyfill for new CSS features')
+ ..addFlag('help',
+ abbr: 'h',
+ defaultsTo: false,
+ negatable: false,
+ help: 'Displays this help message');
+
+ try {
+ var results = parser.parse(arguments);
+ if (results['help'] || results.rest.length == 0) {
+ _showUsage(parser);
+ return null;
+ }
+ return _fromArgs(results);
+ } on FormatException catch (e) {
+ print(e.message);
+ _showUsage(parser);
+ return null;
+ }
+}
+
+void _showUsage(ArgParser parser) {
+ print('Usage: css [options...] input.css');
+ print(parser.usage);
+}
diff --git a/packages/csslib/lib/parser.dart b/packages/csslib/lib/parser.dart
index 6688507..db2068c 100644
--- a/packages/csslib/lib/parser.dart
+++ b/packages/csslib/lib/parser.dart
@@ -8,9 +8,9 @@
import 'package:source_span/source_span.dart';
-import 'visitor.dart';
import 'src/messages.dart';
import 'src/options.dart';
+import 'visitor.dart';
export 'src/messages.dart' show Message;
export 'src/options.dart';
@@ -68,7 +68,7 @@
_createMessages(errors: errors, options: options);
- var file = new SourceFile(source);
+ var file = new SourceFile.fromString(source);
var tree = new _Parser(file, source).parse();
@@ -99,7 +99,7 @@
_createMessages(errors: errors, options: options);
- var file = new SourceFile(source);
+ var file = new SourceFile.fromString(source);
return new _Parser(file, source).parse();
}
@@ -114,7 +114,7 @@
_createMessages(errors: errors);
- var file = new SourceFile(source);
+ var file = new SourceFile.fromString(source);
return (new _Parser(file, source)..tokenizer.inSelector = true)
.parseSelector();
}
@@ -124,7 +124,7 @@
_createMessages(errors: errors);
- var file = new SourceFile(source);
+ var file = new SourceFile.fromString(source);
return (new _Parser(file, source)
// TODO(jmesserly): this fix should be applied to the parser. It's tricky
// because by the time the flag is set one token has already been fetched.
diff --git a/packages/csslib/lib/src/analyzer.dart b/packages/csslib/lib/src/analyzer.dart
index 6c6ba6d..0bfb2f3 100644
--- a/packages/csslib/lib/src/analyzer.dart
+++ b/packages/csslib/lib/src/analyzer.dart
@@ -222,7 +222,7 @@
// If any expandedRuleSets and we're back at the top-level rule set then
// there were nested rule set(s).
if (_parentRuleSet == null) {
- if (!_expandedRuleSets.isEmpty) {
+ if (_expandedRuleSets.isNotEmpty) {
// Remember ruleset to replace with these flattened rulesets.
_expansions[node] = _expandedRuleSets;
_expandedRuleSets = [];
@@ -278,8 +278,8 @@
// Substitue the & with the parent selector and only use a combinator
// descendant if & is prefix by a sequence with an empty name e.g.,
// "... + &", "&", "... ~ &", etc.
- var hasPrefix = !newSequence.isEmpty &&
- !newSequence.last.simpleSelector.name.isEmpty;
+ var hasPrefix = newSequence.isNotEmpty &&
+ newSequence.last.simpleSelector.name.isNotEmpty;
newSequence.addAll(
hasPrefix ? _convertToDescendentSequence(parent) : parent);
} else {
@@ -906,7 +906,7 @@
SelectorGroup _currSelectorGroup;
int _currDeclIndex;
- List<int> _extendsToRemove = [];
+ final List<int> _extendsToRemove = [];
void visitRuleSet(RuleSet node) {
var oldSelectorGroup = _currSelectorGroup;
diff --git a/packages/csslib/lib/src/css_printer.dart b/packages/csslib/lib/src/css_printer.dart
index 91c2861..14c1f8c 100644
--- a/packages/csslib/lib/src/css_printer.dart
+++ b/packages/csslib/lib/src/css_printer.dart
@@ -529,7 +529,7 @@
void visitVarUsage(VarUsage node) {
emit('var(${node.name}');
- if (!node.defaultValues.isEmpty) {
+ if (node.defaultValues.isNotEmpty) {
emit(',');
for (var defaultValue in node.defaultValues) {
emit(' ');
diff --git a/packages/csslib/lib/src/options.dart b/packages/csslib/lib/src/options.dart
index c80370b..56c358b 100644
--- a/packages/csslib/lib/src/options.dart
+++ b/packages/csslib/lib/src/options.dart
@@ -4,8 +4,6 @@
library csslib.src.options;
-import 'package:args/args.dart';
-
class PreprocessorOptions {
/** Generate polyfill code (e.g., var, etc.) */
final bool polyfill;
@@ -50,68 +48,4 @@
this.useColors: true,
this.polyfill: false,
this.inputFile});
-
- PreprocessorOptions.fromArgs(ArgResults args)
- : warningsAsErrors = args['warnings_as_errors'],
- throwOnWarnings = args['throw_on_warnings'],
- throwOnErrors = args['throw_on_errors'],
- verbose = args['verbose'],
- checked = args['checked'],
- lessSupport = args['less'],
- useColors = args['colors'],
- polyfill = args['polyfill'],
- inputFile = args.rest.length > 0 ? args.rest[0] : null;
-
- // tool.dart [options...] <css file>
- static PreprocessorOptions parse(List<String> arguments) {
- var parser = new ArgParser()
- ..addFlag('verbose',
- abbr: 'v',
- defaultsTo: false,
- negatable: false,
- help: 'Display detail info')
- ..addFlag('checked',
- defaultsTo: false,
- negatable: false,
- help: 'Validate CSS values invalid value display a warning message')
- ..addFlag('less',
- defaultsTo: true,
- negatable: true,
- help: 'Supports subset of Less syntax')
- ..addFlag('suppress_warnings',
- defaultsTo: true, help: 'Warnings not displayed')
- ..addFlag('warnings_as_errors',
- defaultsTo: false, help: 'Warning handled as errors')
- ..addFlag('throw_on_errors',
- defaultsTo: false, help: 'Throw on errors encountered')
- ..addFlag('throw_on_warnings',
- defaultsTo: false, help: 'Throw on warnings encountered')
- ..addFlag('colors',
- defaultsTo: true, help: 'Display errors/warnings in colored text')
- ..addFlag('polyfill',
- defaultsTo: false, help: 'Generate polyfill for new CSS features')
- ..addFlag('help',
- abbr: 'h',
- defaultsTo: false,
- negatable: false,
- help: 'Displays this help message');
-
- try {
- var results = parser.parse(arguments);
- if (results['help'] || results.rest.length == 0) {
- showUsage(parser);
- return null;
- }
- return new PreprocessorOptions.fromArgs(results);
- } on FormatException catch (e) {
- print(e.message);
- showUsage(parser);
- return null;
- }
- }
-
- static showUsage(parser) {
- print('Usage: css [options...] input.css');
- print(parser.getUsage());
- }
}
diff --git a/packages/csslib/lib/src/property.dart b/packages/csslib/lib/src/property.dart
index a2cf97c..69f5c54 100644
--- a/packages/csslib/lib/src/property.dart
+++ b/packages/csslib/lib/src/property.dart
@@ -1245,4 +1245,4 @@
num get height => (top != null ? top : 0) + (bottom != null ? bottom : 0);
}
-/*=T*/ _mergeVal/*<T>*/(/*=T*/ x, /*=T*/ y) => y != null ? y : x;
+T _mergeVal<T>(T x, T y) => y != null ? y : x;
diff --git a/packages/csslib/lib/src/tree.dart b/packages/csslib/lib/src/tree.dart
index 7e68473..7e1fe6d 100644
--- a/packages/csslib/lib/src/tree.dart
+++ b/packages/csslib/lib/src/tree.dart
@@ -640,8 +640,7 @@
final List<MediaQuery> mediaQueries;
final List<TreeNode> rules;
- MediaDirective(this.mediaQueries, this.rules, SourceSpan span)
- : super(span);
+ MediaDirective(this.mediaQueries, this.rules, SourceSpan span) : super(span);
MediaDirective clone() {
var cloneQueries = <MediaQuery>[];
diff --git a/packages/csslib/pubspec.yaml b/packages/csslib/pubspec.yaml
index 2111ec9..3660833 100644
--- a/packages/csslib/pubspec.yaml
+++ b/packages/csslib/pubspec.yaml
@@ -1,15 +1,15 @@
name: csslib
-version: 0.14.0
+version: 0.14.1
author: Dart Team <misc@dartlang.org>
description: A library for parsing CSS.
homepage: https://github.com/dart-lang/csslib
environment:
- sdk: '>=1.1.0 <2.0.0'
+ sdk: '>=1.21.0 <2.0.0'
dependencies:
- args: '>=0.9.0 <0.14.0'
+ args: '>=0.12.1 <2.0.0'
logging: '>=0.9.0 <0.12.0'
path: '>=0.9.0 <2.0.0'
- source_span: '>=1.0.0 <2.0.0'
+ source_span: '>=1.4.0 <2.0.0'
dev_dependencies:
browser: '>=0.9.0 <0.11.0'
test: '>=0.12.0 <0.13.0'
diff --git a/packages/csslib/test/compiler_test.dart b/packages/csslib/test/compiler_test.dart
index e64af7f..5faabe2 100644
--- a/packages/csslib/test/compiler_test.dart
+++ b/packages/csslib/test/compiler_test.dart
@@ -533,9 +533,7 @@
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
.foo {
color: #f00;
left: 20px;
@@ -597,9 +595,7 @@
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
html:lang(fr-ca) {
quotes: '" ' ' "';
}
@@ -669,9 +665,7 @@
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
@host {
:scope {
white-space: nowrap;
@@ -697,9 +691,7 @@
expect(stylesheet != null, true);
expect(errors.isEmpty, true, reason: errors.toString());
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
a {
foo: '{"text" : "a\\\""}';
}''');
@@ -721,9 +713,7 @@
walkTree(stylesheet);
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
.foo {
color: #f00;
left: 20px;
diff --git a/packages/csslib/test/error_test.dart b/packages/csslib/test/error_test.dart
index 1060d83..013865e 100644
--- a/packages/csslib/test/error_test.dart
+++ b/packages/csslib/test/error_test.dart
@@ -21,17 +21,13 @@
var stylesheet = parseCss(input, errors: errors);
expect(errors.isEmpty, false);
- expect(
- errors[0].toString(),
- r'''
+ expect(errors[0].toString(), r'''
error on line 1, column 24: Unknown property value bolder
.foobar { font-weight: bolder; }
^^^^^^''');
expect(stylesheet != null, true);
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
.foobar {
font-weight: bolder;
}''');
@@ -42,16 +38,12 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(
- errors[0].toString(),
- r'''
+ expect(errors[0].toString(), r'''
error on line 1, column 24: Unknown property value lighter
.foobar { font-weight: lighter; }
^^^^^^^''');
expect(stylesheet != null, true);
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
.foobar {
font-weight: lighter;
}''');
@@ -62,16 +54,12 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(
- errors[0].toString(),
- r'''
+ expect(errors[0].toString(), r'''
error on line 1, column 24: Unknown property value inherit
.foobar { font-weight: inherit; }
^^^^^^^''');
expect(stylesheet != null, true);
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
.foobar {
font-weight: inherit;
}''');
@@ -89,16 +77,12 @@
var stylesheet = parseCss(input, errors: errors);
expect(errors.isEmpty, false);
- expect(
- errors[0].toString(),
- r'''
+ expect(errors[0].toString(), r'''
error on line 1, column 24: Unexpected value for line-height
.foobar { line-height: 120%; }
^^^''');
expect(stylesheet != null, true);
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
.foobar {
line-height: 120%;
}''');
@@ -109,16 +93,12 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(
- errors[0].toString(),
- r'''
+ expect(errors[0].toString(), r'''
error on line 1, column 24: Unexpected unit for line-height
.foobar { line-height: 20cm; }
^^''');
expect(stylesheet != null, true);
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
.foobar {
line-height: 20cm;
}''');
@@ -129,16 +109,12 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(
- errors[0].toString(),
- r'''
+ expect(errors[0].toString(), r'''
error on line 1, column 24: Unknown property value inherit
.foobar { line-height: inherit; }
^^^^^^^''');
expect(stylesheet != null, true);
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
.foobar {
line-height: inherit;
}''');
@@ -153,16 +129,12 @@
var stylesheet = parseCss(input, errors: errors);
expect(errors.isEmpty, false);
- expect(
- errors[0].toString(),
- r'''
+ expect(errors[0].toString(), r'''
error on line 1, column 1: Not a valid ID selector expected #id
# foo { color: #ff00ff; }
^''');
expect(stylesheet != null, true);
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
# foo {
color: #f0f;
}''');
@@ -172,16 +144,12 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(
- errors[0].toString(),
- r'''
+ expect(errors[0].toString(), r'''
error on line 1, column 1: Not a valid class selector expected .className
. foo { color: #ff00ff; }
^''');
expect(stylesheet != null, true);
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
. foo {
color: #f0f;
}''');
@@ -196,16 +164,12 @@
var stylesheet = parseCss(input, errors: errors);
expect(errors.isEmpty, false);
- expect(
- errors[0].toString(),
- r'''
+ expect(errors[0].toString(), r'''
error on line 1, column 18: Bad hex number
.foobar { color: #AH787; }
^^^^^^''');
expect(stylesheet != null, true);
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
.foobar {
color: #AH787;
}''');
@@ -215,17 +179,13 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(
- errors[0].toString(),
- r'''
+ expect(errors[0].toString(), r'''
error on line 1, column 18: Unknown property value redder
.foobar { color: redder; }
^^^^^^''');
expect(stylesheet != null, true);
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
.foobar {
color: redder;
}''');
@@ -235,17 +195,13 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(
- errors[0].toString(),
- r'''
+ expect(errors[0].toString(), r'''
error on line 1, column 18: Expected hex number
.foobar { color: # ffffff; }
^''');
expect(stylesheet != null, true);
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
.foobar {
color: # ffffff;
}''');
@@ -255,9 +211,7 @@
stylesheet = parseCss(input, errors: errors..clear());
expect(errors.isEmpty, false);
- expect(
- errors[0].toString(),
- r'''
+ expect(errors[0].toString(), r'''
error on line 1, column 18: Expected hex number
.foobar { color: # 123fff; }
^''');
@@ -266,9 +220,7 @@
// Formating is off with an extra space. However, the entire value is bad
// and isn't processed anyway.
- expect(
- prettyPrint(stylesheet),
- r'''
+ expect(prettyPrint(stylesheet), r'''
.foobar {
color: # 123 fff;
}''');
diff --git a/packages/csslib/test/extend_test.dart b/packages/csslib/test/extend_test.dart
index 184a8b4..7df68c5 100644
--- a/packages/csslib/test/extend_test.dart
+++ b/packages/csslib/test/extend_test.dart
@@ -18,8 +18,7 @@
}
void simpleExtend() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
.error {
border: 1px red;
background-color: #fdd;
@@ -28,8 +27,7 @@
@extend .error;
border-width: 3px;
}
-''',
- r'''
+''', r'''
.error, .seriousError {
border: 1px #f00;
background-color: #fdd;
@@ -40,8 +38,7 @@
}
void complexSelectors() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
.error {
border: 1px #f00;
background-color: #fdd;
@@ -53,8 +50,7 @@
@extend .error;
border-width: 3px;
}
-''',
- r'''
+''', r'''
.error, .seriousError {
border: 1px #f00;
background-color: #fdd;
@@ -66,16 +62,14 @@
border-width: 3px;
}''');
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
a:hover {
text-decoration: underline;
}
.hoverlink {
@extend a:hover;
}
-''',
- r'''
+''', r'''
a:hover, .hoverlink {
text-decoration: underline;
}
@@ -84,8 +78,7 @@
}
void multipleExtends() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
.error {
border: 1px #f00;
background-color: #fdd;
@@ -99,8 +92,7 @@
@extend .attention;
border-width: 3px;
}
-''',
- r'''
+''', r'''
.error, .seriousError {
border: 1px #f00;
background-color: #fdd;
@@ -115,8 +107,7 @@
}
void chaining() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
.error {
border: 1px #f00;
background-color: #fdd;
@@ -133,8 +124,7 @@
left: 10%;
right: 10%;
}
-''',
- r'''
+''', r'''
.error, .seriousError, .criticalError {
border: 1px #f00;
background-color: #fdd;
@@ -152,8 +142,7 @@
}
void nestedSelectors() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
a {
color: blue;
&:hover {
@@ -164,8 +153,7 @@
#fake-links .link {
@extend a;
}
-''',
- r'''
+''', r'''
a, #fake-links .link {
color: #00f;
}
@@ -177,8 +165,7 @@
}
void nestedMulty() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
.btn {
display: inline-block;
}
@@ -190,8 +177,7 @@
@extend .btn;
}
}
-''',
- r'''
+''', r'''
.btn, input[type="checkbox"].toggle-button label {
display: inline-block;
}
diff --git a/packages/csslib/test/mixin_test.dart b/packages/csslib/test/mixin_test.dart
index 375054c..59071f9 100644
--- a/packages/csslib/test/mixin_test.dart
+++ b/packages/csslib/test/mixin_test.dart
@@ -26,8 +26,7 @@
}
void topLevelMixin() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin silly-links {
a {
color: blue;
@@ -36,8 +35,7 @@
}
@include silly-links;
-''',
- r'''
+''', r'''
a {
color: #00f;
background-color: #f00;
@@ -45,8 +43,7 @@
}
void topLevelMixinTwoIncludes() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin a {
a {
color: blue;
@@ -61,8 +58,7 @@
}
@include a;
@include b;
-''',
- r'''
+''', r'''
a {
color: #00f;
background-color: #f00;
@@ -75,8 +71,7 @@
/** Tests top-level mixins that includes another mixin. */
void topLevelMixinMultiRulesets() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin a {
a {
color: blue;
@@ -98,8 +93,7 @@
}
@include a;
@include c;
-''',
- r'''
+''', r'''
a {
color: #00f;
background-color: #f00;
@@ -115,8 +109,7 @@
}
void topLevelMixinDeeplyNestedRulesets() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin a {
a {
color: blue;
@@ -156,8 +149,7 @@
@include d;
}
@include c;
-''',
- r'''
+''', r'''
a {
color: #00f;
background-color: #f00;
@@ -183,8 +175,7 @@
/** Tests selector groups and other combinators. */
void topLevelMixinSelectors() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin a {
a, b {
color: blue;
@@ -197,8 +188,7 @@
}
@include a;
-''',
- r'''
+''', r'''
a, b {
color: #00f;
background-color: #f00;
@@ -210,24 +200,21 @@
}
void declSimpleMixin() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin div-border {
border: 2px dashed red;
}
div {
@include div-border;
}
-''',
- r'''
+''', r'''
div {
border: 2px dashed #f00;
}''');
}
void declMixinTwoIncludes() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin div-border {
border: 2px dashed red;
}
@@ -238,8 +225,7 @@
@include div-border;
@include div-color;
}
-''',
- r'''
+''', r'''
div {
border: 2px dashed #f00;
color: #00f;
@@ -247,8 +233,7 @@
}
void declMixinNestedIncludes() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin div-border {
border: 2px dashed red;
}
@@ -267,8 +252,7 @@
@include div-border;
@include div-color;
}
-''',
- r'''
+''', r'''
div {
border: 2px dashed #f00;
padding: .5em;
@@ -278,8 +262,7 @@
}
void declMixinDeeperNestedIncludes() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin div-border {
border: 2px dashed red;
}
@@ -297,8 +280,7 @@
@include div-border;
@include div-color;
}
-''',
- r'''
+''', r'''
div {
border: 2px dashed #f00;
padding: .5em;
@@ -307,8 +289,7 @@
}
void mixinArg() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin div-border-1 {
border: 2px dashed red;
}
@@ -337,8 +318,7 @@
div-4 {
@include div-border-2;
}
-''',
- r'''
+''', r'''
div-1 {
margin-left: 10px;
margin-right: 100px;
@@ -358,8 +338,7 @@
}
void mixinArgs() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin box-shadow(@shadows...) {
-moz-box-shadow: @shadows;
-webkit-box-shadow: @shadows;
@@ -368,8 +347,7 @@
.shadows {
@include box-shadow(0px 4px 5px #666, 2px 6px 10px #999);
-}''',
- r'''
+}''', r'''
.shadowed {
-moz-box-shadow: 0px 4px 5px #666, 2px 6px 10px #999;
-webkit-box-shadow: 0px 4px 5px #666, 2px 6px 10px #999;
@@ -379,8 +357,7 @@
}
void mixinManyArgs() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin border(@border-values) {
border: @border-values
}
@@ -388,14 +365,12 @@
.primary {
@include border(3px solid green);
}
-''',
- r'''
+''', r'''
.primary {
border: 3px solid #008000;
}''');
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin setup(@border-color, @border-style, @border-size, @color) {
border: @border-size @border-style @border-color;
color: @color;
@@ -404,16 +379,14 @@
.primary {
@include setup(red, solid, 5px, blue);
}
-''',
- r'''
+''', r'''
.primary {
border: 5px solid #f00;
color: #00f;
}''');
// Test passing a declaration that is multiple parameters.
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin colors(@text, @background, @border) {
color: @text;
background-color: @background;
@@ -424,8 +397,7 @@
.primary {
@include colors(@values);
}
-''',
- r'''
+''', r'''
var-values: #f00, #0f0, #00f;
.primary {
@@ -434,8 +406,7 @@
border-color: #00f;
}''');
- compilePolyfillAndValidate(
- r'''
+ compilePolyfillAndValidate(r'''
@mixin colors(@text, @background, @border) {
color: @text;
background-color: @background;
@@ -446,8 +417,7 @@
.primary {
@include colors(@values);
}
-''',
- r'''
+''', r'''
.primary {
color: #f00;
background-color: #0f0;
@@ -590,8 +560,7 @@
}
void includeGrammar() {
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin a {
foo { color: red }
}
@@ -602,8 +571,7 @@
}
@include b;
-''',
- r'''
+''', r'''
foo {
color: #f00;
}
@@ -611,8 +579,7 @@
color: #f00;
}''');
- compileAndValidate(
- r'''
+ compileAndValidate(r'''
@mixin a {
color: red
}
@@ -621,8 +588,7 @@
@include a;
@include a
}
-''',
- r'''
+''', r'''
foo {
color: #f00;
color: #f00;
diff --git a/packages/csslib/test/var_test.dart b/packages/csslib/test/var_test.dart
index 3c53169..39e7c45 100644
--- a/packages/csslib/test/var_test.dart
+++ b/packages/csslib/test/var_test.dart
@@ -748,15 +748,13 @@
}
void polyfill() {
- compilePolyfillAndValidate(
- r'''
+ compilePolyfillAndValidate(r'''
@color-background: red;
@color-foreground: blue;
.test {
background-color: @color-background;
color: @color-foreground;
-}''',
- r'''
+}''', r'''
.test {
background-color: #f00;
color: #00f;
@@ -764,8 +762,7 @@
}
void testIndirects() {
- compilePolyfillAndValidate(
- '''
+ compilePolyfillAndValidate('''
:root {
var-redef: #0f0;
@@ -782,8 +779,7 @@
}
.test-1 {
color: @redef;
-}''',
- r'''
+}''', r'''
:root {
}
.test {
diff --git a/packages/csslib/test/visitor_test.dart b/packages/csslib/test/visitor_test.dart
index 16071c7..02784c4 100644
--- a/packages/csslib/test/visitor_test.dart
+++ b/packages/csslib/test/visitor_test.dart
@@ -60,9 +60,7 @@
..visitTree(s);
expect(clsVisits.matches, true);
- expect(
- prettyPrint(s),
- r'''
+ expect(prettyPrint(s), r'''
.foobar1 {
}
.xyzzy .foo #my-div {
diff --git a/packages/dart_style/._AUTHORS b/packages/dart_style/._AUTHORS
deleted file mode 100644
index fa0c94c..0000000
--- a/packages/dart_style/._AUTHORS
+++ /dev/null
Binary files differ
diff --git a/packages/dart_style/._LICENSE b/packages/dart_style/._LICENSE
deleted file mode 100644
index 8d50f72..0000000
--- a/packages/dart_style/._LICENSE
+++ /dev/null
Binary files differ
diff --git a/packages/dart_style/._PATENTS b/packages/dart_style/._PATENTS
deleted file mode 100644
index 0abd44b..0000000
--- a/packages/dart_style/._PATENTS
+++ /dev/null
Binary files differ
diff --git a/packages/dart_style/lib/src/._error_listener.dart b/packages/dart_style/lib/src/._error_listener.dart
deleted file mode 100644
index bcc5ac5..0000000
--- a/packages/dart_style/lib/src/._error_listener.dart
+++ /dev/null
Binary files differ
diff --git a/packages/dart_style/test/selections/._selections.stmt b/packages/dart_style/test/selections/._selections.stmt
deleted file mode 100644
index 9f912de..0000000
--- a/packages/dart_style/test/selections/._selections.stmt
+++ /dev/null
Binary files differ
diff --git a/packages/dart_style/test/splitting/._arrows.unit b/packages/dart_style/test/splitting/._arrows.unit
deleted file mode 100644
index fa01847..0000000
--- a/packages/dart_style/test/splitting/._arrows.unit
+++ /dev/null
Binary files differ
diff --git a/packages/dart_style/test/whitespace/._do.stmt b/packages/dart_style/test/whitespace/._do.stmt
deleted file mode 100644
index 7e57633..0000000
--- a/packages/dart_style/test/whitespace/._do.stmt
+++ /dev/null
Binary files differ
diff --git a/packages/dart_style/test/whitespace/._try.stmt b/packages/dart_style/test/whitespace/._try.stmt
deleted file mode 100644
index 4e6803c..0000000
--- a/packages/dart_style/test/whitespace/._try.stmt
+++ /dev/null
Binary files differ
diff --git a/packages/glob/.analysis_options b/packages/glob/.analysis_options
deleted file mode 100644
index a10d4c5..0000000
--- a/packages/glob/.analysis_options
+++ /dev/null
@@ -1,2 +0,0 @@
-analyzer:
- strong-mode: true
diff --git a/packages/glob/CHANGELOG.md b/packages/glob/CHANGELOG.md
index 3d440e8..1768bab 100644
--- a/packages/glob/CHANGELOG.md
+++ b/packages/glob/CHANGELOG.md
@@ -1,3 +1,14 @@
+## 1.1.5
+
+* Declare support for `async` 2.0.0.
+
+* Require Dart 1.23.0.
+
+## 1.1.4
+
+* Throw an exception when listing globs whose initial paths don't exist in
+ case-insensitive mode. This matches the case-sensitive behavior.
+
## 1.1.3
* Support `string_scanner` 1.0.0.
diff --git a/packages/glob/lib/glob.dart b/packages/glob/lib/glob.dart
index ca83969..a7d6b4c 100644
--- a/packages/glob/lib/glob.dart
+++ b/packages/glob/lib/glob.dart
@@ -58,6 +58,7 @@
}
return _contextIsAbsoluteCache;
}
+
bool _contextIsAbsoluteCache;
/// Whether [pattern] could match absolute paths.
@@ -67,6 +68,7 @@
}
return _patternCanMatchAbsoluteCache;
}
+
bool _patternCanMatchAbsoluteCache;
/// Whether [pattern] could match relative paths.
@@ -76,6 +78,7 @@
}
return _patternCanMatchRelativeCache;
}
+
bool _patternCanMatchRelativeCache;
/// Returns [contents] with characters that are meaningful in globs
@@ -95,8 +98,8 @@
/// case matches that of the characters in the glob. Otherwise, it matches
/// regardless of case. This defaults to `false` when [context] is Windows and
/// `true` otherwise.
- factory Glob(String pattern, {p.Context context, bool recursive: false,
- bool caseSensitive}) {
+ factory Glob(String pattern,
+ {p.Context context, bool recursive: false, bool caseSensitive}) {
context ??= p.context;
caseSensitive ??= context.style == p.Style.windows ? false : true;
if (recursive) pattern += "{,/**}";
diff --git a/packages/glob/lib/src/ast.dart b/packages/glob/lib/src/ast.dart
index 5e24e2b..130342e 100644
--- a/packages/glob/lib/src/ast.dart
+++ b/packages/glob/lib/src/ast.dart
@@ -38,9 +38,9 @@
///
/// For example, given the glob `{foo,bar}/{click/clack}`, this would return
/// `{foo/click,foo/clack,bar/click,bar/clack}`.
- OptionsNode flattenOptions() => new OptionsNode(
- [new SequenceNode([this], caseSensitive: caseSensitive)],
- caseSensitive: caseSensitive);
+ OptionsNode flattenOptions() => new OptionsNode([
+ new SequenceNode([this], caseSensitive: caseSensitive)
+ ], caseSensitive: caseSensitive);
/// Returns whether this glob matches [string].
bool matches(String string) {
@@ -71,8 +71,8 @@
return new OptionsNode([this], caseSensitive: caseSensitive);
}
- var sequences = nodes.first.flattenOptions().options
- .map((sequence) => sequence.nodes);
+ var sequences =
+ nodes.first.flattenOptions().options.map((sequence) => sequence.nodes);
for (var node in nodes.skip(1)) {
// Concatenate all sequences in the next options node ([nextSequences])
// onto all previous sequences ([sequences]).
@@ -86,18 +86,22 @@
return new OptionsNode(sequences.map((sequence) {
// Combine any adjacent LiteralNodes in [sequence].
- return new SequenceNode(sequence.fold/*<List<AstNode>>*/([], (combined, node) {
- if (combined.isEmpty || combined.last is! LiteralNode ||
- node is! LiteralNode) {
- return combined..add(node);
- }
+ return new SequenceNode(
+ sequence.fold<List<AstNode>>([], (combined, node) {
+ if (combined.isEmpty ||
+ combined.last is! LiteralNode ||
+ node is! LiteralNode) {
+ return combined..add(node);
+ }
- combined[combined.length - 1] = new LiteralNode(
- // TODO(nweiz): Avoid casting when sdk#25565 is fixed.
- (combined.last as LiteralNode).text + (node as LiteralNode).text,
- caseSensitive: caseSensitive);
- return combined;
- }), caseSensitive: caseSensitive);
+ combined[combined.length - 1] = new LiteralNode(
+ // TODO(nweiz): Avoid casting when sdk#25565 is fixed.
+ (combined.last as LiteralNode).text +
+ (node as LiteralNode).text,
+ caseSensitive: caseSensitive);
+ return combined;
+ }),
+ caseSensitive: caseSensitive);
}), caseSensitive: caseSensitive);
}
@@ -185,7 +189,8 @@
String _toRegExp() => nodes.map((node) => node._toRegExp()).join();
- bool operator==(Object other) => other is SequenceNode &&
+ bool operator ==(Object other) =>
+ other is SequenceNode &&
const IterableEquality().equals(nodes, other.nodes);
int get hashCode => const IterableEquality().hash(nodes);
@@ -199,7 +204,7 @@
String _toRegExp() => '[^/]*';
- bool operator==(Object other) => other is StarNode;
+ bool operator ==(Object other) => other is StarNode;
int get hashCode => 0;
@@ -241,7 +246,7 @@
return buffer.toString();
}
- bool operator==(Object other) => other is DoubleStarNode;
+ bool operator ==(Object other) => other is DoubleStarNode;
int get hashCode => 1;
@@ -254,7 +259,7 @@
String _toRegExp() => '[^/]';
- bool operator==(Object other) => other is AnyCharNode;
+ bool operator ==(Object other) => other is AnyCharNode;
int get hashCode => 2;
@@ -319,7 +324,7 @@
return buffer.toString();
}
- bool operator==(Object other) {
+ bool operator ==(Object other) {
if (other is! RangeNode) return false;
if ((other as RangeNode).negated != negated) return false;
return const SetEquality().equals(ranges, (other as RangeNode).ranges);
@@ -359,7 +364,8 @@
String _toRegExp() =>
'(?:${options.map((option) => option._toRegExp()).join("|")})';
- bool operator==(Object other) => other is OptionsNode &&
+ bool operator ==(Object other) =>
+ other is OptionsNode &&
const UnorderedIterableEquality().equals(options, other.options);
int get hashCode => const UnorderedIterableEquality().hash(options);
@@ -378,8 +384,8 @@
final p.Context _context;
bool get canMatchAbsolute {
- var nativeText = _context.style == p.Style.windows ?
- text.replaceAll('/', '\\') : text;
+ var nativeText =
+ _context.style == p.Style.windows ? text.replaceAll('/', '\\') : text;
return _context.isAbsolute(nativeText);
}
@@ -391,7 +397,7 @@
String _toRegExp() => regExpQuote(text);
- bool operator==(Object other) => other is LiteralNode && other.text == text;
+ bool operator ==(Object other) => other is LiteralNode && other.text == text;
int get hashCode => text.hashCode;
diff --git a/packages/glob/lib/src/list_tree.dart b/packages/glob/lib/src/list_tree.dart
index 3cce642..f51e4bb 100644
--- a/packages/glob/lib/src/list_tree.dart
+++ b/packages/glob/lib/src/list_tree.dart
@@ -2,8 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:io';
import 'dart:async';
+import 'dart:io';
import 'package:async/async.dart';
import 'package:path/path.dart' as p;
@@ -143,8 +143,8 @@
parent = parent.children[component];
}
} else if (recursive) {
- _trees[root] = new _ListTreeNode.recursive(
- _join(components.sublist(i)));
+ _trees[root] =
+ new _ListTreeNode.recursive(_join(components.sublist(i)));
return;
} else if (complete) {
_trees[root] = new _ListTreeNode()..addOption(component);
@@ -193,8 +193,7 @@
List<FileSystemEntity> listSync({String root, bool followLinks: true}) {
if (root == null) root = '.';
- // TODO(nweiz): Remove the explicit annotation when sdk#26139 is fixed.
- var result = _trees.keys.expand/*<FileSystemEntity>*/((rootDir) {
+ var result = _trees.keys.expand((rootDir) {
var dir = rootDir == '.' ? root : rootDir;
return _trees[rootDir].listSync(dir, followLinks: followLinks);
});
@@ -247,7 +246,6 @@
/// its children.
bool get _isIntermediate {
if (_validator != null) return false;
- if (!_caseSensitive) return false;
return children.keys.every((sequence) =>
sequence.nodes.length == 1 && sequence.nodes.first is LiteralNode);
}
@@ -301,8 +299,8 @@
/// Adds [validator] to this node's existing validator.
void addOption(SequenceNode validator) {
if (_validator == null) {
- _validator = new OptionsNode([validator],
- caseSensitive: validator.caseSensitive);
+ _validator =
+ new OptionsNode([validator], caseSensitive: validator.caseSensitive);
} else {
_validator.options.add(validator);
}
@@ -314,15 +312,15 @@
/// [ListTree.list].
Stream<FileSystemEntity> list(String dir, {bool followLinks: true}) {
if (isRecursive) {
- return new Directory(dir).list(recursive: true, followLinks: followLinks)
+ return new Directory(dir)
+ .list(recursive: true, followLinks: followLinks)
.where((entity) => _matches(p.relative(entity.path, from: dir)));
}
- var resultGroup = new StreamGroup<FileSystemEntity>();
-
// Don't spawn extra [Directory.list] calls when we already know exactly
// which subdirectories we're interested in.
- if (_isIntermediate) {
+ if (_isIntermediate && _caseSensitive) {
+ var resultGroup = new StreamGroup<FileSystemEntity>();
children.forEach((sequence, child) {
resultGroup.add(child.list(
p.join(dir, (sequence.nodes.single as LiteralNode).text),
@@ -332,35 +330,65 @@
return resultGroup.stream;
}
- var resultController = new StreamController<FileSystemEntity>(sync: true);
- resultGroup.add(resultController.stream);
- new Directory(dir).list(followLinks: followLinks).listen((entity) {
- var basename = p.relative(entity.path, from: dir);
- if (_matches(basename)) resultController.add(entity);
+ return StreamCompleter.fromFuture(() async {
+ var entities =
+ await new Directory(dir).list(followLinks: followLinks).toList();
+ await _validateIntermediateChildrenAsync(dir, entities);
- children.forEach((sequence, child) {
- if (entity is! Directory) return;
- if (!sequence.matches(basename)) return;
- var stream = child.list(p.join(dir, basename), followLinks: followLinks)
- .handleError((_) {}, test: (error) {
- // Ignore errors from directories not existing. We do this here so
- // that we only ignore warnings below wild cards. For example, the
- // glob "foo/bar/*/baz" should fail if "foo/bar" doesn't exist but
- // succeed if "foo/bar/qux/baz" doesn't exist.
- return error is FileSystemException &&
- (error.osError.errorCode == _ENOENT ||
- error.osError.errorCode == _ENOENT_WIN);
- });
- resultGroup.add(stream);
- });
- },
- onError: resultController.addError,
- onDone: () {
- resultController.close();
- resultGroup.close();
- });
+ var resultGroup = new StreamGroup<FileSystemEntity>();
+ var resultController = new StreamController<FileSystemEntity>(sync: true);
+ resultGroup.add(resultController.stream);
+ for (var entity in entities) {
+ var basename = p.relative(entity.path, from: dir);
+ if (_matches(basename)) resultController.add(entity);
- return resultGroup.stream;
+ children.forEach((sequence, child) {
+ if (entity is! Directory) return;
+ if (!sequence.matches(basename)) return;
+ var stream = child
+ .list(p.join(dir, basename), followLinks: followLinks)
+ .handleError((_) {}, test: (error) {
+ // Ignore errors from directories not existing. We do this here so
+ // that we only ignore warnings below wild cards. For example, the
+ // glob "foo/bar/*/baz" should fail if "foo/bar" doesn't exist but
+ // succeed if "foo/bar/qux/baz" doesn't exist.
+ return error is FileSystemException &&
+ (error.osError.errorCode == _ENOENT ||
+ error.osError.errorCode == _ENOENT_WIN);
+ });
+ resultGroup.add(stream);
+ });
+ }
+ resultController.close();
+ resultGroup.close();
+ return resultGroup.stream;
+ }());
+ }
+
+ /// If this is a case-insensitive list, validates that all intermediate
+ /// children (according to [_isIntermediate]) match at least one entity in
+ /// [entities].
+ ///
+ /// This ensures that listing "foo/bar/*" fails on case-sensitive systems if
+ /// "foo/bar" doesn't exist.
+ Future _validateIntermediateChildrenAsync(
+ String dir, List<FileSystemEntity> entities) async {
+ if (_caseSensitive) return;
+
+ for (var sequence in children.keys) {
+ var child = children[sequence];
+ if (!child._isIntermediate) continue;
+ if (entities.any(
+ (entity) => sequence.matches(p.relative(entity.path, from: dir)))) {
+ continue;
+ }
+
+ // We know this will fail, we're just doing it to force dart:io to emit
+ // the exception it would if we were listing case-sensitively.
+ await child
+ .list(p.join(dir, (sequence.nodes.single as LiteralNode).text))
+ .toList();
+ }
}
/// Synchronously lists all entities within [dir] matching this node or its
@@ -377,7 +405,7 @@
// Don't spawn extra [Directory.listSync] calls when we already know exactly
// which subdirectories we're interested in.
- if (_isIntermediate) {
+ if (_isIntermediate && _caseSensitive) {
return children.keys.expand((sequence) {
return children[sequence].listSync(
p.join(dir, (sequence.nodes.single as LiteralNode).text),
@@ -385,8 +413,10 @@
});
}
- return new Directory(dir).listSync(followLinks: followLinks)
- .expand((entity) {
+ var entities = new Directory(dir).listSync(followLinks: followLinks);
+ _validateIntermediateChildrenSync(dir, entities);
+
+ return entities.expand((entity) {
var entities = <FileSystemEntity>[];
var basename = p.relative(entity.path, from: dir);
if (_matches(basename)) entities.add(entity);
@@ -396,8 +426,9 @@
.where((sequence) => sequence.matches(basename))
.expand((sequence) {
try {
- return children[sequence].listSync(
- p.join(dir, basename), followLinks: followLinks).toList();
+ return children[sequence]
+ .listSync(p.join(dir, basename), followLinks: followLinks)
+ .toList();
} on FileSystemException catch (error) {
// Ignore errors from directories not existing. We do this here so
// that we only ignore warnings below wild cards. For example, the
@@ -416,6 +447,31 @@
});
}
+ /// If this is a case-insensitive list, validates that all intermediate
+ /// children (according to [_isIntermediate]) match at least one entity in
+ /// [entities].
+ ///
+ /// This ensures that listing "foo/bar/*" fails on case-sensitive systems if
+ /// "foo/bar" doesn't exist.
+ void _validateIntermediateChildrenSync(
+ String dir, List<FileSystemEntity> entities) {
+ if (_caseSensitive) return;
+
+ children.forEach((sequence, child) {
+ if (!child._isIntermediate) return;
+ if (entities.any(
+ (entity) => sequence.matches(p.relative(entity.path, from: dir)))) {
+ return;
+ }
+
+ // If there are no [entities] that match [sequence], manually list the
+ // directory to force `dart:io` to throw an error. This allows us to
+ // ensure that listing "foo/bar/*" fails on case-sensitive systems if
+ // "foo/bar" doesn't exist.
+ child.listSync(p.join(dir, (sequence.nodes.single as LiteralNode).text));
+ });
+ }
+
/// Returns whether the native [path] matches [_validator].
bool _matches(String path) {
if (_validator == null) return false;
diff --git a/packages/glob/lib/src/parser.dart b/packages/glob/lib/src/parser.dart
index d3c7e1d..a4e840c 100644
--- a/packages/glob/lib/src/parser.dart
+++ b/packages/glob/lib/src/parser.dart
@@ -120,8 +120,7 @@
if (end < char) {
_scanner.error("Range out of order.",
- position: start,
- length: _scanner.position - start);
+ position: start, length: _scanner.position - start);
}
ranges.add(new Range(char, end));
} else {
@@ -156,8 +155,8 @@
AstNode _parseLiteral({bool inOptions: false}) {
// If we're in an options block, we want to stop parsing as soon as we hit a
// comma. Otherwise, commas are fair game for literals.
- var regExp = new RegExp(
- inOptions ? r'[^*{[?\\}\],()]*' : r'[^*{[?\\}\]()]*');
+ var regExp =
+ new RegExp(inOptions ? r'[^*{[?\\}\],()]*' : r'[^*{[?\\}\]()]*');
_scanner.scan(regExp);
var buffer = new StringBuffer()..write(_scanner.lastMatch[0]);
diff --git a/packages/glob/lib/src/stream_pool.dart b/packages/glob/lib/src/stream_pool.dart
index 817d57a..cce94ed 100644
--- a/packages/glob/lib/src/stream_pool.dart
+++ b/packages/glob/lib/src/stream_pool.dart
@@ -46,8 +46,7 @@
void add(Stream<T> stream) {
if (_subscriptions.containsKey(stream)) return;
_subscriptions[stream] = stream.listen(_controller.add,
- onError: _controller.addError,
- onDone: () => remove(stream));
+ onError: _controller.addError, onDone: () => remove(stream));
}
/// Removes [stream] as a member of this pool.
diff --git a/packages/glob/lib/src/utils.dart b/packages/glob/lib/src/utils.dart
index 94f6a05..13c0b99 100644
--- a/packages/glob/lib/src/utils.dart
+++ b/packages/glob/lib/src/utils.dart
@@ -18,14 +18,13 @@
Range(this.min, this.max);
/// Returns a range that covers only [value].
- Range.singleton(int value)
- : this(value, value);
+ Range.singleton(int value) : this(value, value);
/// Whether [this] contains [value].
bool contains(int value) => value >= min && value <= max;
- bool operator==(Object other) => other is Range &&
- other.min == min && other.max == max;
+ bool operator ==(Object other) =>
+ other is Range && other.min == min && other.max == max;
int get hashCode => 3 * min + 7 * max;
}
diff --git a/packages/glob/pubspec.yaml b/packages/glob/pubspec.yaml
index 4037f80..8aceccb 100644
--- a/packages/glob/pubspec.yaml
+++ b/packages/glob/pubspec.yaml
@@ -1,15 +1,15 @@
name: glob
-version: 1.1.3
+version: 1.1.5
author: "Dart Team <misc@dartlang.org>"
homepage: https://github.com/dart-lang/glob
description: Bash-style filename globbing.
dependencies:
- async: "^1.2.0"
- collection: ">=1.1.0 <2.0.0"
- path: ">=1.3.0 <2.0.0"
+ async: ">=1.2.0 <3.0.0"
+ collection: "^1.1.0"
+ path: "^1.3.0"
string_scanner: ">=0.1.0 <2.0.0"
dev_dependencies:
- test: ">=0.12.0 <0.13.0"
- scheduled_test: ">=0.12.0 <0.13.0"
+ test: "^0.12.0"
+ test_descriptor: "^1.0.0"
environment:
- sdk: ">=1.12.0 <2.0.0"
+ sdk: ">=1.23.0 <2.0.0"
diff --git a/packages/glob/test/list_test.dart b/packages/glob/test/list_test.dart
index d59e273..ee9814f 100644
--- a/packages/glob/test/list_test.dart
+++ b/packages/glob/test/list_test.dart
@@ -2,27 +2,21 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+@TestOn('vm')
import 'dart:async';
import 'dart:io';
import 'package:glob/glob.dart';
import 'package:glob/src/utils.dart';
import 'package:path/path.dart' as p;
-import 'package:scheduled_test/descriptor.dart' as d;
-import 'package:scheduled_test/scheduled_test.dart';
-
-String sandbox;
+import 'package:test/test.dart';
+import 'package:test_descriptor/test_descriptor.dart' as d;
void main() {
- setUp(() {
- scheduleSandbox();
-
- d.dir("foo", [
+ setUp(() async {
+ await d.dir("foo", [
d.file("bar"),
- d.dir("baz", [
- d.file("bang"),
- d.file("qux")
- ])
+ d.dir("baz", [d.file("bang"), d.file("qux")])
]).create();
});
@@ -31,11 +25,15 @@
expect(new Glob("*", context: p.url).list, throwsStateError);
});
- test("reports exceptions for non-existent directories", () {
- schedule(() {
- expect(new Glob("non/existent/**").list().toList(),
- throwsA(new isInstanceOf<FileSystemException>()));
- });
+ test("reports exceptions for non-existent case-sensitive directories", () {
+ expect(new Glob("non/existent/**", caseSensitive: true).list().toList(),
+ throwsA(new isInstanceOf<FileSystemException>()));
+ });
+
+ test("reports exceptions for non-existent case-insensitive directories",
+ () {
+ expect(new Glob("non/existent/**", caseSensitive: false).list().toList(),
+ throwsA(new isInstanceOf<FileSystemException>()));
});
});
@@ -44,335 +42,304 @@
expect(new Glob("*", context: p.url).listSync, throwsStateError);
});
- test("reports exceptions for non-existent directories", () {
- schedule(() {
- expect(new Glob("non/existent/**").listSync,
- throwsA(new isInstanceOf<FileSystemException>()));
- });
+ test("reports exceptions for non-existent case-sensitive directories", () {
+ expect(new Glob("non/existent/**", caseSensitive: true).listSync,
+ throwsA(new isInstanceOf<FileSystemException>()));
+ });
+
+ test("reports exceptions for non-existent case-insensitive directories",
+ () {
+ expect(new Glob("non/existent/**", caseSensitive: false).listSync,
+ throwsA(new isInstanceOf<FileSystemException>()));
});
});
group("when case-sensitive", () {
test("lists literals case-sensitively", () {
- schedule(() {
- expect(new Glob("foo/BAZ/qux", caseSensitive: true).listSync,
- throwsA(new isInstanceOf<FileSystemException>()));
- });
+ expect(new Glob("foo/BAZ/qux", caseSensitive: true).listSync,
+ throwsA(new isInstanceOf<FileSystemException>()));
});
test("lists ranges case-sensitively", () {
- schedule(() {
- expect(new Glob("foo/[BX][A-Z]z/qux", caseSensitive: true).listSync,
- throwsA(new isInstanceOf<FileSystemException>()));
- });
+ expect(new Glob("foo/[BX][A-Z]z/qux", caseSensitive: true).listSync,
+ throwsA(new isInstanceOf<FileSystemException>()));
});
test("options preserve case-sensitivity", () {
- schedule(() {
- expect(new Glob("foo/{BAZ,ZAP}/qux", caseSensitive: true).listSync,
- throwsA(new isInstanceOf<FileSystemException>()));
- });
+ expect(new Glob("foo/{BAZ,ZAP}/qux", caseSensitive: true).listSync,
+ throwsA(new isInstanceOf<FileSystemException>()));
});
});
- syncAndAsync((list) {
+ syncAndAsync((ListFn list) {
group("literals", () {
- test("lists a single literal", () {
- expect(list("foo/baz/qux"),
- completion(equals([p.join("foo", "baz", "qux")])));
+ test("lists a single literal", () async {
+ expect(
+ await list("foo/baz/qux"), equals([p.join("foo", "baz", "qux")]));
});
- test("lists a non-matching literal", () {
- expect(list("foo/baz/nothing"), completion(isEmpty));
+ test("lists a non-matching literal", () async {
+ expect(await list("foo/baz/nothing"), isEmpty);
});
});
group("star", () {
- test("lists within filenames but not across directories", () {
- expect(list("foo/b*"), completion(unorderedEquals([
- p.join("foo", "bar"),
- p.join("foo", "baz")
- ])));
+ test("lists within filenames but not across directories", () async {
+ expect(await list("foo/b*"),
+ unorderedEquals([p.join("foo", "bar"), p.join("foo", "baz")]));
});
- test("lists the empy string", () {
- expect(list("foo/bar*"), completion(equals([p.join("foo", "bar")])));
+ test("lists the empy string", () async {
+ expect(await list("foo/bar*"), equals([p.join("foo", "bar")]));
});
});
group("double star", () {
- test("lists within filenames", () {
- expect(list("foo/baz/**"), completion(unorderedEquals([
- p.join("foo", "baz", "qux"),
- p.join("foo", "baz", "bang")
- ])));
+ test("lists within filenames", () async {
+ expect(
+ await list("foo/baz/**"),
+ unorderedEquals(
+ [p.join("foo", "baz", "qux"), p.join("foo", "baz", "bang")]));
});
- test("lists the empty string", () {
- expect(list("foo/bar**"), completion(equals([p.join("foo", "bar")])));
+ test("lists the empty string", () async {
+ expect(await list("foo/bar**"), equals([p.join("foo", "bar")]));
});
- test("lists recursively", () {
- expect(list("foo/**"), completion(unorderedEquals([
- p.join("foo", "bar"),
- p.join("foo", "baz"),
- p.join("foo", "baz", "qux"),
- p.join("foo", "baz", "bang")
- ])));
+ test("lists recursively", () async {
+ expect(
+ await list("foo/**"),
+ unorderedEquals([
+ p.join("foo", "bar"),
+ p.join("foo", "baz"),
+ p.join("foo", "baz", "qux"),
+ p.join("foo", "baz", "bang")
+ ]));
});
- test("combines with literals", () {
- expect(list("foo/ba**"), completion(unorderedEquals([
- p.join("foo", "bar"),
- p.join("foo", "baz"),
- p.join("foo", "baz", "qux"),
- p.join("foo", "baz", "bang")
- ])));
+ test("combines with literals", () async {
+ expect(
+ await list("foo/ba**"),
+ unorderedEquals([
+ p.join("foo", "bar"),
+ p.join("foo", "baz"),
+ p.join("foo", "baz", "qux"),
+ p.join("foo", "baz", "bang")
+ ]));
});
- test("lists recursively in the middle of a glob", () {
- d.dir("deep", [
+ test("lists recursively in the middle of a glob", () async {
+ await d.dir("deep", [
d.dir("a", [
d.dir("b", [
- d.dir("c", [
- d.file("d"),
- d.file("long-file")
- ]),
+ d.dir("c", [d.file("d"), d.file("long-file")]),
d.dir("long-dir", [d.file("x")])
])
])
]).create();
- expect(list("deep/**/?/?"), completion(unorderedEquals([
- p.join("deep", "a", "b", "c"),
- p.join("deep", "a", "b", "c", "d")
- ])));
+ expect(
+ await list("deep/**/?/?"),
+ unorderedEquals([
+ p.join("deep", "a", "b", "c"),
+ p.join("deep", "a", "b", "c", "d")
+ ]));
});
});
group("any char", () {
- test("matches a character", () {
- expect(list("foo/ba?"), completion(unorderedEquals([
- p.join("foo", "bar"),
- p.join("foo", "baz")
- ])));
+ test("matches a character", () async {
+ expect(await list("foo/ba?"),
+ unorderedEquals([p.join("foo", "bar"), p.join("foo", "baz")]));
});
- test("doesn't match a separator", () {
- expect(list("foo?bar"), completion(isEmpty));
+ test("doesn't match a separator", () async {
+ expect(await list("foo?bar"), isEmpty);
});
});
group("range", () {
- test("matches a range of characters", () {
- expect(list("foo/ba[a-z]"), completion(unorderedEquals([
- p.join("foo", "bar"),
- p.join("foo", "baz")
- ])));
+ test("matches a range of characters", () async {
+ expect(await list("foo/ba[a-z]"),
+ unorderedEquals([p.join("foo", "bar"), p.join("foo", "baz")]));
});
- test("matches a specific list of characters", () {
- expect(list("foo/ba[rz]"), completion(unorderedEquals([
- p.join("foo", "bar"),
- p.join("foo", "baz")
- ])));
+ test("matches a specific list of characters", () async {
+ expect(await list("foo/ba[rz]"),
+ unorderedEquals([p.join("foo", "bar"), p.join("foo", "baz")]));
});
- test("doesn't match outside its range", () {
- expect(list("foo/ba[a-x]"),
- completion(unorderedEquals([p.join("foo", "bar")])));
+ test("doesn't match outside its range", () async {
+ expect(
+ await list("foo/ba[a-x]"), unorderedEquals([p.join("foo", "bar")]));
});
- test("doesn't match outside its specific list", () {
- expect(list("foo/ba[rx]"),
- completion(unorderedEquals([p.join("foo", "bar")])));
+ test("doesn't match outside its specific list", () async {
+ expect(
+ await list("foo/ba[rx]"), unorderedEquals([p.join("foo", "bar")]));
});
});
test("the same file shouldn't be non-recursively listed multiple times",
- () {
- d.dir("multi", [
+ () async {
+ await d.dir("multi", [
d.dir("start-end", [d.file("file")])
]).create();
- expect(list("multi/{start-*/f*,*-end/*e}"),
- completion(equals([p.join("multi", "start-end", "file")])));
+ expect(await list("multi/{start-*/f*,*-end/*e}"),
+ equals([p.join("multi", "start-end", "file")]));
});
- test("the same file shouldn't be recursively listed multiple times", () {
- d.dir("multi", [
+ test("the same file shouldn't be recursively listed multiple times",
+ () async {
+ await d.dir("multi", [
d.dir("a", [
d.dir("b", [
d.file("file"),
- d.dir("c", [
- d.file("file")
- ])
+ d.dir("c", [d.file("file")])
]),
d.dir("x", [
- d.dir("y", [
- d.file("file")
- ])
+ d.dir("y", [d.file("file")])
])
])
]).create();
- expect(list("multi/{*/*/*/file,a/**/file}"), completion(unorderedEquals([
- p.join("multi", "a", "b", "file"),
- p.join("multi", "a", "b", "c", "file"),
- p.join("multi", "a", "x", "y", "file")
- ])));
+ expect(
+ await list("multi/{*/*/*/file,a/**/file}"),
+ unorderedEquals([
+ p.join("multi", "a", "b", "file"),
+ p.join("multi", "a", "b", "c", "file"),
+ p.join("multi", "a", "x", "y", "file")
+ ]));
});
group("with symlinks", () {
- setUp(() {
- schedule(() {
- return new Link(p.join(sandbox, "dir", "link"))
- .create(p.join(sandbox, "foo", "baz"), recursive: true);
- }, "symlink foo/baz to dir/link");
+ setUp(() async {
+ await new Link(p.join(d.sandbox, "dir", "link"))
+ .create(p.join(d.sandbox, "foo", "baz"), recursive: true);
});
- test("follows symlinks by default", () {
- expect(list("dir/**"), completion(unorderedEquals([
- p.join("dir", "link"),
- p.join("dir", "link", "bang"),
- p.join("dir", "link", "qux")
- ])));
+ test("follows symlinks by default", () async {
+ expect(
+ await list("dir/**"),
+ unorderedEquals([
+ p.join("dir", "link"),
+ p.join("dir", "link", "bang"),
+ p.join("dir", "link", "qux")
+ ]));
});
- test("doesn't follow symlinks with followLinks: false", () {
- expect(list("dir/**", followLinks: false),
- completion(equals([p.join("dir", "link")])));
+ test("doesn't follow symlinks with followLinks: false", () async {
+ expect(await list("dir/**", followLinks: false),
+ equals([p.join("dir", "link")]));
});
- test("shouldn't crash on broken symlinks", () {
- schedule(() {
- return new Directory(p.join(sandbox, "foo")).delete(recursive: true);
- });
+ test("shouldn't crash on broken symlinks", () async {
+ await new Directory(p.join(d.sandbox, "foo")).delete(recursive: true);
- expect(list("dir/**"), completion(equals([p.join("dir", "link")])));
+ expect(await list("dir/**"), equals([p.join("dir", "link")]));
});
});
- test("always lists recursively with recursive: true", () {
- expect(list("foo", recursive: true), completion(unorderedEquals([
- "foo",
- p.join("foo", "bar"),
- p.join("foo", "baz"),
- p.join("foo", "baz", "qux"),
- p.join("foo", "baz", "bang")
- ])));
+ test("always lists recursively with recursive: true", () async {
+ expect(
+ await list("foo", recursive: true),
+ unorderedEquals([
+ "foo",
+ p.join("foo", "bar"),
+ p.join("foo", "baz"),
+ p.join("foo", "baz", "qux"),
+ p.join("foo", "baz", "bang")
+ ]));
});
- test("lists an absolute glob", () {
- expect(schedule(() {
- var pattern = separatorToForwardSlash(
- p.absolute(p.join(sandbox, 'foo/baz/**')));
+ test("lists an absolute glob", () async {
+ var pattern =
+ separatorToForwardSlash(p.absolute(p.join(d.sandbox, 'foo/baz/**')));
- return list(pattern);
- }), completion(unorderedEquals([
- p.join("foo", "baz", "bang"),
- p.join("foo", "baz", "qux")
- ])));
+ var result = await list(pattern);
+
+ expect(
+ result,
+ unorderedEquals(
+ [p.join("foo", "baz", "bang"), p.join("foo", "baz", "qux")]));
});
// Regression test for #4.
- test("lists an absolute case-insensitive glob", () {
- expect(schedule(() {
- var pattern = separatorToForwardSlash(
- p.absolute(p.join(sandbox, 'foo/Baz/**')));
+ test("lists an absolute case-insensitive glob", () async {
+ var pattern =
+ separatorToForwardSlash(p.absolute(p.join(d.sandbox, 'foo/Baz/**')));
- return list(pattern, caseSensitive: false);
- }), completion(unorderedEquals([
- p.join("foo", "baz", "bang"),
- p.join("foo", "baz", "qux")
- ])));
+ expect(
+ await list(pattern, caseSensitive: false),
+ unorderedEquals(
+ [p.join("foo", "baz", "bang"), p.join("foo", "baz", "qux")]));
});
- test("lists a subdirectory that sometimes exists", () {
- d.dir("top", [
+ test("lists a subdirectory that sometimes exists", () async {
+ await d.dir("top", [
d.dir("dir1", [
d.dir("subdir", [d.file("file")])
]),
d.dir("dir2", [])
]).create();
- expect(list("top/*/subdir/**"),
- completion(equals([p.join("top", "dir1", "subdir", "file")])));
+ expect(await list("top/*/subdir/**"),
+ equals([p.join("top", "dir1", "subdir", "file")]));
});
group("when case-insensitive", () {
- test("lists literals case-insensitively", () {
- expect(list("foo/baz/qux", caseSensitive: false),
- completion(equals([p.join("foo", "baz", "qux")])));
- expect(list("foo/BAZ/qux", caseSensitive: false),
- completion(equals([p.join("foo", "baz", "qux")])));
+ test("lists literals case-insensitively", () async {
+ expect(await list("foo/baz/qux", caseSensitive: false),
+ equals([p.join("foo", "baz", "qux")]));
+ expect(await list("foo/BAZ/qux", caseSensitive: false),
+ equals([p.join("foo", "baz", "qux")]));
});
- test("lists ranges case-insensitively", () {
- expect(list("foo/[bx][a-z]z/qux", caseSensitive: false),
- completion(equals([p.join("foo", "baz", "qux")])));
- expect(list("foo/[BX][A-Z]z/qux", caseSensitive: false),
- completion(equals([p.join("foo", "baz", "qux")])));
+ test("lists ranges case-insensitively", () async {
+ expect(await list("foo/[bx][a-z]z/qux", caseSensitive: false),
+ equals([p.join("foo", "baz", "qux")]));
+ expect(await list("foo/[BX][A-Z]z/qux", caseSensitive: false),
+ equals([p.join("foo", "baz", "qux")]));
});
- test("options preserve case-insensitivity", () {
- expect(list("foo/{bar,baz}/qux", caseSensitive: false),
- completion(equals([p.join("foo", "baz", "qux")])));
- expect(list("foo/{BAR,BAZ}/qux", caseSensitive: false),
- completion(equals([p.join("foo", "baz", "qux")])));
+ test("options preserve case-insensitivity", () async {
+ expect(await list("foo/{bar,baz}/qux", caseSensitive: false),
+ equals([p.join("foo", "baz", "qux")]));
+ expect(await list("foo/{BAR,BAZ}/qux", caseSensitive: false),
+ equals([p.join("foo", "baz", "qux")]));
});
});
});
}
-typedef Future<List<String>> ListFn(String glob,
+typedef FutureOr<List<String>> ListFn(String glob,
{bool recursive, bool followLinks, bool caseSensitive});
/// Runs [callback] in two groups with two values of [listFn]: one that uses
/// [Glob.list], one that uses [Glob.listSync].
-void syncAndAsync(callback(ListFn listFn)) {
+void syncAndAsync(FutureOr callback(ListFn listFn)) {
group("async", () {
callback((pattern, {recursive: false, followLinks: true, caseSensitive}) {
- return schedule(() {
- var glob = new Glob(pattern,
- recursive: recursive, caseSensitive: caseSensitive);
+ var glob =
+ new Glob(pattern, recursive: recursive, caseSensitive: caseSensitive);
- return glob
- .list(root: sandbox, followLinks: followLinks)
- .map((entity) => p.relative(entity.path, from: sandbox))
- .toList();
- }, 'listing $pattern');
+ return glob
+ .list(root: d.sandbox, followLinks: followLinks)
+ .map((entity) => p.relative(entity.path, from: d.sandbox))
+ .toList();
});
});
group("sync", () {
callback((pattern, {recursive: false, followLinks: true, caseSensitive}) {
- return schedule(() {
- var glob = new Glob(pattern,
- recursive: recursive, caseSensitive: caseSensitive);
+ var glob =
+ new Glob(pattern, recursive: recursive, caseSensitive: caseSensitive);
- return glob
- .listSync(root: sandbox, followLinks: followLinks)
- .map((entity) => p.relative(entity.path, from: sandbox))
- .toList();
- }, 'listing $pattern');
+ return glob
+ .listSync(root: d.sandbox, followLinks: followLinks)
+ .map((entity) => p.relative(entity.path, from: d.sandbox))
+ .toList();
});
});
}
-
-void scheduleSandbox() {
- schedule(() {
- return Directory.systemTemp.createTemp('glob_').then((dir) {
- sandbox = dir.path;
- d.defaultRoot = sandbox;
- });
- }, 'creating sandbox');
-
- currentSchedule.onComplete.schedule(() {
- d.defaultRoot = null;
- if (sandbox == null) return null;
- var oldSandbox = sandbox;
- sandbox = null;
- return new Directory(oldSandbox).delete(recursive: true);
- });
-}
diff --git a/packages/glob/test/match_test.dart b/packages/glob/test/match_test.dart
index 13dc7d6..50d6f13 100644
--- a/packages/glob/test/match_test.dart
+++ b/packages/glob/test/match_test.dart
@@ -11,8 +11,9 @@
"GHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~";
// URL-encode the path for a URL context.
-final asciiWithoutSlash = p.style == p.Style.url ?
- Uri.encodeFull(RAW_ASCII_WITHOUT_SLASH) : RAW_ASCII_WITHOUT_SLASH;
+final asciiWithoutSlash = p.style == p.Style.url
+ ? Uri.encodeFull(RAW_ASCII_WITHOUT_SLASH)
+ : RAW_ASCII_WITHOUT_SLASH;
void main() {
test("literals match exactly", () {
@@ -22,8 +23,8 @@
});
test("backslashes match nothing on Windows", () {
- expect(r"foo\bar",
- isNot(contains(new Glob(r"foo\\bar", context: p.windows))));
+ expect(
+ r"foo\bar", isNot(contains(new Glob(r"foo\\bar", context: p.windows))));
});
group("star", () {
@@ -237,7 +238,7 @@
test("a relative path can be matched by an absolute glob", () {
var pattern = separatorToForwardSlash(p.absolute('foo/bar'));
expect('foo/bar', contains(new Glob(pattern)));
- });
+ }, testOn: 'vm');
group("with recursive: true", () {
var glob = new Glob("foo/bar", recursive: true);
@@ -270,20 +271,20 @@
expect(r"\\foo\bar\baz",
contains(new Glob("//foo/bar/baz", context: p.windows)));
- expect(r"\\foo\bar\baz",
- isNot(contains(new Glob("**", context: p.windows))));
+ expect(
+ r"\\foo\bar\baz", isNot(contains(new Glob("**", context: p.windows))));
expect(r"\\foo\bar\baz", contains(new Glob("//**", context: p.windows)));
- expect(r"\\foo\bar\baz",
- contains(new Glob("//foo/**", context: p.windows)));
+ expect(
+ r"\\foo\bar\baz", contains(new Glob("//foo/**", context: p.windows)));
});
test("absolute URL paths", () {
expect(r"http://foo.com/bar",
contains(new Glob("http://foo.com/bar", context: p.url)));
- expect(r"http://foo.com/bar",
- isNot(contains(new Glob("**", context: p.url))));
- expect(r"http://foo.com/bar",
- contains(new Glob("http://**", context: p.url)));
+ expect(
+ r"http://foo.com/bar", isNot(contains(new Glob("**", context: p.url))));
+ expect(
+ r"http://foo.com/bar", contains(new Glob("http://**", context: p.url)));
expect(r"http://foo.com/bar",
contains(new Glob("http://foo.com/**", context: p.url)));
@@ -301,26 +302,26 @@
test("ranges match case-sensitively", () {
expect("foo", contains(new Glob("[fx][a-z]o", caseSensitive: true)));
- expect("FOO",
- isNot(contains(new Glob("[fx][a-z]o", caseSensitive: true))));
- expect("foo",
- isNot(contains(new Glob("[FX][A-Z]O", caseSensitive: true))));
+ expect(
+ "FOO", isNot(contains(new Glob("[fx][a-z]o", caseSensitive: true))));
+ expect(
+ "foo", isNot(contains(new Glob("[FX][A-Z]O", caseSensitive: true))));
});
test("sequences preserve case-sensitivity", () {
expect("foo/bar", contains(new Glob("foo/bar", caseSensitive: true)));
- expect("FOO/BAR",
- isNot(contains(new Glob("foo/bar", caseSensitive: true))));
- expect("foo/bar",
- isNot(contains(new Glob("FOO/BAR", caseSensitive: true))));
+ expect(
+ "FOO/BAR", isNot(contains(new Glob("foo/bar", caseSensitive: true))));
+ expect(
+ "foo/bar", isNot(contains(new Glob("FOO/BAR", caseSensitive: true))));
});
test("options preserve case-sensitivity", () {
expect("foo", contains(new Glob("{foo,bar}", caseSensitive: true)));
- expect("FOO",
- isNot(contains(new Glob("{foo,bar}", caseSensitive: true))));
- expect("foo",
- isNot(contains(new Glob("{FOO,BAR}", caseSensitive: true))));
+ expect(
+ "FOO", isNot(contains(new Glob("{foo,bar}", caseSensitive: true))));
+ expect(
+ "foo", isNot(contains(new Glob("{FOO,BAR}", caseSensitive: true))));
});
});
diff --git a/packages/initialize/CHANGELOG.md b/packages/initialize/CHANGELOG.md
index 3c7d38e..3f39873 100644
--- a/packages/initialize/CHANGELOG.md
+++ b/packages/initialize/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.6.2+7
+
+* Strong mode fixes.
+
## 0.6.2+6
* Small bug fixes for https://github.com/dart-lang/web-components/issues/54.
diff --git a/packages/initialize/lib/build/initializer_plugin.dart b/packages/initialize/lib/build/initializer_plugin.dart
index f049df0..1a004dd 100644
--- a/packages/initialize/lib/build/initializer_plugin.dart
+++ b/packages/initialize/lib/build/initializer_plugin.dart
@@ -235,7 +235,7 @@
buffer.write(_evaluateExpression(expression, pluginData));
} else {
libraryPrefixes.putIfAbsent(
- element.library, () => 'i${libraryPrefixes.length}');
+ element.library, () => 'i${libraryPrefixes.length}');
buffer.write('${libraryPrefixes[element.library]}.');
if (element is ClassElement) {
@@ -263,8 +263,7 @@
return buffer.toString();
}
- _evaluateExpression(
- Expression expression, InitializerPluginData pluginData) {
+ _evaluateExpression(Expression expression, InitializerPluginData pluginData) {
var logger = pluginData.logger;
var result = pluginData.resolver.evaluateConstant(
pluginData.initializer.targetElement.library, expression);
@@ -302,9 +301,9 @@
object.toIntValue() ??
object.toStringValue();
if (value == null) {
- value = object.toListValue();
- if (value != null) {
- return value.map((DartObject element) => _getValue(element)).toList();
+ List list = object.toListValue();
+ if (list != null) {
+ return list.map((DartObject element) => _getValue(element)).toList();
}
Map<DartObject, DartObject> map = object.toMapValue();
if (map != null) {
diff --git a/packages/initialize/lib/src/init_method.dart b/packages/initialize/lib/src/init_method.dart
index ebc8f93..1ddb83c 100644
--- a/packages/initialize/lib/src/init_method.dart
+++ b/packages/initialize/lib/src/init_method.dart
@@ -8,6 +8,7 @@
/// it shouldn't be used directly in annotations, instead use the `initMethod`
/// singleton below.
typedef dynamic _ZeroArg();
+
class _InitMethod implements Initializer<_ZeroArg> {
const _InitMethod();
diff --git a/packages/initialize/lib/src/initializer.dart b/packages/initialize/lib/src/initializer.dart
index 60a04d5..1b9f32f 100644
--- a/packages/initialize/lib/src/initializer.dart
+++ b/packages/initialize/lib/src/initializer.dart
@@ -41,8 +41,11 @@
const LibraryIdentifier(this.name, this.package, this.path);
- bool operator ==(LibraryIdentifier other) =>
- name == other.name && package == other.package && path == other.path;
+ bool operator ==(dynamic other) =>
+ other is LibraryIdentifier &&
+ name == other.name &&
+ package == other.package &&
+ path == other.path;
String toString() => '$name: $package:$path';
}
diff --git a/packages/initialize/lib/src/mirror_loader.dart b/packages/initialize/lib/src/mirror_loader.dart
index 11722c1..95da50d 100644
--- a/packages/initialize/lib/src/mirror_loader.dart
+++ b/packages/initialize/lib/src/mirror_loader.dart
@@ -8,8 +8,8 @@
import 'package:path/path.dart' as path;
import 'package:initialize/initialize.dart';
-final _root = currentMirrorSystem().isolate.rootLibrary;
-final _libs = currentMirrorSystem().libraries;
+final LibraryMirror _root = currentMirrorSystem().isolate.rootLibrary;
+final Map<Uri, LibraryMirror> _libs = currentMirrorSystem().libraries;
Queue<Function> loadInitializers(
{List<Type> typeFilter, InitializerFilter customFilter, Uri from}) {
@@ -37,9 +37,7 @@
/// Note: The [from] argument is only supported in the mirror_loader.dart. It
/// is not supported statically.
InitializationCrawler(this.typeFilter, this.customFilter, {Uri from})
- : _rootLibrary = from == null
- ? _root
- : _libs[from] {
+ : _rootLibrary = from == null ? _root : _libs[from] {
if (_rootLibrary == null) throw 'Unable to find library at $from.';
}
@@ -124,10 +122,14 @@
Iterable<DeclarationMirror> _sortedDeclarationsWithMetadata(
LibraryMirror lib) {
return new List()
- ..addAll(_sortDeclarations(lib, lib.declarations.values
- .where((d) => d is MethodMirror && d.metadata.isNotEmpty)))
- ..addAll(_sortDeclarations(lib, lib.declarations.values
- .where((d) => d is ClassMirror && d.metadata.isNotEmpty)));
+ ..addAll(_sortDeclarations(
+ lib,
+ lib.declarations.values
+ .where((d) => d is MethodMirror && d.metadata.isNotEmpty)))
+ ..addAll(_sortDeclarations(
+ lib,
+ lib.declarations.values
+ .where((d) => d is ClassMirror && d.metadata.isNotEmpty)));
}
List<DeclarationMirror> _sortDeclarations(
@@ -202,7 +204,8 @@
throw _TOP_LEVEL_FUNCTIONS_ONLY;
}
annotatedValue = (declaration.owner as ObjectMirror)
- .getField(declaration.simpleName).reflectee;
+ .getField(declaration.simpleName)
+ .reflectee;
} else if (declaration is LibraryMirror) {
var package;
var filePath;
diff --git a/packages/initialize/lib/transformer.dart b/packages/initialize/lib/transformer.dart
index 34acd4a..06ae76e 100644
--- a/packages/initialize/lib/transformer.dart
+++ b/packages/initialize/lib/transformer.dart
@@ -129,8 +129,7 @@
// [entryPoint].
void _replaceEntryWithBootstrap(Transform transform, dom.Document document,
AssetId entryPoint, AssetId originalDartFile, AssetId newDartFile) {
- var scripts = _getScripts(document)
- .where((script) {
+ var scripts = _getScripts(document).where((script) {
var assetId = uriToAssetId(entryPoint, _getScriptAttribute(script),
transform.logger, script.sourceSpan);
return assetId == originalDartFile;
@@ -258,6 +257,7 @@
'(possibly transitive).');
}
}
+
readSuperClassAnnotations(clazz.supertype);
_readAnnotations(clazz);
}
@@ -271,9 +271,9 @@
var metaNodes;
var node = element.computeNode();
if (node is SimpleIdentifier && node.parent is LibraryIdentifier) {
- metaNodes = node.parent.parent.metadata;
+ metaNodes = (node.parent.parent as AnnotatedNode).metadata;
} else if (node is ClassDeclaration || node is FunctionDeclaration) {
- metaNodes = node.metadata;
+ metaNodes = (node as AnnotatedNode).metadata;
} else {
return found;
}
@@ -283,7 +283,10 @@
var meta = metaNode.elementAnnotation;
var e = meta.element;
if (e is PropertyAccessorElement) {
- return _isInitializer(e.variable.evaluationResult.value.type);
+ // 'as dynamic' is because evaluationResult is a property on an impl class, e.g. one that
+ // isn't supposed to be used externally.
+ return _isInitializer(
+ (e.variable as dynamic).evaluationResult.value.type);
} else if (e is ConstructorElement) {
return _isInitializer(e.returnType);
}
diff --git a/packages/initialize/pubspec.yaml b/packages/initialize/pubspec.yaml
index 887267f..f2f354a 100644
--- a/packages/initialize/pubspec.yaml
+++ b/packages/initialize/pubspec.yaml
@@ -1,5 +1,5 @@
name: initialize
-version: 0.6.2+6
+version: 0.6.2+7
author: Polymer.dart Authors <web@dartlang.org>
description: Generic building blocks for doing static initialization.
homepage: https://github.com/dart-lang/initialize
diff --git a/packages/initialize/test/deferred_library_test.dart b/packages/initialize/test/deferred_library_test.dart
index 0bff187..e38542c 100644
--- a/packages/initialize/test/deferred_library_test.dart
+++ b/packages/initialize/test/deferred_library_test.dart
@@ -24,6 +24,7 @@
expect(InitializeTracker.seen.length, 5);
});
});
- }, skip: 'Should be skipped only in pub-serve mode, blocked on '
- 'https://github.com/dart-lang/test/issues/388.');
+ },
+ skip: 'Should be skipped only in pub-serve mode, blocked on '
+ 'https://github.com/dart-lang/test/issues/388.');
}
diff --git a/packages/initialize/test/initializer_custom_filter_test.dart b/packages/initialize/test/initializer_custom_filter_test.dart
index 302db1b..1911ee3 100644
--- a/packages/initialize/test/initializer_custom_filter_test.dart
+++ b/packages/initialize/test/initializer_custom_filter_test.dart
@@ -15,26 +15,34 @@
main() {
test('filter option limits which types of annotations will be ran', () {
var originalSize;
- return runPhase(1).then((_) {
- // Even though Baz extends Bar, only Baz should be run.
- expect(InitializeTracker.seen, [Baz]);
- }).then((_) => runPhase(2)).then((_) {
- expect(InitializeTracker.seen, [Baz, foo]);
- }).then((_) => runPhase(3)).then((_) {
- expect(InitializeTracker.seen, [Baz, foo, Foo]);
- }).then((_) => runPhase(4)).then((_) {
- expect(InitializeTracker.seen, [Baz, foo, Foo, Bar]);
- }).then((_) {
- originalSize = InitializeTracker.seen.length;
- })
+ return runPhase(1)
+ .then((_) {
+ // Even though Baz extends Bar, only Baz should be run.
+ expect(InitializeTracker.seen, [Baz]);
+ })
+ .then((_) => runPhase(2))
+ .then((_) {
+ expect(InitializeTracker.seen, [Baz, foo]);
+ })
+ .then((_) => runPhase(3))
+ .then((_) {
+ expect(InitializeTracker.seen, [Baz, foo, Foo]);
+ })
+ .then((_) => runPhase(4))
+ .then((_) {
+ expect(InitializeTracker.seen, [Baz, foo, Foo, Bar]);
+ })
+ .then((_) {
+ originalSize = InitializeTracker.seen.length;
+ })
.then((_) => runPhase(1))
.then((_) => runPhase(2))
.then((_) => runPhase(3))
.then((_) => runPhase(4))
.then((_) => run())
.then((_) {
- expect(InitializeTracker.seen.length, originalSize);
- });
+ expect(InitializeTracker.seen.length, originalSize);
+ });
});
}
diff --git a/packages/initialize/test/initializer_cycle_error_test.dart b/packages/initialize/test/initializer_cycle_error_test.dart
index 365e64f..200a8ec 100644
--- a/packages/initialize/test/initializer_cycle_error_test.dart
+++ b/packages/initialize/test/initializer_cycle_error_test.dart
@@ -15,6 +15,7 @@
main() {
test('super class cycles are not supported', () {
expect(run, throwsUnsupportedError);
- }, skip: 'Should be skipped only in pub-serve mode, blocked on '
- 'https://github.com/dart-lang/test/issues/388.');
+ },
+ skip: 'Should be skipped only in pub-serve mode, blocked on '
+ 'https://github.com/dart-lang/test/issues/388.');
}
diff --git a/packages/initialize/test/initializer_from_test.dart b/packages/initialize/test/initializer_from_test.dart
index aa7172b..74449a6 100644
--- a/packages/initialize/test/initializer_from_test.dart
+++ b/packages/initialize/test/initializer_from_test.dart
@@ -29,11 +29,12 @@
expect(InitializeTracker.seen.length, 2);
// Don't know what the path will be, so have to explicitly check fields
// and use an [endsWith] matcher for the path.
- expect(InitializeTracker.seen[1].name,
- #initialize.test.initializer_from_test);
+ expect(
+ InitializeTracker.seen[1].name, #initialize.test.initializer_from_test);
expect(InitializeTracker.seen[1].package, isNull);
expect(
InitializeTracker.seen[1].path, endsWith('initializer_from_test.dart'));
- }, skip: 'Should be skipped only in pub-serve mode, blocked on '
- 'https://github.com/dart-lang/test/issues/388.');
+ },
+ skip: 'Should be skipped only in pub-serve mode, blocked on '
+ 'https://github.com/dart-lang/test/issues/388.');
}
diff --git a/packages/initialize/test/initializer_super_test.dart b/packages/initialize/test/initializer_super_test.dart
index 512ef51..430d796 100644
--- a/packages/initialize/test/initializer_super_test.dart
+++ b/packages/initialize/test/initializer_super_test.dart
@@ -15,7 +15,13 @@
// Run all initializers.
return run().then((_) {
test('annotations are seen in post-order with superclasses first', () {
- var expectedNames = [A, C, B, E, D,];
+ var expectedNames = [
+ A,
+ C,
+ B,
+ E,
+ D,
+ ];
expect(InitializeTracker.seen, expectedNames);
});
});
diff --git a/packages/initialize/test/initializer_type_filter_test.dart b/packages/initialize/test/initializer_type_filter_test.dart
index 87e0196..1cd57d3 100644
--- a/packages/initialize/test/initializer_type_filter_test.dart
+++ b/packages/initialize/test/initializer_type_filter_test.dart
@@ -20,16 +20,23 @@
});
test('filter option limits which types of annotations will be ran', () {
- return run(typeFilter: const [_Adder]).then((_) {
- expect(total, 2);
- }).then((_) => run(typeFilter: const [_Subtractor])).then((_) {
- expect(total, 0);
- }).then((_) => run(typeFilter: const [_Adder])).then((_) {
- // Sanity check, future calls should be no-ops
- expect(total, 0);
- }).then((_) => run(typeFilter: const [_Subtractor])).then((_) {
- expect(total, 0);
- });
+ return run(typeFilter: const [_Adder])
+ .then((_) {
+ expect(total, 2);
+ })
+ .then((_) => run(typeFilter: const [_Subtractor]))
+ .then((_) {
+ expect(total, 0);
+ })
+ .then((_) => run(typeFilter: const [_Adder]))
+ .then((_) {
+ // Sanity check, future calls should be no-ops
+ expect(total, 0);
+ })
+ .then((_) => run(typeFilter: const [_Subtractor]))
+ .then((_) {
+ expect(total, 0);
+ });
});
}
@@ -48,6 +55,7 @@
@override
initialize(_) => total++;
}
+
const adder = const _Adder();
// Initializer that decrements `total` by one.
@@ -57,4 +65,5 @@
@override
initialize(_) => total--;
}
+
const subtractor = const _Subtractor();
diff --git a/packages/initialize/test/transformer_test.dart b/packages/initialize/test/transformer_test.dart
index 8342c03..c8e017f 100644
--- a/packages/initialize/test/transformer_test.dart
+++ b/packages/initialize/test/transformer_test.dart
@@ -19,14 +19,19 @@
}
void htmlEntryPointTests() {
- var phases = [[new InitializeTransformer(['web/*.html'])]];
+ var phases = [
+ [
+ new InitializeTransformer(['web/*.html'])
+ ]
+ ];
testPhases('basic', phases, {
'a|web/index.html': '''
<html><head></head><body>
<script type="application/dart" src="index.dart"></script>
</body></html>
- '''.replaceAll(' ', ''),
+ '''
+ .replaceAll(' ', ''),
'a|web/index.dart': '''
library web_foo;
@@ -77,7 +82,8 @@
<html><head></head><body>
<script type="application/dart" src="index.initialize.dart"></script>
- </body></html>'''.replaceAll(' ', ''),
+ </body></html>'''
+ .replaceAll(' ', ''),
'a|web/index.initialize.dart': formatter.format('''
import 'package:initialize/src/static_loader.dart';
import 'package:initialize/initialize.dart';
@@ -109,7 +115,11 @@
}
void dartEntryPointTests() {
- var phases = [[new InitializeTransformer(['web/index.dart'])]];
+ var phases = [
+ [
+ new InitializeTransformer(['web/index.dart'])
+ ]
+ ];
testPhases('constructor arguments', phases, {
'a|web/index.dart': '''
diff --git a/packages/initialize/tool/all_tests.sh b/packages/initialize/tool/all_tests.sh
index 312cda2..d5c23c1 100755
--- a/packages/initialize/tool/all_tests.sh
+++ b/packages/initialize/tool/all_tests.sh
@@ -7,6 +7,8 @@
# Fast fail the script on failures.
set -e
+dartanalyzer --fatal-warnings lib/initialize.dart lib/transformer.dart
+
# Run the un-transformed command-line tests.
dart test/deferred_library_test.dart
dart test/init_method_test.dart
diff --git a/packages/matcher/.analysis_options b/packages/matcher/.analysis_options
deleted file mode 100644
index a10d4c5..0000000
--- a/packages/matcher/.analysis_options
+++ /dev/null
@@ -1,2 +0,0 @@
-analyzer:
- strong-mode: true
diff --git a/packages/matcher/CHANGELOG.md b/packages/matcher/CHANGELOG.md
index f36f40d..d6fe1c6 100644
--- a/packages/matcher/CHANGELOG.md
+++ b/packages/matcher/CHANGELOG.md
@@ -1,3 +1,23 @@
+## 0.12.1+4
+
+* Fixed SDK constraint to allow edge builds.
+
+## 0.12.1+3
+
+* Make `predicate` and `pairwiseCompare` generic methods to allow typed
+ functions to be passed to them as arguments.
+
+* Make internal implementations take better advantage of type promotion to avoid
+ dynamic call overhead.
+
+## 0.12.1+2
+
+* Fixed small documentation issues.
+
+* Fixed small issue in `StringEqualsMatcher`.
+
+* Update to support future Dart language changes.
+
## 0.12.1+1
* Produce a better error message when a `CustomMatcher`'s feature throws.
diff --git a/packages/matcher/lib/src/core_matchers.dart b/packages/matcher/lib/src/core_matchers.dart
index 94f9d7d..e8fdb11 100644
--- a/packages/matcher/lib/src/core_matchers.dart
+++ b/packages/matcher/lib/src/core_matchers.dart
@@ -110,60 +110,70 @@
? new _StringEqualsMatcher(expected)
: new _DeepMatcher(expected, limit);
+typedef _RecursiveMatcher = List<String> Function(
+ dynamic, dynamic, String, int);
+
class _DeepMatcher extends Matcher {
final _expected;
final int _limit;
- var count;
_DeepMatcher(this._expected, [int limit = 1000]) : this._limit = limit;
// Returns a pair (reason, location)
- List _compareIterables(expected, actual, matcher, depth, location) {
- if (actual is! Iterable) return ['is not Iterable', location];
+ List<String> _compareIterables(Iterable expected, Object actual,
+ _RecursiveMatcher matcher, int depth, String location) {
+ if (actual is Iterable) {
+ var expectedIterator = expected.iterator;
+ var actualIterator = actual.iterator;
+ for (var index = 0;; index++) {
+ // Advance in lockstep.
+ var expectedNext = expectedIterator.moveNext();
+ var actualNext = actualIterator.moveNext();
- var expectedIterator = expected.iterator;
- var actualIterator = actual.iterator;
- for (var index = 0;; index++) {
- // Advance in lockstep.
- var expectedNext = expectedIterator.moveNext();
- var actualNext = actualIterator.moveNext();
+ // If we reached the end of both, we succeeded.
+ if (!expectedNext && !actualNext) return null;
- // If we reached the end of both, we succeeded.
- if (!expectedNext && !actualNext) return null;
+ // Fail if their lengths are different.
+ var newLocation = '$location[$index]';
+ if (!expectedNext) return ['longer than expected', newLocation];
+ if (!actualNext) return ['shorter than expected', newLocation];
- // Fail if their lengths are different.
- var newLocation = '${location}[${index}]';
- if (!expectedNext) return ['longer than expected', newLocation];
- if (!actualNext) return ['shorter than expected', newLocation];
-
- // Match the elements.
- var rp = matcher(
- expectedIterator.current, actualIterator.current, newLocation, depth);
- if (rp != null) return rp;
- }
- }
-
- List _compareSets(Set expected, actual, matcher, depth, location) {
- if (actual is! Iterable) return ['is not Iterable', location];
- actual = actual.toSet();
-
- for (var expectedElement in expected) {
- if (actual.every((actualElement) =>
- matcher(expectedElement, actualElement, location, depth) != null)) {
- return ['does not contain $expectedElement', location];
+ // Match the elements.
+ var rp = matcher(expectedIterator.current, actualIterator.current,
+ newLocation, depth);
+ if (rp != null) return rp;
}
- }
-
- if (actual.length > expected.length) {
- return ['larger than expected', location];
- } else if (actual.length < expected.length) {
- return ['smaller than expected', location];
} else {
- return null;
+ return ['is not Iterable', location];
}
}
- List _recursiveMatch(expected, actual, String location, int depth) {
+ List<String> _compareSets(Set expected, Object actual,
+ _RecursiveMatcher matcher, int depth, String location) {
+ if (actual is Iterable) {
+ Set other = actual.toSet();
+
+ for (var expectedElement in expected) {
+ if (other.every((actualElement) =>
+ matcher(expectedElement, actualElement, location, depth) != null)) {
+ return ['does not contain $expectedElement', location];
+ }
+ }
+
+ if (other.length > expected.length) {
+ return ['larger than expected', location];
+ } else if (other.length < expected.length) {
+ return ['smaller than expected', location];
+ } else {
+ return null;
+ }
+ } else {
+ return ['is not Iterable', location];
+ }
+ }
+
+ List<String> _recursiveMatch(
+ Object expected, Object actual, String location, int depth) {
// If the expected value is a matcher, try to match it.
if (expected is Matcher) {
var matchState = {};
@@ -194,17 +204,16 @@
expected, actual, _recursiveMatch, depth + 1, location);
} else if (expected is Map) {
if (actual is! Map) return ['expected a map', location];
-
- var err = (expected.length == actual.length)
- ? ''
- : 'has different length and ';
+ var map = (actual as Map);
+ var err =
+ (expected.length == map.length) ? '' : 'has different length and ';
for (var key in expected.keys) {
- if (!actual.containsKey(key)) {
+ if (!map.containsKey(key)) {
return ["${err}is missing map key '$key'", location];
}
}
- for (var key in actual.keys) {
+ for (var key in map.keys) {
if (!expected.containsKey(key)) {
return ["${err}has extra map key '$key'", location];
}
@@ -212,7 +221,7 @@
for (var key in expected.keys) {
var rp = _recursiveMatch(
- expected[key], actual[key], "${location}['${key}']", depth + 1);
+ expected[key], map[key], "$location['$key']", depth + 1);
if (rp != null) return rp;
}
@@ -240,7 +249,7 @@
String _match(expected, actual, Map matchState) {
var rp = _recursiveMatch(expected, actual, '', 0);
if (rp == null) return null;
- var reason;
+ String reason;
if (rp[0].length > 0) {
if (rp[1].length > 0) {
reason = "${rp[0]} at location ${rp[1]}";
@@ -330,7 +339,7 @@
buff.write('^\n Differ at offset $start');
}
- return mismatchDescription.replace(buff.toString());
+ return mismatchDescription.add(buff.toString());
}
}
@@ -568,18 +577,19 @@
/// For example:
///
/// expect(v, predicate((x) => ((x % 2) == 0), "is even"))
-Matcher predicate(bool f(value), [String description = 'satisfies function']) =>
+Matcher predicate<T>(bool f(T value),
+ [String description = 'satisfies function']) =>
new _Predicate(f, description);
-typedef bool _PredicateFunction(value);
+typedef bool _PredicateFunction<T>(T value);
-class _Predicate extends Matcher {
- final _PredicateFunction _matcher;
+class _Predicate<T> extends Matcher {
+ final _PredicateFunction<T> _matcher;
final String _description;
- const _Predicate(this._matcher, this._description);
+ _Predicate(this._matcher, this._description);
- bool matches(item, Map matchState) => _matcher(item);
+ bool matches(item, Map matchState) => _matcher(item as T);
Description describe(Description description) =>
description.add(_description);
@@ -595,15 +605,18 @@
/// have a Widget class where each Widget has a price; we could make a
/// [CustomMatcher] that can make assertions about prices with:
///
-/// class HasPrice extends CustomMatcher {
-/// const HasPrice(matcher) :
-/// super("Widget with price that is", "price", matcher);
-/// featureValueOf(actual) => actual.price;
-/// }
+/// ```dart
+/// class HasPrice extends CustomMatcher {
+/// HasPrice(matcher) : super("Widget with price that is", "price", matcher);
+/// featureValueOf(actual) => actual.price;
+/// }
+/// ```
///
/// and then use this for example like:
///
-/// expect(inventoryItem, new HasPrice(greaterThan(0)));
+/// ```dart
+/// expect(inventoryItem, new HasPrice(greaterThan(0)));
+/// ```
class CustomMatcher extends Matcher {
final String _featureDescription;
final String _featureName;
diff --git a/packages/matcher/lib/src/interfaces.dart b/packages/matcher/lib/src/interfaces.dart
index 1c8091e..6ab0f14 100644
--- a/packages/matcher/lib/src/interfaces.dart
+++ b/packages/matcher/lib/src/interfaces.dart
@@ -28,6 +28,7 @@
}
/// [expect] Matchers must implement/extend the Matcher class.
+///
/// The base Matcher class has a generic implementation of [describeMismatch]
/// so this does not need to be provided unless a more clear description is
/// required. The other two methods ([matches] and [describe])
@@ -48,7 +49,7 @@
/// is the value that was tested by [matches]; [matchState] is
/// the [Map] that was passed to and supplemented by [matches]
/// with additional information about the mismatch, and [mismatchDescription]
- /// is the [Description] that is being built to decribe the mismatch.
+ /// is the [Description] that is being built to describe the mismatch.
/// A few matchers make use of the [verbose] flag to provide detailed
/// information that is not typically included but can be of help in
/// diagnosing failures, such as stack traces.
diff --git a/packages/matcher/lib/src/iterable_matchers.dart b/packages/matcher/lib/src/iterable_matchers.dart
index 9159104..759c252 100644
--- a/packages/matcher/lib/src/iterable_matchers.dart
+++ b/packages/matcher/lib/src/iterable_matchers.dart
@@ -14,7 +14,7 @@
class _EveryElement extends _IterableMatcher {
final Matcher _matcher;
- _EveryElement(Matcher this._matcher);
+ _EveryElement(this._matcher);
bool matches(item, Map matchState) {
if (item is! Iterable) {
@@ -155,42 +155,45 @@
: _expected = expected.map(wrapMatcher).toList();
String _test(item) {
- if (item is! Iterable) return 'not iterable';
- item = item.toList();
+ if (item is Iterable) {
+ var list = item.toList();
- // Check the lengths are the same.
- if (_expected.length > item.length) {
- return 'has too few elements (${item.length} < ${_expected.length})';
- } else if (_expected.length < item.length) {
- return 'has too many elements (${item.length} > ${_expected.length})';
- }
+ // Check the lengths are the same.
+ if (_expected.length > list.length) {
+ return 'has too few elements (${list.length} < ${_expected.length})';
+ } else if (_expected.length < list.length) {
+ return 'has too many elements (${list.length} > ${_expected.length})';
+ }
- var matched = new List<bool>.filled(item.length, false);
- var expectedPosition = 0;
- for (var expectedMatcher in _expected) {
- var actualPosition = 0;
- var gotMatch = false;
- for (var actualElement in item) {
- if (!matched[actualPosition]) {
- if (expectedMatcher.matches(actualElement, {})) {
- matched[actualPosition] = gotMatch = true;
- break;
+ var matched = new List<bool>.filled(list.length, false);
+ var expectedPosition = 0;
+ for (var expectedMatcher in _expected) {
+ var actualPosition = 0;
+ var gotMatch = false;
+ for (var actualElement in list) {
+ if (!matched[actualPosition]) {
+ if (expectedMatcher.matches(actualElement, {})) {
+ matched[actualPosition] = gotMatch = true;
+ break;
+ }
}
+ ++actualPosition;
}
- ++actualPosition;
- }
- if (!gotMatch) {
- return new StringDescription()
- .add('has no match for ')
- .addDescriptionOf(expectedMatcher)
- .add(' at index ${expectedPosition}')
- .toString();
- }
+ if (!gotMatch) {
+ return new StringDescription()
+ .add('has no match for ')
+ .addDescriptionOf(expectedMatcher)
+ .add(' at index $expectedPosition')
+ .toString();
+ }
- ++expectedPosition;
+ ++expectedPosition;
+ }
+ return null;
+ } else {
+ return 'not iterable';
}
- return null;
}
bool matches(item, Map mismatchState) => _test(item) == null;
@@ -210,34 +213,37 @@
/// The [comparator] function, taking an expected and an actual argument, and
/// returning whether they match, will be applied to each pair in order.
/// [description] should be a meaningful name for the comparator.
-Matcher pairwiseCompare(
- Iterable expected, bool comparator(a, b), String description) =>
+Matcher pairwiseCompare<S, T>(
+ Iterable<S> expected, bool comparator(S a, T b), String description) =>
new _PairwiseCompare(expected, comparator, description);
-typedef bool _Comparator(a, b);
+typedef bool _Comparator<S, T>(S a, T b);
-class _PairwiseCompare extends _IterableMatcher {
- final Iterable _expected;
- final _Comparator _comparator;
+class _PairwiseCompare<S, T> extends _IterableMatcher {
+ final Iterable<S> _expected;
+ final _Comparator<S, T> _comparator;
final String _description;
_PairwiseCompare(this._expected, this._comparator, this._description);
bool matches(item, Map matchState) {
- if (item is! Iterable) return false;
- if (item.length != _expected.length) return false;
- var iterator = item.iterator;
- var i = 0;
- for (var e in _expected) {
- iterator.moveNext();
- if (!_comparator(e, iterator.current)) {
- addStateInfo(matchState,
- {'index': i, 'expected': e, 'actual': iterator.current});
- return false;
+ if (item is Iterable) {
+ if (item.length != _expected.length) return false;
+ var iterator = item.iterator;
+ var i = 0;
+ for (var e in _expected) {
+ iterator.moveNext();
+ if (!_comparator(e, iterator.current)) {
+ addStateInfo(matchState,
+ {'index': i, 'expected': e, 'actual': iterator.current});
+ return false;
+ }
+ i++;
}
- i++;
+ return true;
+ } else {
+ return false;
}
- return true;
}
Description describe(Description description) =>
diff --git a/packages/matcher/lib/src/map_matchers.dart b/packages/matcher/lib/src/map_matchers.dart
index a44148f..47cddef 100644
--- a/packages/matcher/lib/src/map_matchers.dart
+++ b/packages/matcher/lib/src/map_matchers.dart
@@ -27,7 +27,7 @@
final _key;
final Matcher _valueMatcher;
- const _ContainsMapping(this._key, Matcher this._valueMatcher);
+ const _ContainsMapping(this._key, this._valueMatcher);
bool matches(item, Map matchState) =>
item.containsKey(_key) && _valueMatcher.matches(item[_key], matchState);
diff --git a/packages/matcher/lib/src/numeric_matchers.dart b/packages/matcher/lib/src/numeric_matchers.dart
index e8651de..c405391 100644
--- a/packages/matcher/lib/src/numeric_matchers.dart
+++ b/packages/matcher/lib/src/numeric_matchers.dart
@@ -17,11 +17,13 @@
const _IsCloseTo(this._value, this._delta);
bool matches(item, Map matchState) {
- if (item is! num) return false;
-
- var diff = item - _value;
- if (diff < 0) diff = -diff;
- return (diff <= _delta);
+ if (item is num) {
+ var diff = item - _value;
+ if (diff < 0) diff = -diff;
+ return (diff <= _delta);
+ } else {
+ return false;
+ }
}
Description describe(Description description) => description
@@ -32,12 +34,12 @@
Description describeMismatch(
item, Description mismatchDescription, Map matchState, bool verbose) {
- if (item is! num) {
- return mismatchDescription.add(' not numeric');
- } else {
+ if (item is num) {
var diff = item - _value;
if (diff < 0) diff = -diff;
return mismatchDescription.add(' differs by ').addDescriptionOf(diff);
+ } else {
+ return mismatchDescription.add(' not numeric');
}
}
}
@@ -70,19 +72,20 @@
this._low, this._high, this._lowMatchValue, this._highMatchValue);
bool matches(value, Map matchState) {
- if (value is! num) {
+ if (value is num) {
+ if (value < _low || value > _high) {
+ return false;
+ }
+ if (value == _low) {
+ return _lowMatchValue;
+ }
+ if (value == _high) {
+ return _highMatchValue;
+ }
+ return true;
+ } else {
return false;
}
- if (value < _low || value > _high) {
- return false;
- }
- if (value == _low) {
- return _lowMatchValue;
- }
- if (value == _high) {
- return _highMatchValue;
- }
- return true;
}
Description describe(Description description) =>
diff --git a/packages/matcher/lib/src/string_matchers.dart b/packages/matcher/lib/src/string_matchers.dart
index d8bbdb8..14e6fbb 100644
--- a/packages/matcher/lib/src/string_matchers.dart
+++ b/packages/matcher/lib/src/string_matchers.dart
@@ -118,15 +118,16 @@
const _StringContainsInOrder(this._substrings);
bool matches(item, Map matchState) {
- if (!(item is String)) {
+ if (item is String) {
+ var from_index = 0;
+ for (var s in _substrings) {
+ from_index = item.indexOf(s, from_index);
+ if (from_index < 0) return false;
+ }
+ return true;
+ } else {
return false;
}
- var from_index = 0;
- for (var s in _substrings) {
- from_index = item.indexOf(s, from_index);
- if (from_index < 0) return false;
- }
- return true;
}
Description describe(Description description) => description.addAll(
diff --git a/packages/matcher/lib/src/util.dart b/packages/matcher/lib/src/util.dart
index 112819b..7e7ff05 100644
--- a/packages/matcher/lib/src/util.dart
+++ b/packages/matcher/lib/src/util.dart
@@ -5,7 +5,7 @@
import 'core_matchers.dart';
import 'interfaces.dart';
-typedef bool _Predicate(value);
+typedef bool _Predicate<T>(T value);
/// A [Map] between whitespace characters and their escape sequences.
const _escapeMap = const {
@@ -38,8 +38,13 @@
Matcher wrapMatcher(x) {
if (x is Matcher) {
return x;
- } else if (x is _Predicate) {
+ } else if (x is _Predicate<Object>) {
+ // x is already a predicate that can handle anything
return predicate(x);
+ } else if (x is _Predicate<Null>) {
+ // x is a unary predicate, but expects a specific type
+ // so wrap it.
+ return predicate((a) => (x as dynamic)(a));
} else {
return equals(x);
}
diff --git a/packages/matcher/pubspec.yaml b/packages/matcher/pubspec.yaml
index a274b9d..0c5468e 100644
--- a/packages/matcher/pubspec.yaml
+++ b/packages/matcher/pubspec.yaml
@@ -1,11 +1,10 @@
name: matcher
-
-version: 0.12.1+1
+version: 0.12.1+4
author: Dart Team <misc@dartlang.org>
description: Support for specifying test expectations
homepage: https://github.com/dart-lang/matcher
environment:
- sdk: '>=1.8.0 <2.0.0'
+ sdk: '>=1.23.0 <2.0.0'
dependencies:
stack_trace: '^1.2.0'
dev_dependencies:
diff --git a/packages/matcher/test/core_matchers_test.dart b/packages/matcher/test/core_matchers_test.dart
index 04cc111..8261c6f 100644
--- a/packages/matcher/test/core_matchers_test.dart
+++ b/packages/matcher/test/core_matchers_test.dart
@@ -250,8 +250,6 @@
contains("Expected: feature {1: 'a'} "),
contains("Actual: 'a' "),
contains("Which: threw 'Exception: bang' "),
- contains("test/core_matchers_test.dart "),
- contains("package:test ")
]));
});
}
diff --git a/packages/matcher/test/string_matchers_test.dart b/packages/matcher/test/string_matchers_test.dart
index 5b5afe4..28d085c 100644
--- a/packages/matcher/test/string_matchers_test.dart
+++ b/packages/matcher/test/string_matchers_test.dart
@@ -13,6 +13,16 @@
contains('Differ at offset 7'));
});
+ test("Retains outer matcher mismatch text", () {
+ shouldFail(
+ {'word': 'thing'},
+ containsPair('word', equals('notthing')),
+ allOf([
+ contains("contains key 'word' but with value is different"),
+ contains("Differ at offset 0")
+ ]));
+ });
+
test('collapseWhitespace', () {
var source = '\t\r\n hello\t\r\n world\r\t \n';
expect(collapseWhitespace(source), 'hello world');
diff --git a/packages/meta/.packages b/packages/meta/.packages
deleted file mode 100644
index d979045..0000000
--- a/packages/meta/.packages
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated by pub on 2017-07-19 12:49:39.505373.
-meta:lib/
diff --git a/packages/meta/CHANGELOG.md b/packages/meta/CHANGELOG.md
index b44eb57..51ed95f 100644
--- a/packages/meta/CHANGELOG.md
+++ b/packages/meta/CHANGELOG.md
@@ -1,6 +1,3 @@
-## 1.1.1
-* Update SDK constraint to be 2.0.0 dev friendly.
-
## 1.1.0
* Introduce `@alwaysThrows` to declare that a function always throws
(SDK issue [17999](https://github.com/dart-lang/sdk/issues/17999)). This
diff --git a/packages/meta/pubspec.yaml b/packages/meta/pubspec.yaml
index 50f7b1b..e23093e 100644
--- a/packages/meta/pubspec.yaml
+++ b/packages/meta/pubspec.yaml
@@ -1,5 +1,5 @@
name: meta
-version: 1.1.1
+version: 1.1.0
author: Dart Team <misc@dartlang.org>
homepage: http://www.dartlang.org
description: >
@@ -7,4 +7,4 @@
semantic information about the program being annotated. These annotations are
intended to be used by tools to provide a better user experience.
environment:
- sdk: '>=1.12.0 <2.0.0-dev.infinity'
+ sdk: '>=1.12.0 <2.0.0'
diff --git a/packages/package_config/.travis.yml b/packages/package_config/.travis.yml
index 7a20d25..24d56a3 100644
--- a/packages/package_config/.travis.yml
+++ b/packages/package_config/.travis.yml
@@ -1,4 +1,17 @@
language: dart
-dart: dev
-script: ./tool/travis.sh
sudo: false
+dart:
+ - dev
+ - stable
+dart_task:
+ - test
+ - dartfmt
+ - dartanalyzer: --fatal-warnings .
+
+# Only building master means that we don't run two builds for each pull request.
+branches:
+ only: [master]
+
+cache:
+ directories:
+ - $HOME/.pub-cache
diff --git a/packages/package_config/CHANGELOG.md b/packages/package_config/CHANGELOG.md
index c17c674..a9ac0ec 100644
--- a/packages/package_config/CHANGELOG.md
+++ b/packages/package_config/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.0.3
+
+- Removed unneeded dependency constraint on SDK.
+
## 1.0.2
- Update SDK constraint to be 2.0.0 dev friendly.
diff --git a/packages/package_config/lib/discovery.dart b/packages/package_config/lib/discovery.dart
index 4c09eec..020d99a 100644
--- a/packages/package_config/lib/discovery.dart
+++ b/packages/package_config/lib/discovery.dart
@@ -33,6 +33,7 @@
Map<String, Uri> packageMap = pkgfile.parse(bytes, packagesFile);
return new MapPackages(packageMap);
}
+
if (packagesFile.scheme == "file") {
File file = new File.fromUri(packagesFile);
return parseBytes(await file.readAsBytes());
@@ -125,6 +126,7 @@
if (file.existsSync()) return file;
return null;
}
+
// Check for $cwd/.packages
var packagesCfgFile = checkForConfigFile(dir);
if (packagesCfgFile != null) return packagesCfgFile;
@@ -210,8 +212,8 @@
HttpClientRequest request = await client.getUrl(uri);
HttpClientResponse response = await request.close();
if (response.statusCode != HttpStatus.OK) {
- throw 'Failure getting $uri: '
- '${response.statusCode} ${response.reasonPhrase}';
+ throw new HttpException('${response.statusCode} ${response.reasonPhrase}',
+ uri: uri);
}
List<List<int>> splitContent = await response.toList();
int totalLength = 0;
diff --git a/packages/package_config/lib/discovery_analysis.dart b/packages/package_config/lib/discovery_analysis.dart
index ce7e98a..67798e1 100644
--- a/packages/package_config/lib/discovery_analysis.dart
+++ b/packages/package_config/lib/discovery_analysis.dart
@@ -91,6 +91,7 @@
contexts = oldContexts;
}
}
+
findRoots(directory);
// If the root is not itself context root, add a the wrapper context.
if (contexts.length == 1 && contexts[0].directory == directory) {
@@ -115,6 +116,7 @@
recurse(child);
}
}
+
recurse(this);
return result;
}
diff --git a/packages/package_config/pubspec.yaml b/packages/package_config/pubspec.yaml
index a629eaf..bd2c6ab 100644
--- a/packages/package_config/pubspec.yaml
+++ b/packages/package_config/pubspec.yaml
@@ -1,11 +1,11 @@
name: package_config
-version: 1.0.2
+version: 1.0.3
description: Support for working with Package Resolution config files.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/package_config
environment:
- sdk: '>=1.11.0 <2.0.0-dev.infinity'
+ sdk: '>=1.11.0 <2.0.0'
dependencies:
charcode: ^1.1.0
diff --git a/packages/package_config/test/discovery_analysis_test.dart b/packages/package_config/test/discovery_analysis_test.dart
index 0a28767..c819a90 100644
--- a/packages/package_config/test/discovery_analysis_test.dart
+++ b/packages/package_config/test/discovery_analysis_test.dart
@@ -78,7 +78,7 @@
if (location.scheme == "file") {
expect(resolver.packages, unorderedEquals(["foo", "bar", "baz"]));
} else {
- expect(() => resolver.packages, throws);
+ expect(() => resolver.packages, throwsUnsupportedError);
}
}
diff --git a/packages/package_config/test/discovery_test.dart b/packages/package_config/test/discovery_test.dart
index 897063f..6a5bcde 100644
--- a/packages/package_config/test/discovery_test.dart
+++ b/packages/package_config/test/discovery_test.dart
@@ -41,7 +41,7 @@
if (location.scheme == "file") {
expect(resolver.packages, unorderedEquals(["foo", "bar", "baz"]));
} else {
- expect(() => resolver.packages, throws);
+ expect(() => resolver.packages, throwsUnsupportedError);
}
}
@@ -169,6 +169,7 @@
}
throw "not found";
}
+
// A non-file: location with no .packages or packages/:
// Assumes a packages dir exists, and resolves relative to that.
Packages resolver;
@@ -189,6 +190,7 @@
Future<List<int>> loader(Uri file) async {
throw "not found";
}
+
// A non-file: location with no .packages or packages/:
// Assumes a packages dir exists, and resolves relative to that.
Packages resolver;
@@ -228,13 +230,16 @@
generalTest("loadPackagesFile not found", {}, (Uri directory) async {
Uri file = directory.resolve(".packages");
- expect(loadPackagesFile(file), throws);
+ expect(
+ loadPackagesFile(file),
+ throwsA(anyOf(new isInstanceOf<FileSystemException>(),
+ new isInstanceOf<HttpException>())));
});
generalTest("loadPackagesFile syntax error", {".packages": "syntax error"},
(Uri directory) async {
Uri file = directory.resolve(".packages");
- expect(loadPackagesFile(file), throws);
+ expect(loadPackagesFile(file), throwsFormatException);
});
generalTest("getPackagesDir", {
diff --git a/packages/package_config/test/parse_test.dart b/packages/package_config/test/parse_test.dart
index 7a2fce7..fb3a6fa 100644
--- a/packages/package_config/test/parse_test.dart
+++ b/packages/package_config/test/parse_test.dart
@@ -102,16 +102,18 @@
for (int i = 0; i <= 255; i++) {
if (map[i] == true) continue;
var char = new String.fromCharCode(i);
- expect(() => doParse("x${char}x:x", null), throws);
+ expect(() => doParse("x${char}x:x", null),
+ anyOf(throwsNoSuchMethodError, throwsFormatException));
}
});
test("no escapes", () {
- expect(() => doParse("x%41x:x", base), throws);
+ expect(() => doParse("x%41x:x", base), throwsFormatException);
});
test("same name twice", () {
- expect(() => doParse(singleRelativeSample * 2, base), throws);
+ expect(
+ () => doParse(singleRelativeSample * 2, base), throwsFormatException);
});
for (String invalidSample in invalid) {
diff --git a/packages/package_config/test/parse_write_test.dart b/packages/package_config/test/parse_write_test.dart
index 4302187..b963eb5 100644
--- a/packages/package_config/test/parse_write_test.dart
+++ b/packages/package_config/test/parse_write_test.dart
@@ -34,6 +34,7 @@
});
});
}
+
var lowerDir = baseDir.resolve("path3/path4/");
var higherDir = baseDir.resolve("../");
var parallelDir = baseDir.resolve("../path3/");
diff --git a/packages/package_config/tool/travis.sh b/packages/package_config/tool/travis.sh
deleted file mode 100755
index 6d8cfe3..0000000
--- a/packages/package_config/tool/travis.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-
-# Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-# Fast fail the script on failures.
-set -e
-
-# Verify that the libraries are error free.
-dartanalyzer --fatal-warnings \
- lib/packages.dart \
- test/all.dart
-
-# Run the tests.
-dart test/all.dart
-
diff --git a/packages/plugin/.gitignore b/packages/plugin/.gitignore
index 5652c58..938f99e 100644
--- a/packages/plugin/.gitignore
+++ b/packages/plugin/.gitignore
@@ -4,5 +4,4 @@
build
.project
.settings
-.packages
pubspec.lock
diff --git a/packages/plugin/analysis_options.yaml b/packages/plugin/analysis_options.yaml
deleted file mode 100644
index a10d4c5..0000000
--- a/packages/plugin/analysis_options.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-analyzer:
- strong-mode: true
diff --git a/packages/plugin/pubspec.yaml b/packages/plugin/pubspec.yaml
index f705677..92f0932 100755
--- a/packages/plugin/pubspec.yaml
+++ b/packages/plugin/pubspec.yaml
@@ -1,9 +1,9 @@
name: plugin
-version: 0.2.0+1
+version: 0.2.0
author: Dart Team <misc@dartlang.org>
description: Support for building plugins.
homepage: https://github.com/dart-lang/plugin
environment:
- sdk: '>=1.0.0 <2.0.0-dev.infinity'
+ sdk: '>=1.0.0 <2.0.0'
dev_dependencies:
- test: any
+ unittest: any
diff --git a/packages/plugin/test/plugin_impl_test.dart b/packages/plugin/test/plugin_impl_test.dart
index 2221cf8..c8603af 100644
--- a/packages/plugin/test/plugin_impl_test.dart
+++ b/packages/plugin/test/plugin_impl_test.dart
@@ -6,9 +6,11 @@
import 'package:plugin/plugin.dart';
import 'package:plugin/src/plugin_impl.dart';
-import 'package:test/test.dart';
+import 'package:unittest/unittest.dart';
main() {
+ groupSep = ' | ';
+
group('ExtensionManager', () {
test('processPlugins', () {
TestPlugin plugin1 = new TestPlugin('plugin1');
diff --git a/packages/pool/.analysis_options b/packages/pool/.analysis_options
deleted file mode 100644
index a10d4c5..0000000
--- a/packages/pool/.analysis_options
+++ /dev/null
@@ -1,2 +0,0 @@
-analyzer:
- strong-mode: true
diff --git a/packages/pool/CHANGELOG.md b/packages/pool/CHANGELOG.md
index 80d54c7..d9db81c 100644
--- a/packages/pool/CHANGELOG.md
+++ b/packages/pool/CHANGELOG.md
@@ -1,3 +1,13 @@
+## 1.3.3
+
+* Declare support for `async` 2.0.0.
+
+## 1.3.2
+
+* Update to make the code work with strong-mode clean Zone API.
+
+* Required minimum SDK of 1.23.0.
+
## 1.3.1
* Fix the type annotation of `Pool.withResource()` to indicate that it takes
diff --git a/packages/pool/README.md b/packages/pool/README.md
index 8987288..641e772 100644
--- a/packages/pool/README.md
+++ b/packages/pool/README.md
@@ -13,7 +13,7 @@
Future<String> readFile(String path) {
// Since the call to [File.readAsString] is within [withResource], no more
// than ten files will be open at once.
- return pool.withResource(() => return new File(path).readAsString());
+ return pool.withResource(() => new File(path).readAsString());
}
```
diff --git a/packages/pool/lib/pool.dart b/packages/pool/lib/pool.dart
index 04aaaea..86f8363 100644
--- a/packages/pool/lib/pool.dart
+++ b/packages/pool/lib/pool.dart
@@ -78,8 +78,7 @@
/// If [timeout] is passed, then if that much time passes without any activity
/// all pending [request] futures will throw a [TimeoutException]. This is
/// intended to avoid deadlocks.
- Pool(this._maxAllocatedResources, {Duration timeout})
- : _timeout = timeout {
+ Pool(this._maxAllocatedResources, {Duration timeout}) : _timeout = timeout {
if (timeout != null) {
// Start the timer canceled since we only want to start counting down once
// we've run out of available resources.
@@ -140,21 +139,21 @@
///
/// This may be called more than once; it returns the same [Future] each time.
Future close() => _closeMemo.runOnce(() {
- if (_closeGroup != null) return _closeGroup.future;
+ if (_closeGroup != null) return _closeGroup.future;
- _resetTimer();
+ _resetTimer();
- _closeGroup = new FutureGroup();
- for (var callback in _onReleaseCallbacks) {
- _closeGroup.add(new Future.sync(callback));
- }
+ _closeGroup = new FutureGroup();
+ for (var callback in _onReleaseCallbacks) {
+ _closeGroup.add(new Future.sync(callback));
+ }
- _allocatedResources -= _onReleaseCallbacks.length;
- _onReleaseCallbacks.clear();
+ _allocatedResources -= _onReleaseCallbacks.length;
+ _onReleaseCallbacks.clear();
- if (_allocatedResources == 0) _closeGroup.close();
- return _closeGroup.future;
- });
+ if (_allocatedResources == 0) _closeGroup.close();
+ return _closeGroup.future;
+ });
final _closeMemo = new AsyncMemoizer();
/// If there are any pending requests, this will fire the oldest one.
@@ -183,8 +182,9 @@
_allocatedResources--;
if (_allocatedResources == 0) _closeGroup.close();
} else {
- _onReleaseCallbacks.add(
- Zone.current.bindCallback(onRelease, runGuarded: false));
+ var zone = Zone.current;
+ var registered = zone.registerCallback(onRelease);
+ _onReleaseCallbacks.add(() => zone.run(registered));
}
}
@@ -221,7 +221,8 @@
void _onTimeout() {
for (var completer in _requestedResources) {
completer.completeError(
- new TimeoutException("Pool deadlock: all resources have been "
+ new TimeoutException(
+ "Pool deadlock: all resources have been "
"allocated for too long.",
_timeout),
new Chain.current());
diff --git a/packages/pool/pubspec.yaml b/packages/pool/pubspec.yaml
index 8efc8e5..b9c5c8d 100644
--- a/packages/pool/pubspec.yaml
+++ b/packages/pool/pubspec.yaml
@@ -1,13 +1,13 @@
name: pool
-version: 1.3.1
+version: 1.3.3
author: Dart Team <misc@dartlang.org>
description: A class for managing a finite pool of resources.
homepage: https://github.com/dart-lang/pool
dependencies:
- async: "^1.4.0"
+ async: ">=1.4.0 <3.0.0"
stack_trace: ">=0.9.2 <2.0.0"
environment:
- sdk: ">=1.22.0 <2.0.0"
+ sdk: ">=1.23.0 <2.0.0"
dev_dependencies:
fake_async: ">=0.1.0 <0.2.0"
test: ">=0.12.0 <0.13.0"
diff --git a/packages/pool/test/pool_test.dart b/packages/pool/test/pool_test.dart
index 7fba9c0..6feba75 100644
--- a/packages/pool/test/pool_test.dart
+++ b/packages/pool/test/pool_test.dart
@@ -299,9 +299,11 @@
test("pending requests are fulfilled", () async {
var pool = new Pool(1);
var resource1 = await pool.request();
- expect(pool.request().then((resource2) {
- resource2.release();
- }), completes);
+ expect(
+ pool.request().then((resource2) {
+ resource2.release();
+ }),
+ completes);
expect(pool.done, completes);
expect(pool.close(), completes);
resource1.release();
@@ -312,10 +314,12 @@
var resource1 = await pool.request();
var completer = new Completer();
- expect(pool.request().then((resource2) {
- expect(completer.isCompleted, isTrue);
- resource2.release();
- }), completes);
+ expect(
+ pool.request().then((resource2) {
+ expect(completer.isCompleted, isTrue);
+ resource2.release();
+ }),
+ completes);
expect(pool.close(), completes);
resource1.allowRelease(() => completer.future);
@@ -333,11 +337,13 @@
var resource1Released = false;
var resource2Released = false;
var resource3Released = false;
- expect(pool.close().then((_) {
- expect(resource1Released, isTrue);
- expect(resource2Released, isTrue);
- expect(resource3Released, isTrue);
- }), completes);
+ expect(
+ pool.close().then((_) {
+ expect(resource1Released, isTrue);
+ expect(resource2Released, isTrue);
+ expect(resource3Released, isTrue);
+ }),
+ completes);
resource1Released = true;
resource1.release();
@@ -360,9 +366,11 @@
// [completer].
var completer = new Completer();
resource.allowRelease(() => completer.future);
- expect(pool.request().then((_) {
- expect(completer.isCompleted, isTrue);
- }), completes);
+ expect(
+ pool.request().then((_) {
+ expect(completer.isCompleted, isTrue);
+ }),
+ completes);
await new Future.delayed(Duration.ZERO);
pool.close();
@@ -381,10 +389,12 @@
var completer2 = new Completer();
resource2.allowRelease(() => completer2.future);
- expect(pool.close().then((_) {
- expect(completer1.isCompleted, isTrue);
- expect(completer2.isCompleted, isTrue);
- }), completes);
+ expect(
+ pool.close().then((_) {
+ expect(completer1.isCompleted, isTrue);
+ expect(completer2.isCompleted, isTrue);
+ }),
+ completes);
await new Future.delayed(Duration.ZERO);
completer1.complete();
@@ -398,9 +408,11 @@
var resource = await pool.request();
var completer = new Completer();
- expect(pool.close().then((_) {
- expect(completer.isCompleted, isTrue);
- }), completes);
+ expect(
+ pool.close().then((_) {
+ expect(completer.isCompleted, isTrue);
+ }),
+ completes);
await new Future.delayed(Duration.ZERO);
resource.allowRelease(() => completer.future);
@@ -438,10 +450,10 @@
///
/// This should only be called within a [FakeAsync.run] zone.
Matcher get doesNotComplete => predicate((future) {
- expect(future, new isInstanceOf<Future>());
+ expect(future, new isInstanceOf<Future>());
- var stack = new Trace.current(1);
- future.then((_) => registerException(
- new TestFailure("Expected future not to complete."), stack));
- return true;
-});
+ var stack = new Trace.current(1);
+ future.then((_) => registerException(
+ new TestFailure("Expected future not to complete."), stack));
+ return true;
+ });
diff --git a/packages/stack_trace/.travis.yml b/packages/stack_trace/.travis.yml
index fff8494..2ec03bb 100644
--- a/packages/stack_trace/.travis.yml
+++ b/packages/stack_trace/.travis.yml
@@ -3,8 +3,7 @@
dart:
- dev
- stable
- - 1.22.1
- - 1.21.1
+ - 1.23.0
dart_task:
- test: -p vm
- test: -p firefox
@@ -17,6 +16,11 @@
# Formatted with 1.23.0+ which has (good) changes since 1.22.1
- dart: dev
dart_task: dartfmt
+
+# Only building master means that we don't run two builds for each pull request.
+branches:
+ only: [master]
+
cache:
directories:
- $HOME/.pub-cache
diff --git a/packages/stack_trace/CHANGELOG.md b/packages/stack_trace/CHANGELOG.md
index cd78a9a..19fb82b 100644
--- a/packages/stack_trace/CHANGELOG.md
+++ b/packages/stack_trace/CHANGELOG.md
@@ -1,3 +1,13 @@
+## 1.8.2
+
+* Update to use strong-mode clean Zone API.
+
+## 1.8.1
+
+* Use official generic function syntax.
+
+* Updated minimum SDK to 1.23.0.
+
## 1.8.0
* Add a `Trace.original` field to provide access to the original `StackTrace`s
diff --git a/packages/stack_trace/lib/src/chain.dart b/packages/stack_trace/lib/src/chain.dart
index 2d1349d..01bf06f 100644
--- a/packages/stack_trace/lib/src/chain.dart
+++ b/packages/stack_trace/lib/src/chain.dart
@@ -93,7 +93,8 @@
return callback();
} catch (error, stackTrace) {
// TODO(nweiz): Don't special-case this when issue 19566 is fixed.
- return Zone.current.handleUncaughtError(error, stackTrace);
+ Zone.current.handleUncaughtError(error, stackTrace);
+ return null;
}
},
zoneSpecification: spec.toSpec(),
@@ -104,7 +105,7 @@
/// [callback] in a [Zone] in which chain capturing is disabled.
///
/// If [callback] returns a value, it will be returned by [disable] as well.
- static/*=T*/ disable/*<T>*/(/*=T*/ callback(), {bool when: true}) {
+ static T disable<T>(T callback(), {bool when: true}) {
var zoneValues =
when ? {_specKey: null, StackZoneSpecification.disableKey: true} : null;
diff --git a/packages/stack_trace/lib/src/stack_zone_specification.dart b/packages/stack_trace/lib/src/stack_zone_specification.dart
index eb06beb..6749d56 100644
--- a/packages/stack_trace/lib/src/stack_zone_specification.dart
+++ b/packages/stack_trace/lib/src/stack_zone_specification.dart
@@ -92,8 +92,8 @@
/// Tracks the current stack chain so it can be set to [_currentChain] when
/// [f] is run.
- ZoneCallback _registerCallback(
- Zone self, ZoneDelegate parent, Zone zone, Function f) {
+ ZoneCallback<R> _registerCallback<R>(
+ Zone self, ZoneDelegate parent, Zone zone, R f()) {
if (f == null || _disabled) return parent.registerCallback(zone, f);
var node = _createNode(1);
return parent.registerCallback(zone, () => _run(f, node));
@@ -101,8 +101,8 @@
/// Tracks the current stack chain so it can be set to [_currentChain] when
/// [f] is run.
- ZoneUnaryCallback _registerUnaryCallback(
- Zone self, ZoneDelegate parent, Zone zone, Function f) {
+ ZoneUnaryCallback<R, T> _registerUnaryCallback<R, T>(
+ Zone self, ZoneDelegate parent, Zone zone, R f(T arg)) {
if (f == null || _disabled) return parent.registerUnaryCallback(zone, f);
var node = _createNode(1);
return parent.registerUnaryCallback(zone, (arg) {
@@ -112,7 +112,7 @@
/// Tracks the current stack chain so it can be set to [_currentChain] when
/// [f] is run.
- ZoneBinaryCallback _registerBinaryCallback(
+ ZoneBinaryCallback<R, T1, T2> _registerBinaryCallback<R, T1, T2>(
Zone self, ZoneDelegate parent, Zone zone, Function f) {
if (f == null || _disabled) return parent.registerBinaryCallback(zone, f);
@@ -124,26 +124,28 @@
/// Looks up the chain associated with [stackTrace] and passes it either to
/// [_onError] or [parent]'s error handler.
- _handleUncaughtError(
+ void _handleUncaughtError(
Zone self, ZoneDelegate parent, Zone zone, error, StackTrace stackTrace) {
if (_disabled) {
- return parent.handleUncaughtError(zone, error, stackTrace);
+ parent.handleUncaughtError(zone, error, stackTrace);
+ return;
}
var stackChain = chainFor(stackTrace);
if (_onError == null) {
- return parent.handleUncaughtError(zone, error, stackChain);
+ parent.handleUncaughtError(zone, error, stackChain);
+ return;
}
// TODO(nweiz): Currently this copies a lot of logic from [runZoned]. Just
// allow [runBinary] to throw instead once issue 18134 is fixed.
try {
- return self.parent.runBinary(_onError, error, stackChain);
+ self.parent.runBinary(_onError, error, stackChain);
} catch (newError, newStackTrace) {
if (identical(newError, error)) {
- return parent.handleUncaughtError(zone, error, stackChain);
+ parent.handleUncaughtError(zone, error, stackChain);
} else {
- return parent.handleUncaughtError(zone, newError, newStackTrace);
+ parent.handleUncaughtError(zone, newError, newStackTrace);
}
}
}
@@ -180,7 +182,7 @@
///
/// If [f] throws an error, this associates [node] with that error's stack
/// trace.
- _run(Function f, _Node node) {
+ T _run<T>(T f(), _Node node) {
var previousNode = _currentNode;
_currentNode = node;
try {
diff --git a/packages/stack_trace/pubspec.yaml b/packages/stack_trace/pubspec.yaml
index a4552ac..a6e5b92 100644
--- a/packages/stack_trace/pubspec.yaml
+++ b/packages/stack_trace/pubspec.yaml
@@ -7,7 +7,7 @@
#
# When the major version is upgraded, you *must* update that version constraint
# in pub to stay in sync with this.
-version: 1.8.0
+version: 1.8.2
author: "Dart Team <misc@dartlang.org>"
homepage: https://github.com/dart-lang/stack_trace
description: A package for manipulating stack traces and printing them readably.
@@ -17,4 +17,4 @@
dev_dependencies:
test: '^0.12.17'
environment:
- sdk: ">=1.21.0 <2.0.0"
+ sdk: ">=1.23.0 <2.0.0"
diff --git a/packages/watcher/CHANGELOG.md b/packages/watcher/CHANGELOG.md
index c3acaf5..f07ceaf 100644
--- a/packages/watcher/CHANGELOG.md
+++ b/packages/watcher/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 0.9.7+4
+
+* Declare support for `async` 2.0.0.
+
# 0.9.7+3
* Fix a crashing bug on Linux.
diff --git a/packages/watcher/lib/src/directory_watcher/windows.dart b/packages/watcher/lib/src/directory_watcher/windows.dart
index 67a2741..ec119f7 100644
--- a/packages/watcher/lib/src/directory_watcher/windows.dart
+++ b/packages/watcher/lib/src/directory_watcher/windows.dart
@@ -1,408 +1,408 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-// TODO(rnystrom): Merge with mac_os version.
-
-import 'dart:async';
-import 'dart:collection';
-import 'dart:io';
-
-import 'package:path/path.dart' as p;
-
-import '../constructable_file_system_event.dart';
-import '../directory_watcher.dart';
-import '../path_set.dart';
-import '../resubscribable.dart';
-import '../utils.dart';
-import '../watch_event.dart';
-
-class WindowsDirectoryWatcher extends ResubscribableWatcher
- implements DirectoryWatcher {
- String get directory => path;
-
- WindowsDirectoryWatcher(String directory)
- : super(directory, () => new _WindowsDirectoryWatcher(directory));
-}
-
-class _EventBatcher {
- static const Duration _BATCH_DELAY = const Duration(milliseconds: 100);
- final List<FileSystemEvent> events = [];
- Timer timer;
-
- void addEvent(FileSystemEvent event, void callback()) {
- events.add(event);
- if (timer != null) {
- timer.cancel();
- }
- timer = new Timer(_BATCH_DELAY, callback);
- }
-
- void cancelTimer() {
- timer.cancel();
- }
-}
-
-class _WindowsDirectoryWatcher
- implements DirectoryWatcher, ManuallyClosedWatcher {
- String get directory => path;
- final String path;
-
- Stream<WatchEvent> get events => _eventsController.stream;
- final _eventsController = new StreamController<WatchEvent>.broadcast();
-
- bool get isReady => _readyCompleter.isCompleted;
-
- Future get ready => _readyCompleter.future;
- final _readyCompleter = new Completer();
-
- final Map<String, _EventBatcher> _eventBatchers =
- new HashMap<String, _EventBatcher>();
-
- /// The set of files that are known to exist recursively within the watched
- /// directory.
- ///
- /// The state of files on the filesystem is compared against this to determine
- /// the real change that occurred. This is also used to emit REMOVE events
- /// when subdirectories are moved out of the watched directory.
- final PathSet _files;
-
- /// The subscription to the stream returned by [Directory.watch].
- StreamSubscription<FileSystemEvent> _watchSubscription;
-
- /// The subscription to the stream returned by [Directory.watch] of the
- /// parent directory to [directory]. This is needed to detect changes to
- /// [directory], as they are not included on Windows.
- StreamSubscription<FileSystemEvent> _parentWatchSubscription;
-
- /// The subscription to the [Directory.list] call for the initial listing of
- /// the directory to determine its initial state.
- StreamSubscription<FileSystemEntity> _initialListSubscription;
-
- /// The subscriptions to the [Directory.list] calls for listing the contents
- /// of subdirectories that were moved into the watched directory.
- final Set<StreamSubscription<FileSystemEntity>> _listSubscriptions
- = new HashSet<StreamSubscription<FileSystemEntity>>();
-
- _WindowsDirectoryWatcher(String path)
- : path = path,
- _files = new PathSet(path) {
- // Before we're ready to emit events, wait for [_listDir] to complete.
- _listDir().then((_) {
- _startWatch();
- _startParentWatcher();
- _readyCompleter.complete();
- });
- }
-
- void close() {
- if (_watchSubscription != null) _watchSubscription.cancel();
- if (_parentWatchSubscription != null) _parentWatchSubscription.cancel();
- if (_initialListSubscription != null) _initialListSubscription.cancel();
- for (var sub in _listSubscriptions) {
- sub.cancel();
- }
- _listSubscriptions.clear();
- for (var batcher in _eventBatchers.values) {
- batcher.cancelTimer();
- }
- _eventBatchers.clear();
- _watchSubscription = null;
- _parentWatchSubscription = null;
- _initialListSubscription = null;
- _eventsController.close();
- }
-
- /// On Windows, if [directory] is deleted, we will not receive any event.
- ///
- /// Instead, we add a watcher on the parent folder (if any), that can notify
- /// us about [path]. This also includes events such as moves.
- void _startParentWatcher() {
- var absoluteDir = p.absolute(path);
- var parent = p.dirname(absoluteDir);
- // Check if [path] is already the root directory.
- if (FileSystemEntity.identicalSync(parent, path)) return;
- var parentStream = new Directory(parent).watch(recursive: false);
- _parentWatchSubscription = parentStream.listen((event) {
- // Only look at events for 'directory'.
- if (p.basename(event.path) != p.basename(absoluteDir)) return;
- // Test if the directory is removed. FileSystemEntity.typeSync will
- // return NOT_FOUND if it's unable to decide upon the type, including
- // access denied issues, which may happen when the directory is deleted.
- // FileSystemMoveEvent and FileSystemDeleteEvent events will always mean
- // the directory is now gone.
- if (event is FileSystemMoveEvent ||
- event is FileSystemDeleteEvent ||
- (FileSystemEntity.typeSync(path) ==
- FileSystemEntityType.NOT_FOUND)) {
- for (var path in _files.paths) {
- _emitEvent(ChangeType.REMOVE, path);
- }
- _files.clear();
- close();
- }
- }, onError: (error) {
- // Ignore errors, simply close the stream. The user listens on
- // [directory], and while it can fail to listen on the parent, we may
- // still be able to listen on the path requested.
- _parentWatchSubscription.cancel();
- _parentWatchSubscription = null;
- });
- }
-
- void _onEvent(FileSystemEvent event) {
- assert(isReady);
- final batcher = _eventBatchers.putIfAbsent(
- event.path, () => new _EventBatcher());
- batcher.addEvent(event, () {
- _eventBatchers.remove(event.path);
- _onBatch(batcher.events);
- });
- }
-
- /// The callback that's run when [Directory.watch] emits a batch of events.
- void _onBatch(List<FileSystemEvent> batch) {
- _sortEvents(batch).forEach((path, eventSet) {
-
- var canonicalEvent = _canonicalEvent(eventSet);
- var events = canonicalEvent == null ?
- _eventsBasedOnFileSystem(path) : [canonicalEvent];
-
- for (var event in events) {
- if (event is FileSystemCreateEvent) {
- if (!event.isDirectory) {
- if (_files.contains(path)) continue;
-
- _emitEvent(ChangeType.ADD, path);
- _files.add(path);
- continue;
- }
-
- if (_files.containsDir(path)) continue;
-
- var stream = new Directory(path).list(recursive: true);
- StreamSubscription<FileSystemEntity> subscription;
- subscription = stream.listen((entity) {
- if (entity is Directory) return;
- if (_files.contains(path)) return;
-
- _emitEvent(ChangeType.ADD, entity.path);
- _files.add(entity.path);
- }, onDone: () {
- _listSubscriptions.remove(subscription);
- }, onError: (e, stackTrace) {
- _listSubscriptions.remove(subscription);
- _emitError(e, stackTrace);
- }, cancelOnError: true);
- _listSubscriptions.add(subscription);
- } else if (event is FileSystemModifyEvent) {
- if (!event.isDirectory) {
- _emitEvent(ChangeType.MODIFY, path);
- }
- } else {
- assert(event is FileSystemDeleteEvent);
- for (var removedPath in _files.remove(path)) {
- _emitEvent(ChangeType.REMOVE, removedPath);
- }
- }
- }
- });
- }
-
- /// Sort all the events in a batch into sets based on their path.
- ///
- /// A single input event may result in multiple events in the returned map;
- /// for example, a MOVE event becomes a DELETE event for the source and a
- /// CREATE event for the destination.
- ///
- /// The returned events won't contain any [FileSystemMoveEvent]s, nor will it
- /// contain any events relating to [path].
- Map<String, Set<FileSystemEvent>> _sortEvents(List<FileSystemEvent> batch) {
- var eventsForPaths = <String, Set>{};
-
- // Events within directories that already have events are superfluous; the
- // directory's full contents will be examined anyway, so we ignore such
- // events. Emitting them could cause useless or out-of-order events.
- var directories = unionAll(batch.map((event) {
- if (!event.isDirectory) return new Set();
- if (event is FileSystemMoveEvent) {
- return new Set.from([event.path, event.destination]);
- }
- return new Set.from([event.path]);
- }));
-
- isInModifiedDirectory(path) =>
- directories.any((dir) => path != dir && path.startsWith(dir));
-
- addEvent(path, event) {
- if (isInModifiedDirectory(path)) return;
- var set = eventsForPaths.putIfAbsent(path, () => new Set());
- set.add(event);
- }
-
- for (var event in batch) {
- if (event is FileSystemMoveEvent) {
- addEvent(event.destination, event);
- }
- addEvent(event.path, event);
- }
-
- return eventsForPaths;
- }
-
- /// Returns the canonical event from a batch of events on the same path, if
- /// one exists.
- ///
- /// If [batch] doesn't contain any contradictory events (e.g. DELETE and
- /// CREATE, or events with different values for [isDirectory]), this returns a
- /// single event that describes what happened to the path in question.
- ///
- /// If [batch] does contain contradictory events, this returns `null` to
- /// indicate that the state of the path on the filesystem should be checked to
- /// determine what occurred.
- FileSystemEvent _canonicalEvent(Set<FileSystemEvent> batch) {
- // An empty batch indicates that we've learned earlier that the batch is
- // contradictory (e.g. because of a move).
- if (batch.isEmpty) return null;
-
- var type = batch.first.type;
- var isDir = batch.first.isDirectory;
-
- for (var event in batch.skip(1)) {
- // If one event reports that the file is a directory and another event
- // doesn't, that's a contradiction.
- if (isDir != event.isDirectory) return null;
-
- // Modify events don't contradict either CREATE or REMOVE events. We can
- // safely assume the file was modified after a CREATE or before the
- // REMOVE; otherwise there will also be a REMOVE or CREATE event
- // (respectively) that will be contradictory.
- if (event is FileSystemModifyEvent) continue;
- assert(event is FileSystemCreateEvent ||
- event is FileSystemDeleteEvent ||
- event is FileSystemMoveEvent);
-
- // If we previously thought this was a MODIFY, we now consider it to be a
- // CREATE or REMOVE event. This is safe for the same reason as above.
- if (type == FileSystemEvent.MODIFY) {
- type = event.type;
- continue;
- }
-
- // A CREATE event contradicts a REMOVE event and vice versa.
- assert(type == FileSystemEvent.CREATE ||
- type == FileSystemEvent.DELETE ||
- type == FileSystemEvent.MOVE);
- if (type != event.type) return null;
- }
-
- switch (type) {
- case FileSystemEvent.CREATE:
- return new ConstructableFileSystemCreateEvent(batch.first.path, isDir);
- case FileSystemEvent.DELETE:
- return new ConstructableFileSystemDeleteEvent(batch.first.path, isDir);
- case FileSystemEvent.MODIFY:
- return new ConstructableFileSystemModifyEvent(
- batch.first.path, isDir, false);
- case FileSystemEvent.MOVE:
- return null;
- default: throw 'unreachable';
- }
- }
-
- /// Returns one or more events that describe the change between the last known
- /// state of [path] and its current state on the filesystem.
- ///
- /// This returns a list whose order should be reflected in the events emitted
- /// to the user, unlike the batched events from [Directory.watch]. The
- /// returned list may be empty, indicating that no changes occurred to [path]
- /// (probably indicating that it was created and then immediately deleted).
- List<FileSystemEvent> _eventsBasedOnFileSystem(String path) {
- var fileExisted = _files.contains(path);
- var dirExisted = _files.containsDir(path);
- var fileExists = new File(path).existsSync();
- var dirExists = new Directory(path).existsSync();
-
- var events = <FileSystemEvent>[];
- if (fileExisted) {
- if (fileExists) {
- events.add(new ConstructableFileSystemModifyEvent(path, false, false));
- } else {
- events.add(new ConstructableFileSystemDeleteEvent(path, false));
- }
- } else if (dirExisted) {
- if (dirExists) {
- // If we got contradictory events for a directory that used to exist and
- // still exists, we need to rescan the whole thing in case it was
- // replaced with a different directory.
- events.add(new ConstructableFileSystemDeleteEvent(path, true));
- events.add(new ConstructableFileSystemCreateEvent(path, true));
- } else {
- events.add(new ConstructableFileSystemDeleteEvent(path, true));
- }
- }
-
- if (!fileExisted && fileExists) {
- events.add(new ConstructableFileSystemCreateEvent(path, false));
- } else if (!dirExisted && dirExists) {
- events.add(new ConstructableFileSystemCreateEvent(path, true));
- }
-
- return events;
- }
-
- /// The callback that's run when the [Directory.watch] stream is closed.
- /// Note that this is unlikely to happen on Windows, unless the system itself
- /// closes the handle.
- void _onDone() {
- _watchSubscription = null;
-
- // Emit remove events for any remaining files.
- for (var file in _files.paths) {
- _emitEvent(ChangeType.REMOVE, file);
- }
- _files.clear();
- close();
- }
-
- /// Start or restart the underlying [Directory.watch] stream.
- void _startWatch() {
- // Batch the events together so that we can dedup events.
- var innerStream = new Directory(path).watch(recursive: true);
- _watchSubscription = innerStream.listen(_onEvent,
- onError: _eventsController.addError,
- onDone: _onDone);
- }
-
- /// Starts or restarts listing the watched directory to get an initial picture
- /// of its state.
- Future _listDir() {
- assert(!isReady);
- if (_initialListSubscription != null) _initialListSubscription.cancel();
-
- _files.clear();
- var completer = new Completer();
- var stream = new Directory(path).list(recursive: true);
- void handleEntity(entity) {
- if (entity is! Directory) _files.add(entity.path);
- }
- _initialListSubscription = stream.listen(
- handleEntity,
- onError: _emitError,
- onDone: completer.complete,
- cancelOnError: true);
- return completer.future;
- }
-
- /// Emit an event with the given [type] and [path].
- void _emitEvent(ChangeType type, String path) {
- if (!isReady) return;
-
- _eventsController.add(new WatchEvent(type, path));
- }
-
- /// Emit an error, then close the watcher.
- void _emitError(error, StackTrace stackTrace) {
- _eventsController.addError(error, stackTrace);
- close();
- }
-}
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// TODO(rnystrom): Merge with mac_os version.
+
+import 'dart:async';
+import 'dart:collection';
+import 'dart:io';
+
+import 'package:path/path.dart' as p;
+
+import '../constructable_file_system_event.dart';
+import '../directory_watcher.dart';
+import '../path_set.dart';
+import '../resubscribable.dart';
+import '../utils.dart';
+import '../watch_event.dart';
+
+class WindowsDirectoryWatcher extends ResubscribableWatcher
+ implements DirectoryWatcher {
+ String get directory => path;
+
+ WindowsDirectoryWatcher(String directory)
+ : super(directory, () => new _WindowsDirectoryWatcher(directory));
+}
+
+class _EventBatcher {
+ static const Duration _BATCH_DELAY = const Duration(milliseconds: 100);
+ final List<FileSystemEvent> events = [];
+ Timer timer;
+
+ void addEvent(FileSystemEvent event, void callback()) {
+ events.add(event);
+ if (timer != null) {
+ timer.cancel();
+ }
+ timer = new Timer(_BATCH_DELAY, callback);
+ }
+
+ void cancelTimer() {
+ timer.cancel();
+ }
+}
+
+class _WindowsDirectoryWatcher
+ implements DirectoryWatcher, ManuallyClosedWatcher {
+ String get directory => path;
+ final String path;
+
+ Stream<WatchEvent> get events => _eventsController.stream;
+ final _eventsController = new StreamController<WatchEvent>.broadcast();
+
+ bool get isReady => _readyCompleter.isCompleted;
+
+ Future get ready => _readyCompleter.future;
+ final _readyCompleter = new Completer();
+
+ final Map<String, _EventBatcher> _eventBatchers =
+ new HashMap<String, _EventBatcher>();
+
+ /// The set of files that are known to exist recursively within the watched
+ /// directory.
+ ///
+ /// The state of files on the filesystem is compared against this to determine
+ /// the real change that occurred. This is also used to emit REMOVE events
+ /// when subdirectories are moved out of the watched directory.
+ final PathSet _files;
+
+ /// The subscription to the stream returned by [Directory.watch].
+ StreamSubscription<FileSystemEvent> _watchSubscription;
+
+ /// The subscription to the stream returned by [Directory.watch] of the
+ /// parent directory to [directory]. This is needed to detect changes to
+ /// [directory], as they are not included on Windows.
+ StreamSubscription<FileSystemEvent> _parentWatchSubscription;
+
+ /// The subscription to the [Directory.list] call for the initial listing of
+ /// the directory to determine its initial state.
+ StreamSubscription<FileSystemEntity> _initialListSubscription;
+
+ /// The subscriptions to the [Directory.list] calls for listing the contents
+ /// of subdirectories that were moved into the watched directory.
+ final Set<StreamSubscription<FileSystemEntity>> _listSubscriptions
+ = new HashSet<StreamSubscription<FileSystemEntity>>();
+
+ _WindowsDirectoryWatcher(String path)
+ : path = path,
+ _files = new PathSet(path) {
+ // Before we're ready to emit events, wait for [_listDir] to complete.
+ _listDir().then((_) {
+ _startWatch();
+ _startParentWatcher();
+ _readyCompleter.complete();
+ });
+ }
+
+ void close() {
+ if (_watchSubscription != null) _watchSubscription.cancel();
+ if (_parentWatchSubscription != null) _parentWatchSubscription.cancel();
+ if (_initialListSubscription != null) _initialListSubscription.cancel();
+ for (var sub in _listSubscriptions) {
+ sub.cancel();
+ }
+ _listSubscriptions.clear();
+ for (var batcher in _eventBatchers.values) {
+ batcher.cancelTimer();
+ }
+ _eventBatchers.clear();
+ _watchSubscription = null;
+ _parentWatchSubscription = null;
+ _initialListSubscription = null;
+ _eventsController.close();
+ }
+
+ /// On Windows, if [directory] is deleted, we will not receive any event.
+ ///
+ /// Instead, we add a watcher on the parent folder (if any), that can notify
+ /// us about [path]. This also includes events such as moves.
+ void _startParentWatcher() {
+ var absoluteDir = p.absolute(path);
+ var parent = p.dirname(absoluteDir);
+ // Check if [path] is already the root directory.
+ if (FileSystemEntity.identicalSync(parent, path)) return;
+ var parentStream = new Directory(parent).watch(recursive: false);
+ _parentWatchSubscription = parentStream.listen((event) {
+ // Only look at events for 'directory'.
+ if (p.basename(event.path) != p.basename(absoluteDir)) return;
+ // Test if the directory is removed. FileSystemEntity.typeSync will
+ // return NOT_FOUND if it's unable to decide upon the type, including
+ // access denied issues, which may happen when the directory is deleted.
+ // FileSystemMoveEvent and FileSystemDeleteEvent events will always mean
+ // the directory is now gone.
+ if (event is FileSystemMoveEvent ||
+ event is FileSystemDeleteEvent ||
+ (FileSystemEntity.typeSync(path) ==
+ FileSystemEntityType.NOT_FOUND)) {
+ for (var path in _files.paths) {
+ _emitEvent(ChangeType.REMOVE, path);
+ }
+ _files.clear();
+ close();
+ }
+ }, onError: (error) {
+ // Ignore errors, simply close the stream. The user listens on
+ // [directory], and while it can fail to listen on the parent, we may
+ // still be able to listen on the path requested.
+ _parentWatchSubscription.cancel();
+ _parentWatchSubscription = null;
+ });
+ }
+
+ void _onEvent(FileSystemEvent event) {
+ assert(isReady);
+ final batcher = _eventBatchers.putIfAbsent(
+ event.path, () => new _EventBatcher());
+ batcher.addEvent(event, () {
+ _eventBatchers.remove(event.path);
+ _onBatch(batcher.events);
+ });
+ }
+
+ /// The callback that's run when [Directory.watch] emits a batch of events.
+ void _onBatch(List<FileSystemEvent> batch) {
+ _sortEvents(batch).forEach((path, eventSet) {
+
+ var canonicalEvent = _canonicalEvent(eventSet);
+ var events = canonicalEvent == null ?
+ _eventsBasedOnFileSystem(path) : [canonicalEvent];
+
+ for (var event in events) {
+ if (event is FileSystemCreateEvent) {
+ if (!event.isDirectory) {
+ if (_files.contains(path)) continue;
+
+ _emitEvent(ChangeType.ADD, path);
+ _files.add(path);
+ continue;
+ }
+
+ if (_files.containsDir(path)) continue;
+
+ var stream = new Directory(path).list(recursive: true);
+ StreamSubscription<FileSystemEntity> subscription;
+ subscription = stream.listen((entity) {
+ if (entity is Directory) return;
+ if (_files.contains(path)) return;
+
+ _emitEvent(ChangeType.ADD, entity.path);
+ _files.add(entity.path);
+ }, onDone: () {
+ _listSubscriptions.remove(subscription);
+ }, onError: (e, stackTrace) {
+ _listSubscriptions.remove(subscription);
+ _emitError(e, stackTrace);
+ }, cancelOnError: true);
+ _listSubscriptions.add(subscription);
+ } else if (event is FileSystemModifyEvent) {
+ if (!event.isDirectory) {
+ _emitEvent(ChangeType.MODIFY, path);
+ }
+ } else {
+ assert(event is FileSystemDeleteEvent);
+ for (var removedPath in _files.remove(path)) {
+ _emitEvent(ChangeType.REMOVE, removedPath);
+ }
+ }
+ }
+ });
+ }
+
+ /// Sort all the events in a batch into sets based on their path.
+ ///
+ /// A single input event may result in multiple events in the returned map;
+ /// for example, a MOVE event becomes a DELETE event for the source and a
+ /// CREATE event for the destination.
+ ///
+ /// The returned events won't contain any [FileSystemMoveEvent]s, nor will it
+ /// contain any events relating to [path].
+ Map<String, Set<FileSystemEvent>> _sortEvents(List<FileSystemEvent> batch) {
+ var eventsForPaths = <String, Set>{};
+
+ // Events within directories that already have events are superfluous; the
+ // directory's full contents will be examined anyway, so we ignore such
+ // events. Emitting them could cause useless or out-of-order events.
+ var directories = unionAll(batch.map((event) {
+ if (!event.isDirectory) return new Set();
+ if (event is FileSystemMoveEvent) {
+ return new Set.from([event.path, event.destination]);
+ }
+ return new Set.from([event.path]);
+ }));
+
+ isInModifiedDirectory(path) =>
+ directories.any((dir) => path != dir && path.startsWith(dir));
+
+ addEvent(path, event) {
+ if (isInModifiedDirectory(path)) return;
+ var set = eventsForPaths.putIfAbsent(path, () => new Set());
+ set.add(event);
+ }
+
+ for (var event in batch) {
+ if (event is FileSystemMoveEvent) {
+ addEvent(event.destination, event);
+ }
+ addEvent(event.path, event);
+ }
+
+ return eventsForPaths;
+ }
+
+ /// Returns the canonical event from a batch of events on the same path, if
+ /// one exists.
+ ///
+ /// If [batch] doesn't contain any contradictory events (e.g. DELETE and
+ /// CREATE, or events with different values for [isDirectory]), this returns a
+ /// single event that describes what happened to the path in question.
+ ///
+ /// If [batch] does contain contradictory events, this returns `null` to
+ /// indicate that the state of the path on the filesystem should be checked to
+ /// determine what occurred.
+ FileSystemEvent _canonicalEvent(Set<FileSystemEvent> batch) {
+ // An empty batch indicates that we've learned earlier that the batch is
+ // contradictory (e.g. because of a move).
+ if (batch.isEmpty) return null;
+
+ var type = batch.first.type;
+ var isDir = batch.first.isDirectory;
+
+ for (var event in batch.skip(1)) {
+ // If one event reports that the file is a directory and another event
+ // doesn't, that's a contradiction.
+ if (isDir != event.isDirectory) return null;
+
+ // Modify events don't contradict either CREATE or REMOVE events. We can
+ // safely assume the file was modified after a CREATE or before the
+ // REMOVE; otherwise there will also be a REMOVE or CREATE event
+ // (respectively) that will be contradictory.
+ if (event is FileSystemModifyEvent) continue;
+ assert(event is FileSystemCreateEvent ||
+ event is FileSystemDeleteEvent ||
+ event is FileSystemMoveEvent);
+
+ // If we previously thought this was a MODIFY, we now consider it to be a
+ // CREATE or REMOVE event. This is safe for the same reason as above.
+ if (type == FileSystemEvent.MODIFY) {
+ type = event.type;
+ continue;
+ }
+
+ // A CREATE event contradicts a REMOVE event and vice versa.
+ assert(type == FileSystemEvent.CREATE ||
+ type == FileSystemEvent.DELETE ||
+ type == FileSystemEvent.MOVE);
+ if (type != event.type) return null;
+ }
+
+ switch (type) {
+ case FileSystemEvent.CREATE:
+ return new ConstructableFileSystemCreateEvent(batch.first.path, isDir);
+ case FileSystemEvent.DELETE:
+ return new ConstructableFileSystemDeleteEvent(batch.first.path, isDir);
+ case FileSystemEvent.MODIFY:
+ return new ConstructableFileSystemModifyEvent(
+ batch.first.path, isDir, false);
+ case FileSystemEvent.MOVE:
+ return null;
+ default: throw 'unreachable';
+ }
+ }
+
+ /// Returns one or more events that describe the change between the last known
+ /// state of [path] and its current state on the filesystem.
+ ///
+ /// This returns a list whose order should be reflected in the events emitted
+ /// to the user, unlike the batched events from [Directory.watch]. The
+ /// returned list may be empty, indicating that no changes occurred to [path]
+ /// (probably indicating that it was created and then immediately deleted).
+ List<FileSystemEvent> _eventsBasedOnFileSystem(String path) {
+ var fileExisted = _files.contains(path);
+ var dirExisted = _files.containsDir(path);
+ var fileExists = new File(path).existsSync();
+ var dirExists = new Directory(path).existsSync();
+
+ var events = <FileSystemEvent>[];
+ if (fileExisted) {
+ if (fileExists) {
+ events.add(new ConstructableFileSystemModifyEvent(path, false, false));
+ } else {
+ events.add(new ConstructableFileSystemDeleteEvent(path, false));
+ }
+ } else if (dirExisted) {
+ if (dirExists) {
+ // If we got contradictory events for a directory that used to exist and
+ // still exists, we need to rescan the whole thing in case it was
+ // replaced with a different directory.
+ events.add(new ConstructableFileSystemDeleteEvent(path, true));
+ events.add(new ConstructableFileSystemCreateEvent(path, true));
+ } else {
+ events.add(new ConstructableFileSystemDeleteEvent(path, true));
+ }
+ }
+
+ if (!fileExisted && fileExists) {
+ events.add(new ConstructableFileSystemCreateEvent(path, false));
+ } else if (!dirExisted && dirExists) {
+ events.add(new ConstructableFileSystemCreateEvent(path, true));
+ }
+
+ return events;
+ }
+
+ /// The callback that's run when the [Directory.watch] stream is closed.
+ /// Note that this is unlikely to happen on Windows, unless the system itself
+ /// closes the handle.
+ void _onDone() {
+ _watchSubscription = null;
+
+ // Emit remove events for any remaining files.
+ for (var file in _files.paths) {
+ _emitEvent(ChangeType.REMOVE, file);
+ }
+ _files.clear();
+ close();
+ }
+
+ /// Start or restart the underlying [Directory.watch] stream.
+ void _startWatch() {
+ // Batch the events together so that we can dedup events.
+ var innerStream = new Directory(path).watch(recursive: true);
+ _watchSubscription = innerStream.listen(_onEvent,
+ onError: _eventsController.addError,
+ onDone: _onDone);
+ }
+
+ /// Starts or restarts listing the watched directory to get an initial picture
+ /// of its state.
+ Future _listDir() {
+ assert(!isReady);
+ if (_initialListSubscription != null) _initialListSubscription.cancel();
+
+ _files.clear();
+ var completer = new Completer();
+ var stream = new Directory(path).list(recursive: true);
+ void handleEntity(entity) {
+ if (entity is! Directory) _files.add(entity.path);
+ }
+ _initialListSubscription = stream.listen(
+ handleEntity,
+ onError: _emitError,
+ onDone: completer.complete,
+ cancelOnError: true);
+ return completer.future;
+ }
+
+ /// Emit an event with the given [type] and [path].
+ void _emitEvent(ChangeType type, String path) {
+ if (!isReady) return;
+
+ _eventsController.add(new WatchEvent(type, path));
+ }
+
+ /// Emit an error, then close the watcher.
+ void _emitError(error, StackTrace stackTrace) {
+ _eventsController.addError(error, stackTrace);
+ close();
+ }
+}
diff --git a/packages/watcher/pubspec.yaml b/packages/watcher/pubspec.yaml
index bee3546..15c51c6 100644
--- a/packages/watcher/pubspec.yaml
+++ b/packages/watcher/pubspec.yaml
@@ -1,5 +1,5 @@
name: watcher
-version: 0.9.7+3
+version: 0.9.7+4
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/watcher
description: >
@@ -8,8 +8,7 @@
environment:
sdk: '>=1.9.0 <2.0.0'
dependencies:
- async: '^1.10.0'
- collection: '^1.0.0'
+ async: '>=1.10.0 <3.0.0'
path: '>=0.9.0 <2.0.0'
dev_dependencies:
benchmark_harness: '^1.0.4'
diff --git a/packages/watcher/test/directory_watcher/windows_test.dart b/packages/watcher/test/directory_watcher/windows_test.dart
index 4c77ced..55e40a9 100644
--- a/packages/watcher/test/directory_watcher/windows_test.dart
+++ b/packages/watcher/test/directory_watcher/windows_test.dart
@@ -1,25 +1,25 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-@TestOn('windows')
-
-import 'package:scheduled_test/scheduled_test.dart';
-import 'package:watcher/src/directory_watcher/windows.dart';
-import 'package:watcher/watcher.dart';
-
-import 'shared.dart';
-import '../utils.dart';
-
-void main() {
- watcherFactory = (dir) => new WindowsDirectoryWatcher(dir);
-
- setUp(createSandbox);
-
- sharedTests();
-
- test('DirectoryWatcher creates a WindowsDirectoryWatcher on Windows', () {
- expect(new DirectoryWatcher('.'),
- new isInstanceOf<WindowsDirectoryWatcher>());
- });
-}
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+@TestOn('windows')
+
+import 'package:scheduled_test/scheduled_test.dart';
+import 'package:watcher/src/directory_watcher/windows.dart';
+import 'package:watcher/watcher.dart';
+
+import 'shared.dart';
+import '../utils.dart';
+
+void main() {
+ watcherFactory = (dir) => new WindowsDirectoryWatcher(dir);
+
+ setUp(createSandbox);
+
+ sharedTests();
+
+ test('DirectoryWatcher creates a WindowsDirectoryWatcher on Windows', () {
+ expect(new DirectoryWatcher('.'),
+ new isInstanceOf<WindowsDirectoryWatcher>());
+ });
+}