Index: sdk/lib/_internal/pub/test/build/warns_on_assets_paths_test.dart |
diff --git a/sdk/lib/_internal/pub/test/build/warns_on_assets_paths_test.dart b/sdk/lib/_internal/pub/test/build/warns_on_assets_paths_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..67eb1b5925ae2f0a19faca1fe9a8b2ddeccf7bbb |
--- /dev/null |
+++ b/sdk/lib/_internal/pub/test/build/warns_on_assets_paths_test.dart |
@@ -0,0 +1,97 @@ |
+// Copyright (c) 2013, 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. |
+ |
+library pub_tests; |
+ |
+import 'package:path/path.dart' as path; |
+ |
+import '../descriptor.dart' as d; |
+import '../test_pub.dart'; |
+ |
+getWarningRegExp(String assetsPath) => new RegExp( |
+ '^Warning: Pub reserves paths containing "assets" for using assets from ' |
+ 'packages\\. Please rename the path "$assetsPath"\\.\$'); |
+ |
+main() { |
+ initConfig(); |
+ |
+ integration('warns user about assets dir in the root of "web"', () { |
+ d.dir(appPath, [ |
+ d.appPubspec(), |
+ d.dir('web', [ |
+ d.file('index.html'), |
+ d.dir('assets') |
+ ]) |
+ ]).create(); |
+ |
+ var assetsPath = path.join('web', 'assets'); |
+ schedulePub(args: ['build'], |
+ error: getWarningRegExp(assetsPath), |
+ exitCode: 0); |
+ }); |
+ |
+ integration('warns user about assets dir nested anywhere in "web"', () { |
+ d.dir(appPath, [ |
+ d.appPubspec(), |
+ d.dir('web', [ |
+ d.file('index.html'), |
+ d.dir('foo', [ |
+ d.dir('assets') |
+ ]) |
+ ]) |
+ ]).create(); |
+ |
+ var assetsPath = path.join('web', 'foo', 'assets'); |
+ schedulePub(args: ['build'], |
+ error: getWarningRegExp(assetsPath), |
+ exitCode: 0); |
+ }); |
+ |
+ integration('warns user about assets file in the root of "web"', () { |
+ d.dir(appPath, [ |
+ d.appPubspec(), |
+ d.dir('web', [ |
+ d.file('index.html'), |
+ d.file('assets') |
+ ]) |
+ ]).create(); |
+ |
+ var assetsPath = path.join('web', 'assets'); |
+ schedulePub(args: ['build'], |
+ error: getWarningRegExp(assetsPath), |
+ exitCode: 0); |
+ }); |
+ |
+ integration('warns user about assets file nested anywhere in "web"', () { |
+ d.dir(appPath, [ |
+ d.appPubspec(), |
+ d.dir('web', [ |
+ d.file('index.html'), |
+ d.dir('foo', [ |
+ d.file('assets') |
+ ]) |
+ ]) |
+ ]).create(); |
+ |
+ var assetsPath = path.join('web', 'foo', 'assets'); |
+ schedulePub(args: ['build'], |
+ error: getWarningRegExp(assetsPath), |
+ exitCode: 0); |
+ }); |
+ |
+ integration('does not warn if no assets dir or file anywhere in "web"', () { |
+ d.dir(appPath, [ |
+ d.appPubspec(), |
+ d.dir('web', [ |
+ d.file('index.html'), |
+ d.dir('foo') |
+ ]) |
+ ]).create(); |
+ |
+ schedulePub(args: ['build'], |
+ error: new RegExp( |
+ r'^(?!Warning: Pub reserves paths containing "assets").*$'), |
+ exitCode: 0); |
+ }); |
+} |