-
Notifications
You must be signed in to change notification settings - Fork 6k
Run integration tests on ci #17598
Run integration tests on ci #17598
Changes from all commits
afd35da
8324ebf
20ebc73
9c4f976
c3ff9e2
efbfb0e
7c9abc5
bedf999
7fdc03e
c5ddc34
21d7dd5
958af7c
2bafbbc
cf34de4
41a7dae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ class Environment { | |
| factory Environment() { | ||
| final io.File self = io.File.fromUri(io.Platform.script); | ||
| final io.Directory engineSrcDir = self.parent.parent.parent.parent.parent; | ||
| final io.Directory engineToolsDir = io.Directory(pathlib.join(engineSrcDir.path, 'flutter', 'tools')); | ||
| final io.Directory outDir = io.Directory(pathlib.join(engineSrcDir.path, 'out')); | ||
| final io.Directory hostDebugUnoptDir = io.Directory(pathlib.join(outDir.path, 'host_debug_unopt')); | ||
| final io.Directory dartSdkDir = io.Directory(pathlib.join(hostDebugUnoptDir.path, 'dart-sdk')); | ||
|
|
@@ -36,6 +37,7 @@ class Environment { | |
| self: self, | ||
| webUiRootDir: webUiRootDir, | ||
| engineSrcDir: engineSrcDir, | ||
| engineToolsDir: engineToolsDir, | ||
| integrationTestsDir: integrationTestsDir, | ||
| outDir: outDir, | ||
| hostDebugUnoptDir: hostDebugUnoptDir, | ||
|
|
@@ -47,6 +49,7 @@ class Environment { | |
| this.self, | ||
| this.webUiRootDir, | ||
| this.engineSrcDir, | ||
| this.engineToolsDir, | ||
| this.integrationTestsDir, | ||
| this.outDir, | ||
| this.hostDebugUnoptDir, | ||
|
|
@@ -62,6 +65,9 @@ class Environment { | |
| /// Path to the engine's "src" directory. | ||
| final io.Directory engineSrcDir; | ||
|
|
||
| /// Path to the engine's "tools" directory. | ||
| final io.Directory engineToolsDir; | ||
|
|
||
| /// Path to the web integration tests. | ||
| final io.Directory integrationTestsDir; | ||
|
|
||
|
|
@@ -112,6 +118,16 @@ class Environment { | |
| '.dart_tool', | ||
| )); | ||
|
|
||
| /// Path to the ".dart_tool" directory living under `engine/src/flutter`. | ||
| /// | ||
| /// This is a designated area for tool downloads which can be used by | ||
| /// multiple platforms. For exampe: Flutter repo for e2e tests. | ||
| io.Directory get engineDartToolDir => io.Directory(pathlib.join( | ||
| engineSrcDir.path, | ||
| 'flutter', | ||
| '.dart_tool', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems useful for android and iOS e2e too. We currently have duplicated scripts to build AOT/JIT apps, but it would be a win if we can just reuse the tool logic. |
||
| )); | ||
|
|
||
| /// Path to the "dev" directory containing engine developer tools and | ||
| /// configuration files. | ||
| io.Directory get webUiDevDir => io.Directory(pathlib.join( | ||
|
|
@@ -124,4 +140,23 @@ class Environment { | |
| webUiDartToolDir.path, | ||
| 'goldens', | ||
| )); | ||
|
|
||
| /// Path to the script that clones the Flutter repo. | ||
| io.File get cloneFlutterScript => io.File(pathlib.join( | ||
| engineToolsDir.path, | ||
| 'clone_flutter.sh', | ||
| )); | ||
|
|
||
| /// Path to flutter. | ||
| /// | ||
| /// For example, this can be used to run `flutter pub get`. | ||
| /// | ||
| /// Only use [cloneFlutterScript] to clone flutter to the engine build. | ||
| io.File get flutterCommand => io.File(pathlib.join( | ||
| engineDartToolDir.path, | ||
| 'flutter', | ||
| 'bin', | ||
| 'flutter', | ||
| )); | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,6 @@ void main(List<String> args) async { | |
| final bool result = (await runner.run(args)) as bool; | ||
| if (result == false) { | ||
| print('Sub-command returned false: `${args.join(' ')}`'); | ||
| await cleanup(); | ||
| exitCode = 1; | ||
| } | ||
| } on UsageException catch (e) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. __ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😊 |
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,8 +7,8 @@ import 'package:path/path.dart' as pathlib; | |||||||
| import 'package:web_driver_installer/chrome_driver_installer.dart'; | ||||||||
|
|
||||||||
| import 'chrome_installer.dart'; | ||||||||
| import 'common.dart'; | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||||||||
| import 'environment.dart'; | ||||||||
| import 'exceptions.dart'; | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||||||||
| import 'utils.dart'; | ||||||||
|
|
||||||||
| class IntegrationTestsManager { | ||||||||
|
|
@@ -29,7 +29,9 @@ class IntegrationTestsManager { | |||||||
| /// tests shutdown. | ||||||||
| final io.Directory _drivers; | ||||||||
|
|
||||||||
| IntegrationTestsManager(this._browser) | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||
| final bool _useSystemFlutter; | ||||||||
|
|
||||||||
| IntegrationTestsManager(this._browser, this._useSystemFlutter) | ||||||||
| : this._browserDriverDir = io.Directory(pathlib.join( | ||||||||
| environment.webUiDartToolDir.path, 'drivers', _browser)), | ||||||||
| this._drivers = io.Directory( | ||||||||
|
|
@@ -46,37 +48,49 @@ class IntegrationTestsManager { | |||||||
| } | ||||||||
| } | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I |
||||||||
|
|
||||||||
| Future<bool> _runPubGet(String workingDirectory) async { | ||||||||
| final String executable = isCirrus ? environment.pubExecutable : 'flutter'; | ||||||||
| final List<String> arguments = isCirrus | ||||||||
| ? <String>[ | ||||||||
| 'get', | ||||||||
| ] | ||||||||
| : <String>[ | ||||||||
| 'pub', | ||||||||
| 'get', | ||||||||
| ]; | ||||||||
| Future<void> _runPubGet(String workingDirectory) async { | ||||||||
| if (!_useSystemFlutter) { | ||||||||
| await _cloneFlutterRepo(); | ||||||||
| await _enableWeb(workingDirectory); | ||||||||
| } | ||||||||
| await runFlutter(workingDirectory, <String>['pub', 'get'], | ||||||||
| useSystemFlutter: _useSystemFlutter); | ||||||||
| } | ||||||||
|
|
||||||||
| /// Clone flutter repository, use the youngest commit older than the engine | ||||||||
| /// commit. | ||||||||
| /// | ||||||||
| /// Use engine/src/flutter/.dart_tools to clone the Flutter repo. | ||||||||
| /// TODO(nurhan): Use git pull instead if repo exists. | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||||||||
| Future<void> _cloneFlutterRepo() async { | ||||||||
| // Delete directory if exists. | ||||||||
| if (environment.engineDartToolDir.existsSync()) { | ||||||||
| environment.engineDartToolDir.deleteSync(); | ||||||||
| } | ||||||||
| environment.engineDartToolDir.createSync(); | ||||||||
|
|
||||||||
| final int exitCode = await runProcess( | ||||||||
| executable, | ||||||||
| arguments, | ||||||||
| workingDirectory: workingDirectory, | ||||||||
| environment.cloneFlutterScript.path, | ||||||||
| <String>[ | ||||||||
| environment.engineDartToolDir.path, | ||||||||
| ], | ||||||||
| workingDirectory: environment.webUiRootDir.path, | ||||||||
| ); | ||||||||
|
|
||||||||
| if (exitCode != 0) { | ||||||||
| io.stderr.writeln( | ||||||||
| 'ERROR: Failed to run pub get. Exited with exit code $exitCode'); | ||||||||
| return false; | ||||||||
| } else { | ||||||||
| return true; | ||||||||
| throw ToolException('ERROR: Failed to clone flutter repo. Exited with ' | ||||||||
| 'exit code $exitCode'); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| Future<void> _enableWeb(String workingDirectory) async { | ||||||||
| await runFlutter(workingDirectory, <String>['config', '--enable-web'], | ||||||||
| useSystemFlutter: _useSystemFlutter); | ||||||||
| } | ||||||||
|
|
||||||||
| void _runDriver() async { | ||||||||
| startProcess( | ||||||||
| './chromedriver/chromedriver', | ||||||||
| ['--port=4444'], | ||||||||
| workingDirectory: io.Directory.current.path | ||||||||
| ); | ||||||||
| startProcess('./chromedriver/chromedriver', ['--port=4444'], | ||||||||
| workingDirectory: io.Directory.current.path); | ||||||||
| print('INFO: Driver started'); | ||||||||
| } | ||||||||
|
|
||||||||
|
|
@@ -175,8 +189,10 @@ class IntegrationTestsManager { | |||||||
|
|
||||||||
| Future<bool> _runTestsInProfileMode( | ||||||||
| io.Directory directory, String testName) async { | ||||||||
| final String executable = | ||||||||
| _useSystemFlutter ? 'flutter' : environment.flutterCommand.path; | ||||||||
| final int exitCode = await runProcess( | ||||||||
| 'flutter', | ||||||||
| executable, | ||||||||
| <String>[ | ||||||||
| 'drive', | ||||||||
| '--target=test_driver/${testName}', | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: example