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
943f98d3
Unverified
Commit
943f98d3
authored
Nov 26, 2019
by
Emmanuel Garcia
Committed by
GitHub
Nov 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add integration test for transitive plugin dependencies (#45579)
parent
b2a36ffc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
203 additions
and
0 deletions
+203
-0
test.dart
dev/bots/test.dart
+1
-0
plugin_dependencies_test.dart
dev/devicelab/bin/tasks/plugin_dependencies_test.dart
+202
-0
No files found.
dev/bots/test.dart
View file @
943f98d3
...
...
@@ -763,6 +763,7 @@ Future<void> _runHostOnlyDeviceLabTests() async {
()
=>
_runDevicelabTest
(
'module_host_with_custom_build_test'
,
environment:
gradleEnvironment
,
testEmbeddingV2:
true
),
()
=>
_runDevicelabTest
(
'module_test'
,
environment:
gradleEnvironment
,
testEmbeddingV2:
true
),
()
=>
_runDevicelabTest
(
'plugin_dependencies_test'
,
environment:
gradleEnvironment
),
// TODO(jmagman): Re-enable once flakiness is resolved, https://github.com/flutter/flutter/issues/37525
// if (Platform.isMacOS) () => _runDevicelabTest('module_test_ios'),
...
...
dev/devicelab/bin/tasks/plugin_dependencies_test.dart
0 → 100644
View file @
943f98d3
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:io'
;
import
'package:flutter_devicelab/framework/framework.dart'
;
import
'package:flutter_devicelab/framework/utils.dart'
;
import
'package:path/path.dart'
as
path
;
/// Tests that a plugin A can depend on platform code from a plugin B
/// as long as plugin B is defined as a pub dependency of plugin A.
///
/// This test fails when `flutter build apk` fails and the stderr from this command
/// contains "Unresolved reference: plugin_b".
Future
<
void
>
main
()
async
{
await
task
(()
async
{
section
(
'Find Java'
);
final
String
javaHome
=
await
findJavaHome
();
if
(
javaHome
==
null
)
{
return
TaskResult
.
failure
(
'Could not find Java'
);
}
print
(
'
\n
Using JAVA_HOME=
$javaHome
'
);
final
Directory
tempDir
=
Directory
.
systemTemp
.
createTempSync
(
'flutter_plugin_dependencies.'
);
try
{
section
(
'Create plugin A'
);
final
Directory
pluginADirectory
=
Directory
(
path
.
join
(
tempDir
.
path
,
'plugin_a'
));
await
inDirectory
(
tempDir
,
()
async
{
await
flutter
(
'create'
,
options:
<
String
>[
'--org'
,
'io.flutter.devicelab.plugin_a'
,
'--template=plugin'
,
pluginADirectory
.
path
,
],
);
});
section
(
'Create plugin B'
);
final
Directory
pluginBDirectory
=
Directory
(
path
.
join
(
tempDir
.
path
,
'plugin_b'
));
await
inDirectory
(
tempDir
,
()
async
{
await
flutter
(
'create'
,
options:
<
String
>[
'--org'
,
'io.flutter.devicelab.plugin_b'
,
'--template=plugin'
,
pluginBDirectory
.
path
,
],
);
});
section
(
'Write dummy Kotlin code in plugin B'
);
final
File
pluginBKotlinClass
=
File
(
path
.
join
(
pluginBDirectory
.
path
,
'android'
,
'src'
,
'main'
,
'kotlin'
,
'DummyPluginBClass.kt'
,
));
await
pluginBKotlinClass
.
writeAsString
(
'''
package io.flutter.devicelab.plugin_b
public class DummyPluginBClass {
companion object {
fun dummyStaticMethod() {
}
}
}
'''
,
flush:
true
);
section
(
'Make plugin A depend on plugin B'
);
final
File
pubspec
=
File
(
path
.
join
(
pluginADirectory
.
path
,
'pubspec.yaml'
));
String
content
=
await
pubspec
.
readAsString
();
content
=
content
.
replaceFirst
(
'
\n
dependencies:
\n
'
,
'
\n
dependencies:
\n
'
' plugin_b:
\n
'
' path:
${pluginBDirectory.path}
\n
'
,
);
await
pubspec
.
writeAsString
(
content
,
flush:
true
);
section
(
'Write Kotlin code in plugin A that references Kotlin code from plugin B'
);
final
File
pluginAKotlinClass
=
File
(
path
.
join
(
pluginADirectory
.
path
,
'android'
,
'src'
,
'main'
,
'kotlin'
,
'DummyPluginAClass.kt'
,
));
await
pluginAKotlinClass
.
writeAsString
(
'''
package io.flutter.devicelab.plugin_a
import io.flutter.devicelab.plugin_b.DummyPluginBClass
public class DummyPluginAClass {
constructor() {
// Call a method from plugin b.
DummyPluginBClass.dummyStaticMethod();
}
}
'''
,
flush:
true
);
section
(
'Verify .flutter-plugins-dependencies'
);
final
Directory
exampleApp
=
Directory
(
path
.
join
(
pluginADirectory
.
path
,
'example'
));
await
inDirectory
(
exampleApp
,
()
async
{
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
],
);
});
final
File
flutterPluginsDependenciesFile
=
File
(
path
.
join
(
exampleApp
.
path
,
'.flutter-plugins-dependencies'
));
if
(!
flutterPluginsDependenciesFile
.
existsSync
())
{
return
TaskResult
.
failure
(
'
${flutterPluginsDependenciesFile.path}
doesn
\'
t exist'
);
}
final
String
flutterPluginsDependenciesFileContent
=
flutterPluginsDependenciesFile
.
readAsStringSync
();
const
String
kExpectedPluginsDependenciesContent
=
'{'
'
\"
_info
\"
:
\"
// This is a generated file; do not edit or check into version control.
\"
,'
'
\"
dependencyGraph
\"
:['
'{'
'
\"
name
\"
:
\"
plugin_a
\"
,'
'
\"
dependencies
\"
:[
\"
plugin_b
\"
]'
'},'
'{'
'
\"
name
\"
:
\"
plugin_b
\"
,'
'
\"
dependencies
\"
:[]'
'}'
']'
'}'
;
if
(
flutterPluginsDependenciesFileContent
!=
kExpectedPluginsDependenciesContent
)
{
return
TaskResult
.
failure
(
'Unexpected file content in
${flutterPluginsDependenciesFile.path}
: '
'Found "
$flutterPluginsDependenciesFileContent
" instead of '
'"
$kExpectedPluginsDependenciesContent
"'
);
}
section
(
'Build plugin A example app'
);
final
StringBuffer
stderr
=
StringBuffer
();
await
inDirectory
(
exampleApp
,
()
async
{
await
evalFlutter
(
'build'
,
options:
<
String
>[
'apk'
,
'--target-platform'
,
'android-arm'
],
canFail:
true
,
stderr:
stderr
,
);
});
if
(
stderr
.
toString
().
contains
(
'Unresolved reference: plugin_b'
))
{
return
TaskResult
.
failure
(
'plugin_a cannot reference plugin_b'
);
}
final
bool
pluginAExampleApk
=
exists
(
File
(
path
.
join
(
pluginADirectory
.
path
,
'example'
,
'build'
,
'app'
,
'outputs'
,
'apk'
,
'release'
,
'app-release.apk'
,
)));
if
(!
pluginAExampleApk
)
{
return
TaskResult
.
failure
(
'Failed to build plugin A example APK'
);
}
return
TaskResult
.
success
(
null
);
}
on
TaskResult
catch
(
taskResult
)
{
return
taskResult
;
}
catch
(
e
)
{
return
TaskResult
.
failure
(
e
.
toString
());
}
finally
{
rmTree
(
tempDir
);
}
});
}
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