Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
cd19bc60
Unverified
Commit
cd19bc60
authored
Sep 27, 2021
by
Jason Simmons
Committed by
GitHub
Sep 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not retry if pub get is run in offline mode (#90394)
parent
48e6758f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
9 deletions
+61
-9
pub.dart
packages/flutter_tools/lib/src/dart/pub.dart
+13
-9
pub_get_test.dart
...s/flutter_tools/test/general.shard/dart/pub_get_test.dart
+48
-0
No files found.
packages/flutter_tools/lib/src/dart/pub.dart
View file @
cd19bc60
...
...
@@ -27,6 +27,10 @@ const String _kPubEnvironmentKey = 'PUB_ENVIRONMENT';
/// The console environment key used by the pub tool to find the cache directory.
const
String
_kPubCacheEnvironmentKey
=
'PUB_CACHE'
;
/// The UNAVAILABLE exit code returned by the pub tool.
/// (see https://github.com/dart-lang/pub/blob/master/lib/src/exit_codes.dart)
const
int
_kPubExitCodeUnavailable
=
69
;
typedef
MessageFilter
=
String
Function
(
String
message
);
/// Represents Flutter-specific data that is added to the `PUB_ENVIRONMENT`
...
...
@@ -250,7 +254,7 @@ class _DefaultPub implements Pub {
context:
context
,
directory:
directory
,
failureMessage:
'pub
$command
failed'
,
retry:
tru
e
,
retry:
!
offlin
e
,
flutterRootOverride:
flutterRootOverride
,
);
status
.
stop
();
...
...
@@ -303,7 +307,7 @@ class _DefaultPub implements Pub {
int
attempts
=
0
;
int
duration
=
1
;
int
code
;
loop:
while
(
true
)
{
while
(
true
)
{
attempts
+=
1
;
code
=
await
_processUtils
.
stream
(
_pubCommand
(
arguments
),
...
...
@@ -311,15 +315,15 @@ class _DefaultPub implements Pub {
mapFunction:
filterWrapper
,
// may set versionSolvingFailed, lastPubMessage
environment:
await
_createPubEnvironment
(
context
,
flutterRootOverride
),
);
String
message
;
switch
(
code
)
{
case
69
:
// UNAVAILABLE in https://github.com/dart-lang/pub/blob/master/lib/src/exit_codes.dart
String
?
message
;
if
(
retry
)
{
if
(
code
==
_kPubExitCodeUnavailable
)
{
message
=
'server unavailable'
;
break
;
default
:
break
loop
;
}
}
if
(
message
==
null
)
{
break
;
}
assert
(
message
!=
null
);
versionSolvingFailed
=
false
;
_logger
.
printStatus
(
'
$failureMessage
(
$message
) -- attempting retry
$attempts
in
$duration
'
...
...
packages/flutter_tools/test/general.shard/dart/pub_get_test.dart
View file @
cd19bc60
...
...
@@ -594,6 +594,54 @@ void main() {
expect
(
processManager
,
hasNoRemainingExpectations
);
});
testWithoutContext
(
'pub get offline does not retry'
,
()
async
{
String
?
error
;
const
FakeCommand
pubGetCommand
=
FakeCommand
(
command:
<
String
>[
'bin/cache/dart-sdk/bin/dart'
,
'__deprecated_pub'
,
'--verbosity=warning'
,
'get'
,
'--no-precompile'
,
'--offline'
,
],
exitCode:
69
,
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
''
,
'PUB_ENVIRONMENT'
:
'flutter_cli:flutter_tests'
},
);
final
FakeProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
pubGetCommand
,
]);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Pub
pub
=
Pub
(
fileSystem:
fileSystem
,
logger:
logger
,
processManager:
processManager
,
usage:
TestUsage
(),
platform:
FakePlatform
(
environment:
const
<
String
,
String
>{},
),
botDetector:
const
BotDetectorAlwaysNo
(),
);
FakeAsync
().
run
((
FakeAsync
time
)
{
expect
(
logger
.
statusText
,
''
);
pub
.
get
(
context:
PubContext
.
flutterTests
,
offline:
true
).
then
((
void
value
)
{
error
=
'test completed unexpectedly'
;
},
onError:
(
dynamic
thrownError
)
{
error
=
'test failed unexpectedly:
$thrownError
'
;
});
time
.
elapse
(
const
Duration
(
milliseconds:
500
));
expect
(
logger
.
statusText
,
'Running "flutter pub get" in /...
\n
'
);
});
expect
(
logger
.
errorText
,
isEmpty
);
expect
(
error
,
'test failed unexpectedly: Exception: pub get failed (69; no message)'
);
expect
(
processManager
,
hasNoRemainingExpectations
);
});
testWithoutContext
(
'pub get 66 shows message from pub'
,
()
async
{
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment