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
f753168c
Unverified
Commit
f753168c
authored
Oct 08, 2021
by
Christopher Fujino
Committed by
GitHub
Oct 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] add working directory to ProcessException when pub get fails (#91436)
parent
e1efeb31
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
0 deletions
+82
-0
pub.dart
packages/flutter_tools/lib/src/dart/pub.dart
+19
-0
pub_get_test.dart
...s/flutter_tools/test/general.shard/dart/pub_get_test.dart
+63
-0
No files found.
packages/flutter_tools/lib/src/dart/pub.dart
View file @
f753168c
...
@@ -263,6 +263,25 @@ class _DefaultPub implements Pub {
...
@@ -263,6 +263,25 @@ class _DefaultPub implements Pub {
// The exception is rethrown, so don't catch only Exceptions.
// The exception is rethrown, so don't catch only Exceptions.
}
catch
(
exception
)
{
// ignore: avoid_catches_without_on_clauses
}
catch
(
exception
)
{
// ignore: avoid_catches_without_on_clauses
status
?.
cancel
();
status
?.
cancel
();
if
(
exception
is
io
.
ProcessException
)
{
final
StringBuffer
buffer
=
StringBuffer
(
exception
.
message
);
buffer
.
writeln
(
'Working directory: "
$directory
"'
);
final
Map
<
String
,
String
>
env
=
await
_createPubEnvironment
(
context
,
flutterRootOverride
);
if
(
env
.
entries
.
isNotEmpty
)
{
buffer
.
writeln
(
'pub env: {'
);
for
(
final
MapEntry
<
String
,
String
>
entry
in
env
.
entries
)
{
buffer
.
writeln
(
' "
${entry.key}
": "
${entry.value}
",'
);
}
buffer
.
writeln
(
'}'
);
}
throw
io
.
ProcessException
(
exception
.
executable
,
exception
.
arguments
,
buffer
.
toString
(),
exception
.
errorCode
,
);
}
rethrow
;
rethrow
;
}
}
...
...
packages/flutter_tools/test/general.shard/dart/pub_get_test.dart
View file @
f753168c
...
@@ -8,6 +8,7 @@ import 'package:file/memory.dart';
...
@@ -8,6 +8,7 @@ import 'package:file/memory.dart';
import
'package:flutter_tools/src/base/bot_detector.dart'
;
import
'package:flutter_tools/src/base/bot_detector.dart'
;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
show
ProcessException
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
...
@@ -688,6 +689,68 @@ void main() {
...
@@ -688,6 +689,68 @@ void main() {
expect
(
processManager
,
hasNoRemainingExpectations
);
expect
(
processManager
,
hasNoRemainingExpectations
);
});
});
testWithoutContext
(
'pub get shows working directory on process exception'
,
()
async
{
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
FakeProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
FakeCommand
(
command:
const
<
String
>[
'bin/cache/dart-sdk/bin/dart'
,
'__deprecated_pub'
,
'--verbosity=warning'
,
'get'
,
'--no-precompile'
,
],
onRun:
()
{
throw
const
ProcessException
(
'bin/cache/dart-sdk/bin/dart'
,
<
String
>[
'__deprecated_pub'
,
'--verbosity=warning'
,
'get'
,
'--no-precompile'
,
],
'message'
,
1
,
);
},
exitCode:
66
,
stderr:
'err1
\n
err2
\n
err3
\n
'
,
stdout:
'out1
\n
out2
\n
out3
\n
'
,
environment:
const
<
String
,
String
>{
'FLUTTER_ROOT'
:
''
,
'PUB_ENVIRONMENT'
:
'flutter_cli:flutter_tests'
},
),
]);
final
Pub
pub
=
Pub
(
platform:
FakePlatform
(
environment:
const
<
String
,
String
>{}),
fileSystem:
fileSystem
,
logger:
logger
,
usage:
TestUsage
(),
botDetector:
const
BotDetectorAlwaysNo
(),
processManager:
processManager
,
);
await
expectLater
(
()
=>
pub
.
get
(
context:
PubContext
.
flutterTests
),
throwsA
(
isA
<
ProcessException
>().
having
(
(
ProcessException
error
)
=>
error
.
message
,
'message'
,
contains
(
'Working directory: "/"'
),
).
having
(
(
ProcessException
error
)
=>
error
.
message
,
'message'
,
contains
(
'"PUB_ENVIRONMENT": "flutter_cli:flutter_tests"'
),
),
),
);
expect
(
logger
.
statusText
,
'Running "flutter pub get" in /...
\n
'
);
expect
(
logger
.
errorText
,
isEmpty
);
expect
(
processManager
,
hasNoRemainingExpectations
);
});
testWithoutContext
(
'pub cache in root is used'
,
()
async
{
testWithoutContext
(
'pub cache in root is used'
,
()
async
{
String
?
error
;
String
?
error
;
final
FileSystem
fileSystem
=
MemoryFileSystem
.
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