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
b02cb6e4
Unverified
Commit
b02cb6e4
authored
Sep 15, 2020
by
Jonah Williams
Committed by
GitHub
Sep 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] make local engine integration testing easier (#65802)
parent
199a7c19
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
18 deletions
+58
-18
README.md
packages/flutter_tools/README.md
+18
-4
analyze_size_test.dart
...utter_tools/test/integration.shard/analyze_size_test.dart
+3
-0
build_ios_config_only_test.dart
...ls/test/integration.shard/build_ios_config_only_test.dart
+13
-13
command_output_test.dart
...ter_tools/test/integration.shard/command_output_test.dart
+8
-0
daemon_mode_test.dart
...lutter_tools/test/integration.shard/daemon_mode_test.dart
+1
-1
test_driver.dart
...ges/flutter_tools/test/integration.shard/test_driver.dart
+3
-0
test_utils.dart
...ages/flutter_tools/test/integration.shard/test_utils.dart
+12
-0
No files found.
packages/flutter_tools/README.md
View file @
b02cb6e4
...
@@ -22,7 +22,7 @@ $ ../../bin/flutter --version
...
@@ -22,7 +22,7 @@ $ ../../bin/flutter --version
To run Flutter Tools from source, in this directory run:
To run Flutter Tools from source, in this directory run:
```
shell
```
shell
$
../../bin/
cache/dart-sdk/bin/
dart bin/flutter_tools.dart
$
../../bin/dart bin/flutter_tools.dart
```
```
followed by command-line arguments, as usual.
followed by command-line arguments, as usual.
...
@@ -56,24 +56,38 @@ that add new code should aim to increase coverage. In particular, the coverage
...
@@ -56,24 +56,38 @@ that add new code should aim to increase coverage. In particular, the coverage
of the diff should be close to the average coverage, and should ideally be
of the diff should be close to the average coverage, and should ideally be
better.
better.
#### Using local engine builds in integration tests
The integration tests can be configured to use a specific local engine
variant by setting the
`FLUTTER_LOCAL_ENGINE`
environment variable to the
name of the local engine (e.g. "android_debug_unopt"). If the local engine build
requires a source path, this can be provided by setting the
`FLUTTER_LOCAL_ENGINE_SRC_PATH`
environment variable. This second variable is not necessary if the
`flutter`
and
`engine`
checkouts are in adjacent directories.
```
shell
export
FLUTTER_LOCAL_ENGINE
=
android_debug_unopt
../../bin/dart
test test
/integration.shard/some_test_case
```
### Running the tests
### Running the tests
To run the tests in the
`test/`
directory, first ensure that there are no
To run the tests in the
`test/`
directory, first ensure that there are no
connected devices. Then, in this directory run:
connected devices. Then, in this directory run:
```
shell
```
shell
$
../../bin/
cache/dart-sdk/bin/
pub run
test
$
../../bin/
dart
pub run
test
```
```
The tests in
`test/integration.shard`
are slower to run than the tests in
The tests in
`test/integration.shard`
are slower to run than the tests in
`test/general.shard`
. To run only the tests in
`test/general.shard`
, in this
`test/general.shard`
. To run only the tests in
`test/general.shard`
, in this
directory run:
directory run:
```
shell
```
shell
$
../../bin/
cache/dart-sdk/bin/
pub run
test test
/general.shard
$
../../bin/
dart
pub run
test test
/general.shard
```
```
To run the tests in a specific file, run:
To run the tests in a specific file, run:
```
shell
```
shell
$
../../bin/
cache/dart-sdk/bin/
pub run
test test
/general.shard/utils_test.dart
$
../../bin/
dart
pub run
test test
/general.shard/utils_test.dart
```
```
### Forcing snapshot regeneration
### Forcing snapshot regeneration
...
...
packages/flutter_tools/test/integration.shard/analyze_size_test.dart
View file @
b02cb6e4
...
@@ -18,6 +18,7 @@ void main() {
...
@@ -18,6 +18,7 @@ void main() {
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'build'
,
'build'
,
'apk'
,
'apk'
,
'--analyze-size'
,
'--analyze-size'
,
...
@@ -42,6 +43,7 @@ void main() {
...
@@ -42,6 +43,7 @@ void main() {
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'build'
,
'build'
,
'ios'
,
'ios'
,
'--analyze-size'
,
'--analyze-size'
,
...
@@ -65,6 +67,7 @@ void main() {
...
@@ -65,6 +67,7 @@ void main() {
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'build'
,
'build'
,
'apk'
,
'apk'
,
'--analyze-size'
,
'--analyze-size'
,
...
...
packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart
View file @
b02cb6e4
...
@@ -5,23 +5,23 @@
...
@@ -5,23 +5,23 @@
import
'package:file_testing/file_testing.dart'
;
import
'package:file_testing/file_testing.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/io.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:process/process.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'../src/common.dart'
;
import
'../src/common.dart'
;
import
'test_utils.dart'
;
void
main
(
)
{
void
main
(
)
{
test
(
'flutter build ios --config only updates generated xcconfig file without performing build'
,
()
async
{
test
(
'flutter build ios --config only updates generated xcconfig file without performing build'
,
()
async
{
final
String
woringDirectory
=
globals
.
fs
.
path
.
join
(
getFlutterRoot
(),
'examples'
,
'hello_world'
);
final
String
woringDirectory
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'examples'
,
'hello_world'
);
final
String
flutterBin
=
globals
.
fs
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
await
const
LocalProcessManager
()
.
run
(<
String
>[
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'clean'
,
'clean'
,
],
workingDirectory:
woringDirectory
);
],
workingDirectory:
woringDirectory
);
final
ProcessResult
result
=
await
const
LocalProcessManager
()
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'build'
,
'build'
,
'ios'
,
'ios'
,
'--config-only'
,
'--config-only'
,
...
@@ -36,20 +36,20 @@ void main() {
...
@@ -36,20 +36,20 @@ void main() {
expect
(
result
.
exitCode
,
0
);
expect
(
result
.
exitCode
,
0
);
final
File
generatedConfig
=
globals
.
fs
.
file
(
final
File
generatedConfig
=
fileSystem
.
file
(
globals
.
fs
.
path
.
join
(
woringDirectory
,
'ios'
,
'Flutter'
,
'Generated.xcconfig'
));
fileSystem
.
path
.
join
(
woringDirectory
,
'ios'
,
'Flutter'
,
'Generated.xcconfig'
));
// Config is updated if command succeeded.
// Config is updated if command succeeded.
expect
(
generatedConfig
,
exists
);
expect
(
generatedConfig
,
exists
);
expect
(
generatedConfig
.
readAsStringSync
(),
allOf
(
expect
(
generatedConfig
.
readAsStringSync
(),
allOf
(
contains
(
'DART_OBFUSCATION=true'
),
contains
(
'DART_OBFUSCATION=true'
),
contains
(
'FLUTTER_FRAMEWORK_DIR=
${
globals.fs
.path.absolute(getFlutterRoot(), 'bin', 'cache', 'artifacts', 'engine')}
'
),
contains
(
'FLUTTER_FRAMEWORK_DIR=
${
fileSystem
.path.absolute(getFlutterRoot(), 'bin', 'cache', 'artifacts', 'engine')}
'
),
));
));
// file that only exists if app was fully built.
// file that only exists if app was fully built.
final
File
frameworkPlist
=
globals
.
fs
.
file
(
final
File
frameworkPlist
=
fileSystem
.
file
(
globals
.
fs
.
path
.
join
(
woringDirectory
,
'build'
,
'ios'
,
'iphoneos'
,
'Runner.app'
,
'AppFrameworkInfo.plist'
));
fileSystem
.
path
.
join
(
woringDirectory
,
'build'
,
'ios'
,
'iphoneos'
,
'Runner.app'
,
'AppFrameworkInfo.plist'
));
expect
(
frameworkPlist
,
isNot
(
exists
));
expect
(
frameworkPlist
,
isNot
(
exists
));
},
skip:
!
const
LocalPlatform
()
.
isMacOS
);
},
skip:
!
platform
.
isMacOS
);
}
}
packages/flutter_tools/test/integration.shard/command_output_test.dart
View file @
b02cb6e4
...
@@ -16,6 +16,7 @@ void main() {
...
@@ -16,6 +16,7 @@ void main() {
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'-h'
,
'-h'
,
'-v'
,
'-v'
,
]);
]);
...
@@ -36,6 +37,7 @@ void main() {
...
@@ -36,6 +37,7 @@ void main() {
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'doctor'
,
'doctor'
,
'-v'
,
'-v'
,
]);
]);
...
@@ -48,6 +50,7 @@ void main() {
...
@@ -48,6 +50,7 @@ void main() {
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'doctor'
,
'doctor'
,
'-vv'
,
'-vv'
,
]);
]);
...
@@ -60,6 +63,7 @@ void main() {
...
@@ -60,6 +63,7 @@ void main() {
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'config'
,
'config'
,
]);
]);
...
@@ -89,6 +93,7 @@ void main() {
...
@@ -89,6 +93,7 @@ void main() {
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'run'
,
'run'
,
'--show-test-device'
,
// ensure command can fail to run and hit injection of correct logger.
'--show-test-device'
,
// ensure command can fail to run and hit injection of correct logger.
'--machine'
,
'--machine'
,
...
@@ -105,6 +110,7 @@ void main() {
...
@@ -105,6 +110,7 @@ void main() {
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'attach'
,
'attach'
,
'--machine'
,
'--machine'
,
'-v'
,
'-v'
,
...
@@ -117,6 +123,7 @@ void main() {
...
@@ -117,6 +123,7 @@ void main() {
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'build'
,
'build'
,
'-h'
,
'-h'
,
'-v'
,
'-v'
,
...
@@ -133,6 +140,7 @@ void main() {
...
@@ -133,6 +140,7 @@ void main() {
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
'flutter'
);
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
final
ProcessResult
result
=
await
processManager
.
run
(<
String
>[
flutterBin
,
flutterBin
,
...
getLocalEngineArguments
(),
'--version'
,
'--version'
,
'--machine'
,
'--machine'
,
]);
]);
...
...
packages/flutter_tools/test/integration.shard/daemon_mode_test.dart
View file @
b02cb6e4
...
@@ -27,7 +27,7 @@ void main() {
...
@@ -27,7 +27,7 @@ void main() {
const
ProcessManager
processManager
=
LocalProcessManager
();
const
ProcessManager
processManager
=
LocalProcessManager
();
final
Process
process
=
await
processManager
.
start
(
final
Process
process
=
await
processManager
.
start
(
<
String
>[
flutterBin
,
'--show-test-device'
,
'daemon'
],
<
String
>[
flutterBin
,
...
getLocalEngineArguments
(),
'--show-test-device'
,
'daemon'
],
workingDirectory:
tempDir
.
path
,
workingDirectory:
tempDir
.
path
,
);
);
...
...
packages/flutter_tools/test/integration.shard/test_driver.dart
View file @
b02cb6e4
...
@@ -452,6 +452,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
...
@@ -452,6 +452,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
'--disable-service-auth-codes'
,
'--disable-service-auth-codes'
,
if
(
machine
)
'--machine'
,
if
(
machine
)
'--machine'
,
if
(!
spawnDdsInstance
)
'--disable-dds'
,
if
(!
spawnDdsInstance
)
'--disable-dds'
,
...
getLocalEngineArguments
(),
'-d'
,
'-d'
,
if
(
chrome
)
if
(
chrome
)
...<
String
>[
...<
String
>[
...
@@ -482,6 +483,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
...
@@ -482,6 +483,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
await
_setupProcess
(
await
_setupProcess
(
<
String
>[
<
String
>[
'attach'
,
'attach'
,
...
getLocalEngineArguments
(),
'--machine'
,
'--machine'
,
if
(!
spawnDdsInstance
)
if
(!
spawnDdsInstance
)
'--disable-dds'
,
'--disable-dds'
,
...
@@ -705,6 +707,7 @@ class FlutterTestTestDriver extends FlutterTestDriver {
...
@@ -705,6 +707,7 @@ class FlutterTestTestDriver extends FlutterTestDriver {
})
async
{
})
async
{
await
_setupProcess
(<
String
>[
await
_setupProcess
(<
String
>[
'test'
,
'test'
,
...
getLocalEngineArguments
(),
'--disable-service-auth-codes'
,
'--disable-service-auth-codes'
,
'--machine'
,
'--machine'
,
if
(
coverage
)
if
(
coverage
)
...
...
packages/flutter_tools/test/integration.shard/test_utils.dart
View file @
b02cb6e4
...
@@ -63,3 +63,15 @@ Future<void> getPackages(String folder) async {
...
@@ -63,3 +63,15 @@ Future<void> getPackages(String folder) async {
throw
Exception
(
'flutter pub get failed:
${result.stderr}
\n
${result.stdout}
'
);
throw
Exception
(
'flutter pub get failed:
${result.stderr}
\n
${result.stdout}
'
);
}
}
}
}
const
String
kLocalEngineEnvironment
=
'FLUTTER_LOCAL_ENGINE'
;
const
String
kLocalEngineLocation
=
'FLUTTER_LOCAL_ENGINE_SRC_PATH'
;
List
<
String
>
getLocalEngineArguments
()
{
return
<
String
>[
if
(
platform
.
environment
.
containsKey
(
kLocalEngineEnvironment
))
'--local-engine=
${platform.environment[kLocalEngineEnvironment]}
'
,
if
(
platform
.
environment
.
containsKey
(
kLocalEngineLocation
))
'--local-engine-src-path=
${platform.environment[kLocalEngineLocation]}
'
,
];
}
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