@@ -44,46 +44,46 @@ void main() {
4444 time.elapse (const Duration (milliseconds: 500 ));
4545 expect (testLogger.statusText,
4646 'Running "flutter pub get" in /...\n '
47- 'pub get failed (69 ) -- attempting retry 1 in 1 second...\n ' ,
47+ 'pub get failed (server unavailable ) -- attempting retry 1 in 1 second...\n ' ,
4848 );
4949 expect (processMock.lastPubEnvironment, contains ('flutter_cli:flutter_tests' ));
5050 expect (processMock.lastPubCache, isNull);
5151 time.elapse (const Duration (milliseconds: 500 ));
5252 expect (testLogger.statusText,
5353 'Running "flutter pub get" in /...\n '
54- 'pub get failed (69 ) -- attempting retry 1 in 1 second...\n '
55- 'pub get failed (69 ) -- attempting retry 2 in 2 seconds...\n ' ,
54+ 'pub get failed (server unavailable ) -- attempting retry 1 in 1 second...\n '
55+ 'pub get failed (server unavailable ) -- attempting retry 2 in 2 seconds...\n ' ,
5656 );
5757 time.elapse (const Duration (seconds: 1 ));
5858 expect (testLogger.statusText,
5959 'Running "flutter pub get" in /...\n '
60- 'pub get failed (69 ) -- attempting retry 1 in 1 second...\n '
61- 'pub get failed (69 ) -- attempting retry 2 in 2 seconds...\n ' ,
60+ 'pub get failed (server unavailable ) -- attempting retry 1 in 1 second...\n '
61+ 'pub get failed (server unavailable ) -- attempting retry 2 in 2 seconds...\n ' ,
6262 );
6363 time.elapse (const Duration (seconds: 100 )); // from t=0 to t=100
6464 expect (testLogger.statusText,
6565 'Running "flutter pub get" in /...\n '
66- 'pub get failed (69 ) -- attempting retry 1 in 1 second...\n '
67- 'pub get failed (69 ) -- attempting retry 2 in 2 seconds...\n '
68- 'pub get failed (69 ) -- attempting retry 3 in 4 seconds...\n ' // at t=1
69- 'pub get failed (69 ) -- attempting retry 4 in 8 seconds...\n ' // at t=5
70- 'pub get failed (69 ) -- attempting retry 5 in 16 seconds...\n ' // at t=13
71- 'pub get failed (69 ) -- attempting retry 6 in 32 seconds...\n ' // at t=29
72- 'pub get failed (69 ) -- attempting retry 7 in 64 seconds...\n ' , // at t=61
66+ 'pub get failed (server unavailable ) -- attempting retry 1 in 1 second...\n '
67+ 'pub get failed (server unavailable ) -- attempting retry 2 in 2 seconds...\n '
68+ 'pub get failed (server unavailable ) -- attempting retry 3 in 4 seconds...\n ' // at t=1
69+ 'pub get failed (server unavailable ) -- attempting retry 4 in 8 seconds...\n ' // at t=5
70+ 'pub get failed (server unavailable ) -- attempting retry 5 in 16 seconds...\n ' // at t=13
71+ 'pub get failed (server unavailable ) -- attempting retry 6 in 32 seconds...\n ' // at t=29
72+ 'pub get failed (server unavailable ) -- attempting retry 7 in 64 seconds...\n ' , // at t=61
7373 );
7474 time.elapse (const Duration (seconds: 200 )); // from t=0 to t=200
7575 expect (testLogger.statusText,
7676 'Running "flutter pub get" in /...\n '
77- 'pub get failed (69 ) -- attempting retry 1 in 1 second...\n '
78- 'pub get failed (69 ) -- attempting retry 2 in 2 seconds...\n '
79- 'pub get failed (69 ) -- attempting retry 3 in 4 seconds...\n '
80- 'pub get failed (69 ) -- attempting retry 4 in 8 seconds...\n '
81- 'pub get failed (69 ) -- attempting retry 5 in 16 seconds...\n '
82- 'pub get failed (69 ) -- attempting retry 6 in 32 seconds...\n '
83- 'pub get failed (69 ) -- attempting retry 7 in 64 seconds...\n '
84- 'pub get failed (69 ) -- attempting retry 8 in 64 seconds...\n ' // at t=39
85- 'pub get failed (69 ) -- attempting retry 9 in 64 seconds...\n ' // at t=103
86- 'pub get failed (69 ) -- attempting retry 10 in 64 seconds...\n ' , // at t=167
77+ 'pub get failed (server unavailable ) -- attempting retry 1 in 1 second...\n '
78+ 'pub get failed (server unavailable ) -- attempting retry 2 in 2 seconds...\n '
79+ 'pub get failed (server unavailable ) -- attempting retry 3 in 4 seconds...\n '
80+ 'pub get failed (server unavailable ) -- attempting retry 4 in 8 seconds...\n '
81+ 'pub get failed (server unavailable ) -- attempting retry 5 in 16 seconds...\n '
82+ 'pub get failed (server unavailable ) -- attempting retry 6 in 32 seconds...\n '
83+ 'pub get failed (server unavailable ) -- attempting retry 7 in 64 seconds...\n '
84+ 'pub get failed (server unavailable ) -- attempting retry 8 in 64 seconds...\n ' // at t=39
85+ 'pub get failed (server unavailable ) -- attempting retry 9 in 64 seconds...\n ' // at t=103
86+ 'pub get failed (server unavailable ) -- attempting retry 10 in 64 seconds...\n ' , // at t=167
8787 );
8888 });
8989 expect (testLogger.errorText, isEmpty);
@@ -97,6 +97,33 @@ void main() {
9797 Pub : () => const Pub (),
9898 });
9999
100+ testUsingContext ('pub get 66 shows message from pub' , () async {
101+ try {
102+ await pub.get (context: PubContext .flutterTests, checkLastModified: false );
103+ throw AssertionError ('pubGet did not fail' );
104+ } on ToolExit catch (error) {
105+ expect (error.message, 'pub get failed (66; err3)' );
106+ }
107+ expect (testLogger.statusText,
108+ 'Running "flutter pub get" in /...\n '
109+ 'out1\n '
110+ 'out2\n '
111+ 'out3\n '
112+ );
113+ expect (testLogger.errorText,
114+ 'err1\n '
115+ 'err2\n '
116+ 'err3\n '
117+ );
118+ }, overrides: < Type , Generator > {
119+ ProcessManager : () => MockProcessManager (66 , stderr: 'err1\n err2\n err3\n ' , stdout: 'out1\n out2\n out3\n ' ),
120+ FileSystem : () => MockFileSystem (),
121+ Platform : () => FakePlatform (
122+ environment: UnmodifiableMapView <String , String >(< String , String > {}),
123+ ),
124+ Pub : () => const Pub (),
125+ });
126+
100127 testUsingContext ('pub cache in root is used' , () async {
101128 String error;
102129
@@ -218,10 +245,12 @@ typedef StartCallback = void Function(List<dynamic> command);
218245
219246class MockProcessManager implements ProcessManager {
220247 MockProcessManager (this .fakeExitCode, {
248+ this .stdout = '' ,
221249 this .stderr = '' ,
222250 });
223251
224252 final int fakeExitCode;
253+ final String stdout;
225254 final String stderr;
226255
227256 String lastPubEnvironment;
@@ -240,6 +269,7 @@ class MockProcessManager implements ProcessManager {
240269 lastPubCache = environment['PUB_CACHE' ];
241270 return Future <Process >.value (mocks.createMockProcess (
242271 exitCode: fakeExitCode,
272+ stdout: stdout,
243273 stderr: stderr,
244274 ));
245275 }
0 commit comments