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
fa8bf67c
Unverified
Commit
fa8bf67c
authored
Jan 26, 2021
by
Jonah Williams
Committed by
GitHub
Jan 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] catch errors when getting cwd (#74744)
parent
384b4d1b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
error_handling_io.dart
packages/flutter_tools/lib/src/base/error_handling_io.dart
+4
-2
error_handling_io_test.dart
...tools/test/general.shard/base/error_handling_io_test.dart
+7
-2
No files found.
packages/flutter_tools/lib/src/base/error_handling_io.dart
View file @
fa8bf67c
...
@@ -102,7 +102,9 @@ class ErrorHandlingFileSystem extends ForwardingFileSystem {
...
@@ -102,7 +102,9 @@ class ErrorHandlingFileSystem extends ForwardingFileSystem {
static
bool
_noExitOnFailure
=
false
;
static
bool
_noExitOnFailure
=
false
;
@override
@override
Directory
get
currentDirectory
=>
directory
(
delegate
.
currentDirectory
);
Directory
get
currentDirectory
{
return
_runSync
(()
=>
directory
(
delegate
.
currentDirectory
),
platform:
_platform
);
}
@override
@override
File
file
(
dynamic
path
)
=>
ErrorHandlingFile
(
File
file
(
dynamic
path
)
=>
ErrorHandlingFile
(
...
@@ -710,7 +712,7 @@ void _handleWindowsException(Exception e, String message, int errorCode) {
...
@@ -710,7 +712,7 @@ void _handleWindowsException(Exception e, String message, int errorCode) {
switch
(
errorCode
)
{
switch
(
errorCode
)
{
case
kAccessDenied:
case
kAccessDenied:
errorMessage
=
errorMessage
=
'
$message
. The flutter tool cannot access the file.
\n
'
'
$message
. The flutter tool cannot access the file
or directory
.
\n
'
'Please ensure that the SDK and/or project is installed in a location '
'Please ensure that the SDK and/or project is installed in a location '
'that has read/write permissions for the current user.'
;
'that has read/write permissions for the current user.'
;
break
;
break
;
...
...
packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart
View file @
fa8bf67c
...
@@ -87,6 +87,7 @@ void setupReadMocks({
...
@@ -87,6 +87,7 @@ void setupReadMocks({
})
{
})
{
final
MockFile
mockFile
=
MockFile
();
final
MockFile
mockFile
=
MockFile
();
when
(
mockFileSystem
.
file
(
any
)).
thenReturn
(
mockFile
);
when
(
mockFileSystem
.
file
(
any
)).
thenReturn
(
mockFile
);
when
(
mockFileSystem
.
currentDirectory
).
thenThrow
(
FileSystemException
(
''
,
''
,
OSError
(
''
,
errorCode
)));
when
(
mockFile
.
readAsStringSync
(
when
(
mockFile
.
readAsStringSync
(
encoding:
anyNamed
(
'encoding'
),
encoding:
anyNamed
(
'encoding'
),
)).
thenThrow
(
FileSystemException
(
''
,
''
,
OSError
(
''
,
errorCode
)));
)).
thenThrow
(
FileSystemException
(
''
,
''
,
OSError
(
''
,
errorCode
)));
...
@@ -345,7 +346,7 @@ void main() {
...
@@ -345,7 +346,7 @@ void main() {
throwsToolExit
(
message:
expectedMessage
));
throwsToolExit
(
message:
expectedMessage
));
});
});
testWithoutContext
(
'When reading from a file without permission'
,
()
{
testWithoutContext
(
'When reading from a file
or directory
without permission'
,
()
{
setupReadMocks
(
setupReadMocks
(
mockFileSystem:
mockFileSystem
,
mockFileSystem:
mockFileSystem
,
fs:
fs
,
fs:
fs
,
...
@@ -357,6 +358,8 @@ void main() {
...
@@ -357,6 +358,8 @@ void main() {
const
String
expectedMessage
=
'Flutter failed to read a file at'
;
const
String
expectedMessage
=
'Flutter failed to read a file at'
;
expect
(()
=>
file
.
readAsStringSync
(),
expect
(()
=>
file
.
readAsStringSync
(),
throwsToolExit
(
message:
expectedMessage
));
throwsToolExit
(
message:
expectedMessage
));
expect
(()
=>
fs
.
currentDirectory
,
throwsToolExit
(
message:
'The flutter tool cannot access the file or directory'
));
});
});
});
});
...
@@ -579,7 +582,7 @@ void main() {
...
@@ -579,7 +582,7 @@ void main() {
throwsToolExit
(
message:
expectedMessage
));
throwsToolExit
(
message:
expectedMessage
));
});
});
testWithoutContext
(
'When reading from a file without permission'
,
()
{
testWithoutContext
(
'When reading from a file
or directory
without permission'
,
()
{
setupReadMocks
(
setupReadMocks
(
mockFileSystem:
mockFileSystem
,
mockFileSystem:
mockFileSystem
,
fs:
fs
,
fs:
fs
,
...
@@ -591,6 +594,8 @@ void main() {
...
@@ -591,6 +594,8 @@ void main() {
const
String
expectedMessage
=
'Flutter failed to read a file at'
;
const
String
expectedMessage
=
'Flutter failed to read a file at'
;
expect
(()
=>
file
.
readAsStringSync
(),
expect
(()
=>
file
.
readAsStringSync
(),
throwsToolExit
(
message:
expectedMessage
));
throwsToolExit
(
message:
expectedMessage
));
expect
(()
=>
fs
.
currentDirectory
,
throwsToolExit
(
message:
'The flutter tool cannot access the file or directory'
));
});
});
});
});
...
...
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