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

Unified Diff: utils/tests/pub/sdk_constraint_test.dart

Issue 12092080: Validate packages against their SDK constraints. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 11 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
« no previous file with comments | « utils/tests/pub/pub_test.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/sdk_constraint_test.dart
diff --git a/utils/tests/pub/sdk_constraint_test.dart b/utils/tests/pub/sdk_constraint_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3f934b97b1dd747a1bb9d3d99250cdfa1858d042
--- /dev/null
+++ b/utils/tests/pub/sdk_constraint_test.dart
@@ -0,0 +1,121 @@
+// Copyright (c) 2012, 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 check_sdk_test;
+
+import "test_pub.dart";
+import "../../../pkg/unittest/lib/unittest.dart";
+
+main() {
+ initConfig();
+
+ for (var command in ["install", "update"]) {
+ var success = new RegExp(r"Dependencies installed!$");
+ if (command == "update") {
+ success = new RegExp(r"Dependencies updated!$");
+ }
+
+ integration("gives a friendly message if there are no constraints", () {
+ dir(appPath, [
+ pubspec({"name": "myapp"}),
+ ]).scheduleCreate();
+
+ schedulePub(args: [command], output: success);
+ });
+
+ integration("gives an error if the root package does not match", () {
+ dir(appPath, [
+ pubspec({
+ "name": "myapp",
+ "environment": {"sdk": ">2.0.0"}
+ })
+ ]).scheduleCreate();
+
+ schedulePub(args: [command],
+ error:
+ """
+ Some packages are not compatible with your SDK version 0.1.2+3:
+ - 'myapp' requires >2.0.0
+
+ You may be able to resolve this by upgrading to the latest Dart SDK
+ or adding a version constraint to use an older version of a package.
+ """);
+ });
+
+ integration("gives an error if some dependencies do not match", () {
+ // Using an SDK source, but this should be true of all sources.
+ dir(sdkPath, [
+ dir("pkg", [
+ dir("foo", [
+ libPubspec("foo", "0.0.1", sdk: ">0.1.3"),
+ libDir("foo")
+ ]),
+ dir("bar", [
+ libPubspec("bar", "0.0.1", sdk: ">0.1.1"),
+ libDir("bar")
+ ])
+ ])
+ ]).scheduleCreate();
+
+ dir(appPath, [
+ pubspec({
+ "name": "myapp",
+ "dependencies": {
+ "foo": { "sdk": "foo" },
+ "bar": { "sdk": "bar" }
+ },
+ "environment": {"sdk": ">2.0.0"}
+ })
+ ]).scheduleCreate();
+
+ schedulePub(args: [command],
+ error:
+ """
+ Some packages are not compatible with your SDK version 0.1.2+3:
+ - 'myapp' requires >2.0.0
+ - 'foo' requires >0.1.3
+
+ You may be able to resolve this by upgrading to the latest Dart SDK
+ or adding a version constraint to use an older version of a package.
+ """);
+ });
+
+ integration("gives an error if a transitive dependency doesn't match", () {
+ // Using an SDK source, but this should be true of all sources.
+ dir(sdkPath, [
+ dir("pkg", [
+ dir("foo", [
+ libPubspec("foo", "0.0.1", deps: [
+ {"sdk": "bar"}
+ ]),
+ libDir("foo")
+ ]),
+ dir("bar", [
+ libPubspec("bar", "0.0.1", sdk: "<0.1.1"),
+ libDir("bar")
+ ])
+ ])
+ ]).scheduleCreate();
+
+ dir(appPath, [
+ pubspec({
+ "name": "myapp",
+ "dependencies": {
+ "foo": { "sdk": "foo" }
+ }
+ })
+ ]).scheduleCreate();
+
+ schedulePub(args: [command],
+ error:
+ """
+ Some packages are not compatible with your SDK version 0.1.2+3:
+ - 'bar' requires <0.1.1
+
+ You may be able to resolve this by upgrading to the latest Dart SDK
+ or adding a version constraint to use an older version of a package.
+ """);
+ });
+ }
+}
« no previous file with comments | « utils/tests/pub/pub_test.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698