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

Unified Diff: sdk/lib/_internal/pub/test/pubspec_test.dart

Issue 169223010: Allow transformers to exclude and include assets. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub/test/pubspec_test.dart
diff --git a/sdk/lib/_internal/pub/test/pubspec_test.dart b/sdk/lib/_internal/pub/test/pubspec_test.dart
index f451f1fb1edfe9c315c91999a8f876bd7f351828..a730a14b514d98eb0fe02da7ee9f42b578d517c0 100644
--- a/sdk/lib/_internal/pub/test/pubspec_test.dart
+++ b/sdk/lib/_internal/pub/test/pubspec_test.dart
@@ -241,13 +241,14 @@ dependencies:
'"transformers.pkg" field must be a map');
});
- test("throws if a transformer's configuration contains a top-level key "
- "beginning with a dollar sign", () {
+ test("throws if a transformer's configuration contains an unknown "
+ "reserved key at the top level", () {
expectPubspecException('''
name: pkg
transformers: [{pkg: {\$key: "value"}}]''',
(pubspec) => pubspec.transformers,
- '"transformers.pkg" field cannot contain reserved field "\$key"');
+ 'Invalid transformer configuration for "transformers.pkg": '
+ 'Unknown reserved field "\$key"');
});
test("doesn't throw if a transformer's configuration contains a "
@@ -262,13 +263,55 @@ transformers:
expect(pkg.configuration["outer"]["\$inner"], equals("value"));
});
+ test("throws if the \$include value is not a string or list", () {
+ expectPubspecException('''
+name: pkg
+transformers:
+- pkg: {\$include: 123}''',
+ (pubspec) => pubspec.transformers,
+ 'Invalid transformer configuration for "transformers.pkg": '
+ '"\$include" field must be a string or list, but was "123"');
+ });
+
+ test("throws if the \$include list contains a non-string", () {
+ expectPubspecException('''
+name: pkg
+transformers:
+- pkg: {\$include: ["ok", 123, "alright", null]}''',
+ (pubspec) => pubspec.transformers,
+ 'Invalid transformer configuration for "transformers.pkg": '
+ '"\$include" list field may only contain strings, but contained '
+ '"123" and "null"');
+ });
+
+ test("throws if the \$exclude value is not a string or list", () {
+ expectPubspecException('''
+name: pkg
+transformers:
+- pkg: {\$exclude: 123}''',
+ (pubspec) => pubspec.transformers,
+ 'Invalid transformer configuration for "transformers.pkg": '
+ '"\$exclude" field must be a string or list, but was "123"');
+ });
+
+ test("throws if the \$exclude list contains a non-string", () {
+ expectPubspecException('''
+name: pkg
+transformers:
+- pkg: {\$exclude: ["ok", 123, "alright", null]}''',
+ (pubspec) => pubspec.transformers,
+ 'Invalid transformer configuration for "transformers.pkg": '
+ '"\$exclude" list field may only contain strings, but contained '
+ '"123" and "null"');
+ });
+
test("throws if a transformer is not from a dependency", () {
expectPubspecException('''
name: pkg
transformers: [foo]
''',
- (pubspec) => pubspec.transformers,
- '"transformers.foo" refers to a package that\'s not a dependency.');
+ (pubspec) => pubspec.transformers,
+ '"transformers.foo" refers to a package that\'s not a dependency.');
});
test("allows a transformer from a normal dependency", () {

Powered by Google App Engine
This is Rietveld 408576698