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 'package:pub_semver/pub_semver.dart'; | 5 import 'package:pub_semver/pub_semver.dart'; |
6 | 6 |
7 import 'descriptor.dart' as d; | 7 import 'descriptor.dart' as d; |
8 import 'test_pub.dart'; | 8 import 'test_pub.dart'; |
9 import '../lib/src/barback.dart' as barback; | 9 import '../lib/src/barback.dart' as barback; |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 builder.serve("stack_trace", max("stack_trace")); | 21 builder.serve("stack_trace", max("stack_trace")); |
22 builder.serve("source_span", current("source_span")); | 22 builder.serve("source_span", current("source_span")); |
23 }); | 23 }); |
24 | 24 |
25 d.appDir({ | 25 d.appDir({ |
26 "barback": "any" | 26 "barback": "any" |
27 }).create(); | 27 }).create(); |
28 | 28 |
29 pubCommand(command); | 29 pubCommand(command); |
30 | 30 |
31 d.packagesDir({"stack_trace": nextPatch("stack_trace")}).validate(); | 31 d.packagesDir({ |
| 32 "stack_trace": nextPatch("stack_trace") |
| 33 }).validate(); |
32 }); | 34 }); |
33 | 35 |
34 integration("pub's implicit constraint uses the same source and " | 36 integration( |
35 "description as a dependency override", () { | 37 "pub's implicit constraint uses the same source and " |
| 38 "description as a dependency override", |
| 39 () { |
36 servePackages((builder) { | 40 servePackages((builder) { |
37 builder.serve("barback", current("barback")); | 41 builder.serve("barback", current("barback")); |
38 builder.serve("stack_trace", nextPatch("stack_trace")); | 42 builder.serve("stack_trace", nextPatch("stack_trace")); |
39 builder.serve("source_span", current("source_span")); | 43 builder.serve("source_span", current("source_span")); |
40 }); | 44 }); |
41 | 45 |
42 d.dir("stack_trace", [ | 46 d.dir( |
43 d.libDir("stack_trace", 'stack_trace ${current("stack_trace")}'), | 47 "stack_trace", |
44 d.libPubspec("stack_trace", current("stack_trace")) | 48 [ |
45 ]).create(); | 49 d.libDir("stack_trace", 'stack_trace ${current("stack_trace")}'), |
| 50 d.libPubspec("stack_trace", current("stack_trace"))]).create(); |
46 | 51 |
47 d.dir(appPath, [ | 52 d.dir(appPath, [d.pubspec({ |
48 d.pubspec({ | |
49 "name": "myapp", | 53 "name": "myapp", |
50 "dependencies": {"barback": "any"}, | 54 "dependencies": { |
| 55 "barback": "any" |
| 56 }, |
51 "dependency_overrides": { | 57 "dependency_overrides": { |
52 "stack_trace": {"path": "../stack_trace"}, | 58 "stack_trace": { |
| 59 "path": "../stack_trace" |
| 60 }, |
53 } | 61 } |
54 }) | 62 })]).create(); |
55 ]).create(); | |
56 | 63 |
57 pubCommand(command); | 64 pubCommand(command); |
58 | 65 |
59 // Validate that we're using the path dependency version of stack_trace | 66 // Validate that we're using the path dependency version of stack_trace |
60 // rather than the hosted version. | 67 // rather than the hosted version. |
61 d.packagesDir({ | 68 d.packagesDir({ |
62 "stack_trace": current("stack_trace") | 69 "stack_trace": current("stack_trace") |
63 }).validate(); | 70 }).validate(); |
64 }); | 71 }); |
65 | 72 |
66 integration("doesn't add a constraint if barback isn't in the package " | 73 integration( |
67 "graph", () { | 74 "doesn't add a constraint if barback isn't in the package " "graph", |
| 75 () { |
68 servePackages((builder) { | 76 servePackages((builder) { |
69 builder.serve("stack_trace", previous("stack_trace")); | 77 builder.serve("stack_trace", previous("stack_trace")); |
70 builder.serve("stack_trace", current("stack_trace")); | 78 builder.serve("stack_trace", current("stack_trace")); |
71 builder.serve("stack_trace", nextPatch("stack_trace")); | 79 builder.serve("stack_trace", nextPatch("stack_trace")); |
72 builder.serve("stack_trace", max("stack_trace")); | 80 builder.serve("stack_trace", max("stack_trace")); |
73 builder.serve("source_span", current("source_span")); | 81 builder.serve("source_span", current("source_span")); |
74 }); | 82 }); |
75 | 83 |
76 d.appDir({ | 84 d.appDir({ |
77 "stack_trace": "any" | 85 "stack_trace": "any" |
78 }).create(); | 86 }).create(); |
79 | 87 |
80 pubCommand(command); | 88 pubCommand(command); |
81 | 89 |
82 d.packagesDir({"stack_trace": max("stack_trace")}).validate(); | 90 d.packagesDir({ |
| 91 "stack_trace": max("stack_trace") |
| 92 }).validate(); |
83 }); | 93 }); |
84 }); | 94 }); |
85 | 95 |
86 integration("unlocks if the locked version doesn't meet pub's " | 96 integration( |
87 "constraint", () { | 97 "unlocks if the locked version doesn't meet pub's " "constraint", |
| 98 () { |
88 servePackages((builder) { | 99 servePackages((builder) { |
89 builder.serve("barback", current("barback")); | 100 builder.serve("barback", current("barback")); |
90 builder.serve("stack_trace", previous("stack_trace")); | 101 builder.serve("stack_trace", previous("stack_trace")); |
91 builder.serve("stack_trace", current("stack_trace")); | 102 builder.serve("stack_trace", current("stack_trace")); |
92 builder.serve("source_span", current("source_span")); | 103 builder.serve("source_span", current("source_span")); |
93 }); | 104 }); |
94 | 105 |
95 d.appDir({"barback": "any"}).create(); | 106 d.appDir({ |
| 107 "barback": "any" |
| 108 }).create(); |
96 | 109 |
97 // Hand-create a lockfile to pin the package to an older version. | 110 // Hand-create a lockfile to pin the package to an older version. |
98 createLockFile("myapp", hosted: { | 111 createLockFile("myapp", hosted: { |
99 "barback": current("barback"), | 112 "barback": current("barback"), |
100 "stack_trace": previous("stack_trace") | 113 "stack_trace": previous("stack_trace") |
101 }); | 114 }); |
102 | 115 |
103 pubGet(); | 116 pubGet(); |
104 | 117 |
105 // It should be upgraded. | 118 // It should be upgraded. |
106 d.packagesDir({ | 119 d.packagesDir({ |
107 "stack_trace": current("stack_trace") | 120 "stack_trace": current("stack_trace") |
108 }).validate(); | 121 }).validate(); |
109 }); | 122 }); |
110 } | 123 } |
111 | 124 |
112 String current(String packageName) => | 125 String current(String packageName) => |
113 barback.pubConstraints[packageName].min.toString(); | 126 barback.pubConstraints[packageName].min.toString(); |
114 | 127 |
115 String previous(String packageName) { | 128 String previous(String packageName) { |
116 var constraint = barback.pubConstraints[packageName]; | 129 var constraint = barback.pubConstraints[packageName]; |
117 return new Version(constraint.min.major, constraint.min.minor - 1, 0) | 130 return new Version( |
118 .toString(); | 131 constraint.min.major, |
| 132 constraint.min.minor - 1, |
| 133 0).toString(); |
119 } | 134 } |
120 | 135 |
121 String nextPatch(String packageName) => | 136 String nextPatch(String packageName) => |
122 barback.pubConstraints[packageName].min.nextPatch.toString(); | 137 barback.pubConstraints[packageName].min.nextPatch.toString(); |
123 | 138 |
124 String max(String packageName) => | 139 String max(String packageName) => |
125 barback.pubConstraints[packageName].max.toString(); | 140 barback.pubConstraints[packageName].max.toString(); |
OLD | NEW |