@@ -48,6 +48,7 @@ void main() {
4848 // all output we see the precompilation messages as well.
4949 expect (pub.stdout, emits ('Resolving dependencies...' ));
5050 expect (pub.stdout, emits ('Downloading packages...' ));
51+ expect (pub.stdout, emits (startsWith ('No dependencies would change in ' )));
5152 expect (pub.stdout, emits ('Building package executable...' ));
5253 expect (pub.stdout, emitsThrough ('ok' ));
5354 await pub.shouldExit ();
@@ -66,6 +67,102 @@ void main() {
6667
6768 test ('validate resolution before recompilation' , () async {
6869 final server = await servePackages ();
70+ server.serve (
71+ 'foo' ,
72+ '1.0.0' ,
73+ deps: {
74+ 'bar' : 'any' ,
75+ },
76+ contents: [
77+ d.dir ('bin' , [
78+ d.file ('foo.dart' , 'import "package:bar/bar.dart"; main() => bar();' ),
79+ ]),
80+ ],
81+ );
82+
83+ server.serve (
84+ 'bar' ,
85+ '1.0.0' ,
86+ contents: [
87+ d.dir ('lib' , [
88+ d.file ('bar.dart' , 'bar() => print("original");' ),
89+ ]),
90+ ],
91+ );
92+
93+ await runPub (
94+ args: ['global' , 'activate' , 'foo' ],
95+ );
96+
97+ await runPub (
98+ args: ['global' , 'run' , 'foo' ],
99+ output: 'original' ,
100+ );
101+
102+ server.serve (
103+ 'bar' ,
104+ '1.0.0' ,
105+ contents: [
106+ d.dir ('lib' , [
107+ d.file ('foo.dart' , 'foo() => print("updated");' ),
108+ ]),
109+ ],
110+ );
111+
112+ await runPub (
113+ args: ['global' , 'run' , 'foo' ],
114+ environment: {
115+ 'DART_ROOT' : p.join (d.sandbox, 'dart' ),
116+ // Updated sdk version makes the old snapshot obsolete
117+ '_PUB_TEST_SDK_VERSION' : '3.2.1+4' ,
118+ },
119+ output: contains ('~ bar 1.0.0 (was 1.0.0)' ),
120+ error: allOf (
121+ contains (
122+ 'The current activation of `foo` cannot resolve to the same set of '
123+ 'dependencies.' ,
124+ ),
125+ contains (
126+ "The existing content-hash from pubspec.lock doesn't match "
127+ 'contents for:' ,
128+ ),
129+ contains ('Try reactivating the package' ),
130+ ),
131+ exitCode: DATA ,
132+ );
133+
134+ await d.dir ('dart' , [
135+ d.dir ('packages' , [
136+ d.dir ('bar' , [
137+ // Doesn't fulfill constraint, but doesn't satisfy pubspec.lock.
138+ d.libPubspec ('bar' , '2.0.0' , deps: {}),
139+ ]),
140+ ]),
141+ ]).create ();
142+ await runPub (
143+ args: ['global' , 'run' , 'foo' ],
144+ environment: {
145+ 'DART_ROOT' : p.join (d.sandbox, 'dart' ),
146+ '_PUB_TEST_SDK_VERSION' : '3.2.1+4' ,
147+ },
148+ error: allOf (
149+ contains (
150+ 'The existing content-hash from pubspec.lock doesn\' t match '
151+ 'contents for:' ,
152+ ),
153+ contains (
154+ 'The current activation of `foo` cannot resolve to the same '
155+ 'set of dependencies.' ,
156+ ),
157+ contains ('Try reactivating the package' ),
158+ ),
159+ exitCode: DATA ,
160+ );
161+ });
162+
163+ test ('validate resolution before recompilation - updated sdk package' ,
164+ () async {
165+ final server = await servePackages ();
69166 server.serve (
70167 'foo' ,
71168 '1.0.0' ,
@@ -120,9 +217,12 @@ void main() {
120217 'DART_ROOT' : p.join (d.sandbox, 'dart' ),
121218 '_PUB_TEST_SDK_VERSION' : '3.2.1+4' ,
122219 },
220+ output: contains ('> bar 1.2.0 from sdk dart (was 1.0.0 from sdk dart)' ),
123221 error: allOf (
124- contains ('The package `foo` as currently activated cannot resolve to '
125- 'the same packages' ),
222+ contains (
223+ 'The current activation of `foo` is not compatible with your '
224+ 'current SDK.' ,
225+ ),
126226 contains ('Try reactivating the package' ),
127227 ),
128228 exitCode: DATA ,
0 commit comments