| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'descriptor.dart' as d; | 5 import 'descriptor.dart' as d; |
| 6 import 'test_pub.dart'; | 6 import 'test_pub.dart'; |
| 7 import '../lib/src/barback.dart' as barback; | 7 import '../lib/src/barback.dart' as barback; |
| 8 import '../lib/src/version.dart'; | 8 import '../lib/src/version.dart'; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| 11 initConfig(); | 11 initConfig(); |
| 12 | 12 |
| 13 var current = barback.supportedVersions.min.toString(); | 13 var constraint = barback.pubConstraints["barback"]; |
| 14 var previous = new Version(barback.supportedVersions.min.major, | 14 var current = constraint.min.toString(); |
| 15 barback.supportedVersions.min.minor - 1, 0).toString(); | 15 var previous = new Version(constraint.min.major, constraint.min.minor - 1, 0) |
| 16 var nextPatch = barback.supportedVersions.min.nextPatch.toString(); | 16 .toString(); |
| 17 var max = barback.supportedVersions.max.toString(); | 17 var nextPatch = constraint.min.nextPatch.toString(); |
| 18 var max = constraint.max.toString(); |
| 19 |
| 20 var sourceMapsVersion = barback.pubConstraints["source_maps"].min.toString(); |
| 21 var stackTraceVersion = barback.pubConstraints["stack_trace"].min.toString(); |
| 18 | 22 |
| 19 forBothPubGetAndUpgrade((command) { | 23 forBothPubGetAndUpgrade((command) { |
| 20 integration("implicitly constrains barback to versions pub supports", () { | 24 integration("implicitly constrains barback to versions pub supports", () { |
| 21 servePackages([ | 25 servePackages([ |
| 22 packageMap("barback", previous), | 26 packageMap("barback", previous), |
| 23 packageMap("barback", current), | 27 packageMap("barback", current), |
| 24 packageMap("barback", nextPatch), | 28 packageMap("barback", nextPatch), |
| 25 packageMap("barback", max) | 29 packageMap("barback", max), |
| 30 packageMap("source_maps", sourceMapsVersion), |
| 31 packageMap("stack_trace", stackTraceVersion) |
| 26 ]); | 32 ]); |
| 27 | 33 |
| 28 d.appDir({ | 34 d.appDir({ |
| 29 "barback": "any" | 35 "barback": "any" |
| 30 }).create(); | 36 }).create(); |
| 31 | 37 |
| 32 pubCommand(command); | 38 pubCommand(command); |
| 33 | 39 |
| 34 d.packagesDir({ | 40 d.packagesDir({ |
| 35 "barback": barback.supportedVersions.min.nextPatch.toString() | 41 "barback": nextPatch |
| 36 }).validate(); | 42 }).validate(); |
| 37 }); | 43 }); |
| 38 | 44 |
| 39 integration("discovers transitive dependency on barback", () { | 45 integration("discovers transitive dependency on barback", () { |
| 40 servePackages([ | 46 servePackages([ |
| 41 packageMap("barback", previous), | 47 packageMap("barback", previous), |
| 42 packageMap("barback", current), | 48 packageMap("barback", current), |
| 43 packageMap("barback", nextPatch), | 49 packageMap("barback", nextPatch), |
| 44 packageMap("barback", max) | 50 packageMap("barback", max), |
| 51 packageMap("source_maps", sourceMapsVersion), |
| 52 packageMap("stack_trace", stackTraceVersion) |
| 45 ]); | 53 ]); |
| 46 | 54 |
| 47 d.dir("foo", [ | 55 d.dir("foo", [ |
| 48 d.libDir("foo", "foo 0.0.1"), | 56 d.libDir("foo", "foo 0.0.1"), |
| 49 d.libPubspec("foo", "0.0.1", deps: { | 57 d.libPubspec("foo", "0.0.1", deps: { |
| 50 "barback": "any" | 58 "barback": "any" |
| 51 }) | 59 }) |
| 52 ]).create(); | 60 ]).create(); |
| 53 | 61 |
| 54 d.appDir({ | 62 d.appDir({ |
| 55 "foo": {"path": "../foo"} | 63 "foo": {"path": "../foo"} |
| 56 }).create(); | 64 }).create(); |
| 57 | 65 |
| 58 pubCommand(command); | 66 pubCommand(command); |
| 59 | 67 |
| 60 d.packagesDir({ | 68 d.packagesDir({ |
| 61 "barback": nextPatch, | 69 "barback": nextPatch, |
| 62 "foo": "0.0.1" | 70 "foo": "0.0.1" |
| 63 }).validate(); | 71 }).validate(); |
| 64 }); | 72 }); |
| 65 | 73 |
| 66 integration("pub's implicit constraint uses the same source and " | 74 integration("pub's implicit constraint uses the same source and " |
| 67 "description as the explicit one", () { | 75 "description as a dependency override", () { |
| 76 servePackages([ |
| 77 packageMap("source_maps", sourceMapsVersion), |
| 78 packageMap("stack_trace", stackTraceVersion) |
| 79 ]); |
| 80 |
| 68 d.dir('barback', [ | 81 d.dir('barback', [ |
| 69 d.libDir('barback', 'barback $current'), | 82 d.libDir('barback', 'barback $current'), |
| 70 d.libPubspec('barback', current) | 83 d.libPubspec('barback', current), |
| 71 ]).create(); | 84 ]).create(); |
| 72 | 85 |
| 73 d.dir(appPath, [ | 86 d.dir(appPath, [ |
| 74 d.appPubspec({ | 87 d.pubspec({ |
| 75 "barback": {"path": "../barback"} | 88 "name": "myapp", |
| 89 "dependency_overrides": { |
| 90 "barback": {"path": "../barback"} |
| 91 } |
| 76 }) | 92 }) |
| 77 ]).create(); | 93 ]).create(); |
| 78 | 94 |
| 79 pubCommand(command); | 95 pubCommand(command); |
| 80 | 96 |
| 81 d.packagesDir({ | 97 d.packagesDir({ |
| 82 "barback": current | 98 "barback": current |
| 83 }).validate(); | 99 }).validate(); |
| 84 }); | 100 }); |
| 85 }); | 101 }); |
| 86 | 102 |
| 87 integration("unlock if the locked version doesn't meet pub's constraint", () { | 103 integration("unlock if the locked version doesn't meet pub's constraint", () { |
| 88 servePackages([ | 104 servePackages([ |
| 89 packageMap("barback", previous), | 105 packageMap("barback", previous), |
| 90 packageMap("barback", current) | 106 packageMap("barback", current), |
| 107 packageMap("source_maps", sourceMapsVersion), |
| 108 packageMap("stack_trace", stackTraceVersion) |
| 91 ]); | 109 ]); |
| 92 | 110 |
| 93 d.appDir({"barback": "any"}).create(); | 111 d.appDir({"barback": "any"}).create(); |
| 94 | 112 |
| 95 // Hand-create a lockfile to pin barback to an older version. | 113 // Hand-create a lockfile to pin barback to an older version. |
| 96 createLockFile("myapp", hosted: { | 114 createLockFile("myapp", hosted: { |
| 97 "barback": previous | 115 "barback": previous |
| 98 }); | 116 }); |
| 99 | 117 |
| 100 pubGet(); | 118 pubGet(); |
| 101 | 119 |
| 102 // It should be upgraded. | 120 // It should be upgraded. |
| 103 d.packagesDir({ | 121 d.packagesDir({ |
| 104 "barback": current | 122 "barback": current |
| 105 }).validate(); | 123 }).validate(); |
| 106 }); | 124 }); |
| 107 | 125 |
| 108 integration("includes pub in the error if a solve failed because there " | 126 integration("includes pub in the error if a solve failed because there " |
| 109 "is no version available", () { | 127 "is no version available", () { |
| 110 servePackages([ | 128 servePackages([ |
| 111 packageMap("barback", previous) | 129 packageMap("barback", previous), |
| 130 packageMap("source_maps", sourceMapsVersion), |
| 131 packageMap("stack_trace", stackTraceVersion) |
| 112 ]); | 132 ]); |
| 113 | 133 |
| 114 d.appDir({"barback": "any"}).create(); | 134 d.appDir({"barback": "any"}).create(); |
| 115 | 135 |
| 116 pubGet(error: """ | 136 pubGet(error: """ |
| 117 Package barback has no versions that match >=$current <$max derived from: | 137 Package barback 0.12.0 does not match >=$current <$max derived from: |
| 118 - myapp 0.0.0 depends on version any | 138 - myapp 0.0.0 depends on version any |
| 119 - pub itself depends on version >=$current <$max"""); | 139 - pub itself depends on version >=$current <$max"""); |
| 120 }); | 140 }); |
| 121 | 141 |
| 122 integration("includes pub in the error if a solve failed because there " | 142 integration("includes pub in the error if a solve failed because there " |
| 123 "is a disjoint constraint", () { | 143 "is a disjoint constraint", () { |
| 124 servePackages([ | 144 servePackages([ |
| 125 packageMap("barback", current) | 145 packageMap("barback", previous), |
| 146 packageMap("barback", current), |
| 147 packageMap("source_maps", sourceMapsVersion), |
| 148 packageMap("stack_trace", stackTraceVersion) |
| 126 ]); | 149 ]); |
| 127 | 150 |
| 128 d.appDir({"barback": previous}).create(); | 151 d.appDir({"barback": previous}).create(); |
| 129 | 152 |
| 130 pubGet(error: """ | 153 pubGet(error: """ |
| 131 Incompatible version constraints on barback: | 154 Incompatible version constraints on barback: |
| 132 - myapp 0.0.0 depends on version $previous | 155 - myapp 0.0.0 depends on version $previous |
| 133 - pub itself depends on version >=$current <$max"""); | 156 - pub itself depends on version >=$current <$max"""); |
| 134 }); | 157 }); |
| 135 } | 158 } |
| OLD | NEW |