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
f796e047
Unverified
Commit
f796e047
authored
Jul 16, 2020
by
Christopher Fujino
Committed by
GitHub
Jul 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Verbose process exceptions (#61552)
parent
9ef81927
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
13 deletions
+70
-13
os.dart
packages/flutter_tools/lib/src/base/os.dart
+1
-0
process.dart
packages/flutter_tools/lib/src/base/process.dart
+8
-1
os_test.dart
packages/flutter_tools/test/general.shard/base/os_test.dart
+26
-0
process_test.dart
...s/flutter_tools/test/general.shard/base/process_test.dart
+25
-4
common.dart
packages/flutter_tools/test/src/common.dart
+10
-8
No files found.
packages/flutter_tools/lib/src/base/os.dart
View file @
f796e047
...
@@ -226,6 +226,7 @@ class _PosixUtils extends OperatingSystemUtils {
...
@@ -226,6 +226,7 @@ class _PosixUtils extends OperatingSystemUtils {
_processUtils
.
runSync
(
_processUtils
.
runSync
(
<
String
>[
'unzip'
,
'-o'
,
'-q'
,
file
.
path
,
'-d'
,
targetDirectory
.
path
],
<
String
>[
'unzip'
,
'-o'
,
'-q'
,
file
.
path
,
'-d'
,
targetDirectory
.
path
],
throwOnError:
true
,
throwOnError:
true
,
verboseExceptions:
true
,
);
);
}
}
...
...
packages/flutter_tools/lib/src/base/process.dart
View file @
f796e047
...
@@ -231,6 +231,7 @@ abstract class ProcessUtils {
...
@@ -231,6 +231,7 @@ abstract class ProcessUtils {
RunResult
runSync
(
RunResult
runSync
(
List
<
String
>
cmd
,
{
List
<
String
>
cmd
,
{
bool
throwOnError
=
false
,
bool
throwOnError
=
false
,
bool
verboseExceptions
=
false
,
RunResultChecker
allowedFailures
,
RunResultChecker
allowedFailures
,
bool
hideStdout
=
false
,
bool
hideStdout
=
false
,
String
workingDirectory
,
String
workingDirectory
,
...
@@ -408,6 +409,7 @@ class _DefaultProcessUtils implements ProcessUtils {
...
@@ -408,6 +409,7 @@ class _DefaultProcessUtils implements ProcessUtils {
RunResult
runSync
(
RunResult
runSync
(
List
<
String
>
cmd
,
{
List
<
String
>
cmd
,
{
bool
throwOnError
=
false
,
bool
throwOnError
=
false
,
bool
verboseExceptions
=
false
,
RunResultChecker
allowedFailures
,
RunResultChecker
allowedFailures
,
bool
hideStdout
=
false
,
bool
hideStdout
=
false
,
String
workingDirectory
,
String
workingDirectory
,
...
@@ -449,7 +451,12 @@ class _DefaultProcessUtils implements ProcessUtils {
...
@@ -449,7 +451,12 @@ class _DefaultProcessUtils implements ProcessUtils {
}
}
if
(
failedExitCode
&&
throwOnError
)
{
if
(
failedExitCode
&&
throwOnError
)
{
runResult
.
throwException
(
'The command failed'
);
String
message
=
'The command failed'
;
if
(
verboseExceptions
)
{
message
=
'The command failed
\n
Stdout:
\n
${runResult.stdout}
\n
'
'Stderr:
\n
${runResult.stderr}
'
;
}
runResult
.
throwException
(
message
);
}
}
return
runResult
;
return
runResult
;
...
...
packages/flutter_tools/test/general.shard/base/os_test.dart
View file @
f796e047
...
@@ -89,6 +89,31 @@ void main() {
...
@@ -89,6 +89,31 @@ void main() {
});
});
});
});
testWithoutContext
(
'If unzip fails, include stderr in exception text'
,
()
{
const
String
exceptionMessage
=
'Something really bad happened.'
;
when
(
mockProcessManager
.
runSync
(
<
String
>[
'unzip'
,
'-o'
,
'-q'
,
null
,
'-d'
,
null
],
)).
thenReturn
(
ProcessResult
(
0
,
1
,
''
,
exceptionMessage
));
final
MockFileSystem
fileSystem
=
MockFileSystem
();
final
MockFile
mockFile
=
MockFile
();
final
MockDirectory
mockDirectory
=
MockDirectory
();
when
(
fileSystem
.
file
(
any
)).
thenReturn
(
mockFile
);
when
(
mockFile
.
readAsBytesSync
()).
thenThrow
(
const
FileSystemException
(
exceptionMessage
),
);
final
OperatingSystemUtils
osUtils
=
OperatingSystemUtils
(
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
platform:
FakePlatform
(
operatingSystem:
'linux'
),
processManager:
mockProcessManager
,
);
expect
(
()
=>
osUtils
.
unzip
(
mockFile
,
mockDirectory
),
throwsProcessException
(
message:
exceptionMessage
),
);
});
group
(
'gzip on Windows:'
,
()
{
group
(
'gzip on Windows:'
,
()
{
testWithoutContext
(
'verifyGzip returns false on a FileSystemException'
,
()
{
testWithoutContext
(
'verifyGzip returns false on a FileSystemException'
,
()
{
final
MockFileSystem
fileSystem
=
MockFileSystem
();
final
MockFileSystem
fileSystem
=
MockFileSystem
();
...
@@ -148,5 +173,6 @@ void main() {
...
@@ -148,5 +173,6 @@ void main() {
}
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockDirectory
extends
Mock
implements
Directory
{}
class
MockFileSystem
extends
Mock
implements
FileSystem
{}
class
MockFileSystem
extends
Mock
implements
FileSystem
{}
class
MockFile
extends
Mock
implements
File
{}
class
MockFile
extends
Mock
implements
File
{}
packages/flutter_tools/test/general.shard/base/process_test.dart
View file @
f796e047
...
@@ -286,12 +286,33 @@ void main() {
...
@@ -286,12 +286,33 @@ void main() {
expect
(
processUtils
.
runSync
(<
String
>[
'boohoo'
]).
exitCode
,
1
);
expect
(
processUtils
.
runSync
(<
String
>[
'boohoo'
]).
exitCode
,
1
);
});
});
testWithoutContext
(
' throws on failure with throwOnError'
,
()
async
{
testWithoutContext
(
'throws on failure with throwOnError'
,
()
async
{
const
String
stderr
=
'Something went wrong.'
;
when
(
mockProcessManager
.
runSync
(<
String
>[
'kaboom'
])).
thenReturn
(
when
(
mockProcessManager
.
runSync
(<
String
>[
'kaboom'
])).
thenReturn
(
ProcessResult
(
0
,
1
,
''
,
''
)
ProcessResult
(
0
,
1
,
''
,
stderr
),
);
try
{
processUtils
.
runSync
(<
String
>[
'kaboom'
],
throwOnError:
true
);
fail
(
'ProcessException expected.'
);
}
on
ProcessException
catch
(
e
)
{
expect
(
e
,
isA
<
ProcessException
>());
expect
(
e
.
message
.
contains
(
stderr
),
false
);
}
});
testWithoutContext
(
'throws with stderr in exception on failure with verboseExceptions'
,
()
async
{
const
String
stderr
=
'Something went wrong.'
;
when
(
mockProcessManager
.
runSync
(<
String
>[
'verybad'
])).
thenReturn
(
ProcessResult
(
0
,
1
,
''
,
stderr
),
);
expect
(
()
=>
processUtils
.
runSync
(
<
String
>[
'verybad'
],
throwOnError:
true
,
verboseExceptions:
true
,
),
throwsProcessException
(
message:
stderr
),
);
);
expect
(()
=>
processUtils
.
runSync
(<
String
>[
'kaboom'
],
throwOnError:
true
),
throwsA
(
isA
<
ProcessException
>()));
});
});
testWithoutContext
(
' does not throw on allowed Failures'
,
()
async
{
testWithoutContext
(
' does not throw on allowed Failures'
,
()
async
{
...
...
packages/flutter_tools/test/src/common.dart
View file @
f796e047
...
@@ -13,7 +13,7 @@ import 'package:vm_service/vm_service.dart' as vm_service;
...
@@ -13,7 +13,7 @@ import 'package:vm_service/vm_service.dart' as vm_service;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/context.dart'
;
import
'package:flutter_tools/src/base/context.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/
process
.dart'
;
import
'package:flutter_tools/src/base/
io
.dart'
;
import
'package:flutter_tools/src/commands/create.dart'
;
import
'package:flutter_tools/src/commands/create.dart'
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'package:flutter_tools/src/runner/flutter_command_runner.dart'
;
import
'package:flutter_tools/src/runner/flutter_command_runner.dart'
;
...
@@ -106,15 +106,17 @@ Matcher throwsToolExit({ int exitCode, Pattern message }) {
...
@@ -106,15 +106,17 @@ Matcher throwsToolExit({ int exitCode, Pattern message }) {
/// Matcher for [ToolExit]s.
/// Matcher for [ToolExit]s.
final
test_package
.
TypeMatcher
<
ToolExit
>
isToolExit
=
isA
<
ToolExit
>();
final
test_package
.
TypeMatcher
<
ToolExit
>
isToolExit
=
isA
<
ToolExit
>();
/// Matcher for functions that throw [ProcessExit].
/// Matcher for functions that throw [ProcessException].
Matcher
throwsProcessExit
(
[
dynamic
exitCode
])
{
Matcher
throwsProcessException
(
{
Pattern
message
})
{
return
exitCode
==
null
Matcher
matcher
=
isProcessException
;
?
throwsA
(
isProcessExit
)
if
(
message
!=
null
)
{
:
throwsA
(
allOf
(
isProcessExit
,
(
ProcessExit
e
)
=>
e
.
exitCode
==
exitCode
));
matcher
=
allOf
(
matcher
,
(
ProcessException
e
)
=>
e
.
message
?.
contains
(
message
));
}
return
throwsA
(
matcher
);
}
}
/// Matcher for [ProcessEx
it
]s.
/// Matcher for [ProcessEx
ception
]s.
final
test_package
.
TypeMatcher
<
ProcessEx
it
>
isProcessExit
=
isA
<
ProcessExit
>();
final
test_package
.
TypeMatcher
<
ProcessEx
ception
>
isProcessException
=
isA
<
ProcessException
>();
/// Creates a flutter project in the [temp] directory using the
/// Creates a flutter project in the [temp] directory using the
/// [arguments] list if specified, or `--no-pub` if not.
/// [arguments] list if specified, or `--no-pub` if not.
...
...
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