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
f766871e
Unverified
Commit
f766871e
authored
Nov 13, 2019
by
Emmanuel Garcia
Committed by
GitHub
Nov 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forward ProcessException to error handlers (#44783)
parent
01f4f1ac
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
153 additions
and
27 deletions
+153
-27
gradle.dart
packages/flutter_tools/lib/src/android/gradle.dart
+33
-24
gradle_errors.dart
packages/flutter_tools/lib/src/android/gradle_errors.dart
+1
-1
gradle_errors_test.dart
..._tools/test/general.shard/android/gradle_errors_test.dart
+2
-2
gradle_test.dart
...flutter_tools/test/general.shard/android/gradle_test.dart
+117
-0
No files found.
packages/flutter_tools/lib/src/android/gradle.dart
View file @
f766871e
...
...
@@ -334,39 +334,48 @@ Future<void> buildGradleApp({
}
command
.
add
(
assembleTask
);
final
Stopwatch
sw
=
Stopwatch
()..
start
();
int
exitCode
=
1
;
GradleHandledError
detectedGradleError
;
String
detectedGradleErrorLine
;
String
consumeLog
(
String
line
)
{
// This message was removed from first-party plugins,
// but older plugin versions still display this message.
if
(
androidXPluginWarningRegex
.
hasMatch
(
line
))
{
// Don't pipe.
return
null
;
}
if
(
detectedGradleError
!=
null
)
{
// Pipe stdout/stderr from Gradle.
return
line
;
}
for
(
final
GradleHandledError
gradleError
in
localGradleErrors
)
{
if
(
gradleError
.
test
(
line
))
{
detectedGradleErrorLine
=
line
;
detectedGradleError
=
gradleError
;
// The first error match wins.
break
;
}
}
// Pipe stdout/stderr from Gradle.
return
line
;
}
final
Stopwatch
sw
=
Stopwatch
()..
start
();
int
exitCode
=
1
;
try
{
exitCode
=
await
processUtils
.
stream
(
command
,
workingDirectory:
project
.
android
.
hostAppGradleRoot
.
path
,
allowReentrantFlutter:
true
,
environment:
gradleEnvironment
,
mapFunction:
(
String
line
)
{
// This message was removed from first-party plugins,
// but older plugin versions still display this message.
if
(
androidXPluginWarningRegex
.
hasMatch
(
line
))
{
// Don't pipe.
return
null
;
}
if
(
detectedGradleError
!=
null
)
{
// Pipe stdout/stderr from Gradle.
return
line
;
}
for
(
final
GradleHandledError
gradleError
in
localGradleErrors
)
{
if
(
gradleError
.
test
(
line
))
{
detectedGradleErrorLine
=
line
;
detectedGradleError
=
gradleError
;
// The first error match wins.
break
;
}
}
// Pipe stdout/stderr from Gradle.
return
line
;
},
mapFunction:
consumeLog
,
);
}
on
ProcessException
catch
(
exception
)
{
consumeLog
(
exception
.
toString
());
// Rethrow the exception if the error isn't handled by any of the
// `localGradleErrors`.
if
(
detectedGradleError
==
null
)
{
rethrow
;
}
}
finally
{
status
.
stop
();
}
...
...
packages/flutter_tools/lib/src/android/gradle_errors.dart
View file @
f766871e
...
...
@@ -85,7 +85,7 @@ final GradleHandledError permissionDeniedErrorHandler = GradleHandledError(
bool
usesAndroidX
,
bool
shouldBuildPluginAsAar
,
})
async
{
printStatus
(
'
$warningMark
Gradle does not have
permission to execute by your user
.'
,
emphasis:
true
);
printStatus
(
'
$warningMark
Gradle does not have
execution permission
.'
,
emphasis:
true
);
printStatus
(
'You should change the ownership of the project directory to your user, '
'or move the project to a directory with execute permissions.'
,
...
...
packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart
View file @
f766871e
...
...
@@ -231,7 +231,7 @@ Command: /home/android/gradlew assembleRelease
final
BufferLogger
logger
=
context
.
get
<
Logger
>();
expect
(
logger
.
statusText
,
contains
(
'Gradle does not have
permission to execute by your user
.'
),
contains
(
'Gradle does not have
execution permission
.'
),
);
expect
(
logger
.
statusText
,
...
...
@@ -399,7 +399,7 @@ Command: /home/android/gradlew assembleRelease
final
BufferLogger
logger
=
context
.
get
<
Logger
>();
expect
(
logger
.
statusText
,
contains
(
'Gradle does not have
permission to execute by your user
.'
),
contains
(
'Gradle does not have
execution permission
.'
),
);
expect
(
logger
.
statusText
,
...
...
packages/flutter_tools/test/general.shard/android/gradle_test.dart
View file @
f766871e
...
...
@@ -1266,6 +1266,123 @@ plugin2=${plugin2.path}
Usage:
()
=>
mockUsage
,
});
testUsingContext
(
'recognizes process exceptions - tool exit'
,
()
async
{
when
(
mockProcessManager
.
start
(
any
,
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
)))
.
thenThrow
(
const
ProcessException
(
''
,
<
String
>[],
'Some gradle message'
));
fs
.
directory
(
'android'
)
.
childFile
(
'build.gradle'
)
.
createSync
(
recursive:
true
);
fs
.
directory
(
'android'
)
.
childFile
(
'gradle.properties'
)
.
createSync
(
recursive:
true
);
fs
.
directory
(
'android'
)
.
childDirectory
(
'app'
)
.
childFile
(
'build.gradle'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'apply from: irrelevant/flutter.gradle'
);
bool
handlerCalled
=
false
;
await
expectLater
(()
async
{
await
buildGradleApp
(
project:
FlutterProject
.
current
(),
androidBuildInfo:
const
AndroidBuildInfo
(
BuildInfo
(
BuildMode
.
release
,
null
,
),
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
localGradleErrors:
<
GradleHandledError
>[
GradleHandledError
(
test:
(
String
line
)
{
return
line
.
contains
(
'Some gradle message'
);
},
handler:
({
String
line
,
FlutterProject
project
,
bool
usesAndroidX
,
bool
shouldBuildPluginAsAar
,
})
async
{
handlerCalled
=
true
;
return
GradleBuildStatus
.
exit
;
},
eventLabel:
'random-event-label'
,
),
],
);
},
throwsToolExit
(
message:
'Gradle task assembleRelease failed with exit code 1'
));
expect
(
handlerCalled
,
isTrue
);
verify
(
mockUsage
.
sendEvent
(
any
,
any
,
label:
'gradle-random-event-label-failure'
,
parameters:
anyNamed
(
'parameters'
),
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
Cache:
()
=>
cache
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
mockProcessManager
,
Usage:
()
=>
mockUsage
,
});
testUsingContext
(
'rethrows unrecognized ProcessException'
,
()
async
{
when
(
mockProcessManager
.
start
(
any
,
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
)))
.
thenThrow
(
const
ProcessException
(
''
,
<
String
>[],
'Unrecognized'
));
fs
.
directory
(
'android'
)
.
childFile
(
'build.gradle'
)
.
createSync
(
recursive:
true
);
fs
.
directory
(
'android'
)
.
childFile
(
'gradle.properties'
)
.
createSync
(
recursive:
true
);
fs
.
directory
(
'android'
)
.
childDirectory
(
'app'
)
.
childFile
(
'build.gradle'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'apply from: irrelevant/flutter.gradle'
);
await
expectLater
(()
async
{
await
buildGradleApp
(
project:
FlutterProject
.
current
(),
androidBuildInfo:
const
AndroidBuildInfo
(
BuildInfo
(
BuildMode
.
release
,
null
,
),
),
target:
'lib/main.dart'
,
isBuildingBundle:
false
,
localGradleErrors:
const
<
GradleHandledError
>[],
);
},
throwsA
(
isInstanceOf
<
ProcessException
>()));
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
Cache:
()
=>
cache
,
Platform:
()
=>
android
,
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
mockProcessManager
,
});
testUsingContext
(
'logs success event after a sucessful retry'
,
()
async
{
int
testFnCalled
=
0
;
when
(
mockProcessManager
.
start
(
any
,
...
...
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