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
57911641
Unverified
Commit
57911641
authored
Jun 26, 2018
by
Mikkel Nygaard Ravn
Committed by
GitHub
Jun 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix gradle plugin test (#18824)
parent
5e54b9e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
22 deletions
+33
-22
gradle_plugin_test.dart
dev/devicelab/bin/tasks/gradle_plugin_test.dart
+33
-22
No files found.
dev/devicelab/bin/tasks/gradle_plugin_test.dart
View file @
57911641
...
...
@@ -12,19 +12,30 @@ import 'package:flutter_devicelab/framework/utils.dart';
String
javaHome
;
String
errorMessage
;
/// Runs the given [testFunction]
in a clean temporary directory
.
Future
<
void
>
run
Test
(
Future
<
void
>
testFunction
(
FlutterProject
project
,
FlutterPluginProject
pluginP
roject
))
async
{
/// Runs the given [testFunction]
on a freshly generated Flutter project
.
Future
<
void
>
run
ProjectTest
(
Future
<
void
>
testFunction
(
FlutterProject
p
roject
))
async
{
final
Directory
tmp
=
await
Directory
.
systemTemp
.
createTemp
(
'gradle'
);
final
FlutterProject
project
=
await
FlutterProject
.
create
(
tmp
,
'hello'
);
final
FlutterPluginProject
pluginProject
=
await
FlutterPluginProject
.
create
(
tmp
,
'aaa'
);
try
{
await
testFunction
(
project
,
pluginProject
);
await
testFunction
(
project
);
}
finally
{
project
.
parent
.
deleteSync
(
recursive:
true
);
}
}
/// Runs the given [testFunction] on a freshly generated Flutter plugin project.
Future
<
void
>
runPluginProjectTest
(
Future
<
void
>
testFunction
(
FlutterPluginProject
pluginProject
))
async
{
final
Directory
tmp
=
await
Directory
.
systemTemp
.
createTemp
(
'gradle'
);
final
FlutterPluginProject
pluginProject
=
await
FlutterPluginProject
.
create
(
tmp
,
'aaa'
);
try
{
await
testFunction
(
pluginProject
);
}
finally
{
pluginProject
.
parent
.
deleteSync
(
recursive:
true
);
}
}
void
main
(
)
async
{
await
task
(()
async
{
section
(
'Find Java'
);
...
...
@@ -35,7 +46,7 @@ void main() async {
print
(
'
\n
Using JAVA_HOME=
$javaHome
'
);
try
{
await
run
Test
((
FlutterProject
project
,
FlutterPluginProject
pluginP
roject
)
async
{
await
run
ProjectTest
((
FlutterProject
p
roject
)
async
{
section
(
'gradlew assembleDebug'
);
await
project
.
runGradleTask
(
'assembleDebug'
);
errorMessage
=
_validateSnapshotDependency
(
project
,
'build/app.dill'
);
...
...
@@ -44,79 +55,79 @@ void main() async {
}
});
await
run
Test
((
FlutterProject
project
,
FlutterPluginProject
pluginP
roject
)
async
{
await
run
ProjectTest
((
FlutterProject
p
roject
)
async
{
section
(
'gradlew assembleDebug no-preview-dart-2'
);
await
project
.
runGradleTask
(
'assembleDebug'
,
options:
<
String
>[
'-Ppreview-dart-2=false'
]);
});
await
run
Test
((
FlutterProject
project
,
FlutterPluginProject
pluginP
roject
)
async
{
await
run
ProjectTest
((
FlutterProject
p
roject
)
async
{
section
(
'gradlew assembleProfile'
);
await
project
.
runGradleTask
(
'assembleProfile'
);
});
await
run
Test
((
FlutterProject
project
,
FlutterPluginProject
pluginP
roject
)
async
{
await
run
ProjectTest
((
FlutterProject
p
roject
)
async
{
section
(
'gradlew assembleRelease'
);
await
project
.
runGradleTask
(
'assembleRelease'
);
});
await
run
Test
((
FlutterProject
project
,
FlutterPluginProject
pluginP
roject
)
async
{
await
run
ProjectTest
((
FlutterProject
p
roject
)
async
{
section
(
'gradlew assembleLocal (custom debug build)'
);
await
project
.
addCustomBuildType
(
'local'
,
initWith:
'debug'
);
await
project
.
runGradleTask
(
'assembleLocal'
);
});
await
run
Test
((
FlutterProject
project
,
FlutterPluginProject
pluginP
roject
)
async
{
await
run
ProjectTest
((
FlutterProject
p
roject
)
async
{
section
(
'gradlew assembleBeta (custom release build)'
);
await
project
.
addCustomBuildType
(
'beta'
,
initWith:
'release'
);
await
project
.
runGradleTask
(
'assembleBeta'
);
});
await
run
Test
((
FlutterProject
project
,
FlutterPluginProject
pluginP
roject
)
async
{
await
run
ProjectTest
((
FlutterProject
p
roject
)
async
{
section
(
'gradlew assembleFreeDebug (product flavor)'
);
await
project
.
addProductFlavor
(
'free'
);
await
project
.
runGradleTask
(
'assembleFreeDebug'
);
await
project
.
introduceError
();
});
await
run
Test
((
FlutterProject
project
,
FlutterPluginProject
pluginP
roject
)
async
{
await
run
ProjectTest
((
FlutterProject
p
roject
)
async
{
section
(
'gradlew on build script with error'
);
await
project
.
introduceError
();
final
ProcessResult
result
=
await
project
.
resultOfGradleTask
(
'assembleRelease'
);
if
(
result
.
exitCode
==
0
)
return
_failure
(
throw
_failure
(
'Gradle did not exit with error as expected'
,
result
);
final
String
output
=
result
.
stdout
+
'
\n
'
+
result
.
stderr
;
if
(
output
.
contains
(
'GradleException'
)
||
output
.
contains
(
'Failed to notify'
)
||
output
.
contains
(
'at org.gradle'
))
return
_failure
(
throw
_failure
(
'Gradle output should not contain stacktrace'
,
result
);
if
(!
output
.
contains
(
'Build failed'
)
||
!
output
.
contains
(
'builTypes'
))
return
_failure
(
throw
_failure
(
'Gradle output should contain a readable error message'
,
result
);
});
await
run
Test
((
FlutterProject
project
,
FlutterPluginProject
pluginP
roject
)
async
{
await
run
ProjectTest
((
FlutterProject
p
roject
)
async
{
section
(
'flutter build apk on build script with error'
);
await
project
.
introduceError
();
final
ProcessResult
result
=
await
project
.
resultOfFlutterCommand
(
'build'
,
<
String
>[
'apk'
]);
if
(
result
.
exitCode
==
0
)
return
_failure
(
throw
_failure
(
'flutter build apk should fail when Gradle does'
,
result
);
final
String
output
=
result
.
stdout
+
'
\n
'
+
result
.
stderr
;
if
(!
output
.
contains
(
'Build failed'
)
||
!
output
.
contains
(
'builTypes'
))
return
_failure
(
throw
_failure
(
'flutter build apk output should contain a readable Gradle error message'
,
result
);
if
(
_hasMultipleOccurrences
(
output
,
'builTypes'
))
return
_failure
(
throw
_failure
(
'flutter build apk should not invoke Gradle repeatedly on error'
,
result
);
});
await
run
Test
((
FlutterProject
project
,
FlutterPluginProject
pluginProject
)
async
{
await
run
PluginProjectTest
((
FlutterPluginProject
pluginProject
)
async
{
section
(
'gradlew assembleDebug on plugin example'
);
await
pluginProject
.
runGradleTask
(
'assembleDebug'
);
if
(!
pluginProject
.
hasDebugApk
)
...
...
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