Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 48902d1

Browse files
author
Nurhan Turgut
authored
Felt add integration (#17190)
* adding arguments to felt for running different type of tests * adding test type enums to felt * more changes to felt for testing branches * more additions to code * more changes to felt * adding code for cloning web_drivers * validating test directories. running the integration tests. update the readme file partially * Removing todo lists used for development * addressing reviewers comments * remove unused imports * addressing more reviewer comments * addressing more reviewer comments * addressing reviewer comments. * addressing reviewer comments. * fixing typos * using chromedriverinstaller as a library. Fixing the commit number used from web_installers repo * clean drivers directory after tests finish * addressing more reviewer comments * throwing all critical exceptions instead of logging and returning boolean flags * adding todos for items we can do for making felt easier to use for local development * do not run integration tests on CIs. Added an issue to the TODO. * changing todo's with issues.
1 parent 047c03b commit 48902d1

File tree

9 files changed

+532
-26
lines changed

9 files changed

+532
-26
lines changed

lib/web_ui/dev/README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,24 @@ felt build [-w] -j 100
3131
If you are a Google employee, you can use an internal instance of Goma to parallelize your builds. Because Goma compiles code on remote servers, this option is effective even on low-powered laptops.
3232

3333
## Running web engine tests
34-
To run all tests on Chrome:
34+
To run all tests on Chrome. This will run both integration tests and the unit tests:
3535

3636
```
3737
felt test
3838
```
3939

40+
To run unit tests only:
41+
42+
```
43+
felt test --unit-tests-only
44+
```
45+
46+
To run integration tests only. For now these tests are only available on Chrome Desktop browsers.
47+
48+
```
49+
felt test --integration-tests-only
50+
```
51+
4052
To run tests on Firefox (this will work only on a Linux device):
4153

4254
```
@@ -55,7 +67,7 @@ To run tests on Safari use the following command. It works on MacOS devices and
5567
felt test --browser=safari
5668
```
5769

58-
To run tests on Windows Edge use the following command. It works on Windows devices and it uses the Edge installed on the OS.
70+
To run tests on Windows Edge use the following command. It works on Windows devices and it uses the Edge installed on the OS.
5971

6072
```
6173
felt_windows.bat test --browser=edge

lib/web_ui/dev/common.dart

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ class BrowserInstallerException implements Exception {
2727
String toString() => message;
2828
}
2929

30+
class DriverException implements Exception {
31+
DriverException(this.message);
32+
33+
final String message;
34+
35+
@override
36+
String toString() => message;
37+
}
38+
3039
abstract class PlatformBinding {
3140
static PlatformBinding get instance {
3241
if (_instance == null) {
@@ -77,11 +86,10 @@ class _WindowsBinding implements PlatformBinding {
7786
@override
7887
String getFirefoxDownloadUrl(String version) =>
7988
'https://download-installer.cdn.mozilla.net/pub/firefox/releases/${version}/win64/en-US/'
80-
'${getFirefoxDownloadFilename(version)}';
89+
'${getFirefoxDownloadFilename(version)}';
8190

8291
@override
83-
String getFirefoxDownloadFilename(String version) =>
84-
'firefox-${version}.exe';
92+
String getFirefoxDownloadFilename(String version) => 'firefox-${version}.exe';
8593

8694
@override
8795
String getFirefoxExecutablePath(io.Directory versionDir) =>
@@ -117,7 +125,7 @@ class _LinuxBinding implements PlatformBinding {
117125
@override
118126
String getFirefoxDownloadUrl(String version) =>
119127
'https://download-installer.cdn.mozilla.net/pub/firefox/releases/${version}/linux-x86_64/en-US/'
120-
'${getFirefoxDownloadFilename(version)}';
128+
'${getFirefoxDownloadFilename(version)}';
121129

122130
@override
123131
String getFirefoxDownloadFilename(String version) =>
@@ -161,16 +169,15 @@ class _MacBinding implements PlatformBinding {
161169

162170
@override
163171
String getFirefoxDownloadUrl(String version) =>
164-
'https://download-installer.cdn.mozilla.net/pub/firefox/releases/${version}/mac/en-US/'
165-
'${getFirefoxDownloadFilename(version)}';
172+
'https://download-installer.cdn.mozilla.net/pub/firefox/releases/${version}/mac/en-US/'
173+
'${getFirefoxDownloadFilename(version)}';
166174

167175
@override
168-
String getFirefoxDownloadFilename(String version) =>
169-
'Firefox ${version}.dmg';
176+
String getFirefoxDownloadFilename(String version) => 'Firefox ${version}.dmg';
170177

171178
@override
172179
String getFirefoxExecutablePath(io.Directory versionDir) =>
173-
path.join(versionDir.path, 'Firefox.app','Contents','MacOS', 'firefox');
180+
path.join(versionDir.path, 'Firefox.app', 'Contents', 'MacOS', 'firefox');
174181

175182
@override
176183
String getFirefoxLatestVersionUrl() =>
@@ -243,3 +250,14 @@ class DevNull implements StringSink {
243250
}
244251

245252
bool get isCirrus => io.Platform.environment['CIRRUS_CI'] == 'true';
253+
254+
/// There might be proccesses started during the tests.
255+
///
256+
/// Use this list to store those Processes, for cleaning up before shutdown.
257+
final List<io.Process> processesToCleanUp = List<io.Process>();
258+
259+
/// There might be temporary directories created during the tests.
260+
///
261+
/// Use this list to store those directories and for deleteing them before
262+
/// shutdown.
263+
final List<io.Directory> temporaryDirectories = List<io.Directory>();

lib/web_ui/dev/environment.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Environment {
2222
final io.Directory hostDebugUnoptDir = io.Directory(pathlib.join(outDir.path, 'host_debug_unopt'));
2323
final io.Directory dartSdkDir = io.Directory(pathlib.join(hostDebugUnoptDir.path, 'dart-sdk'));
2424
final io.Directory webUiRootDir = io.Directory(pathlib.join(engineSrcDir.path, 'flutter', 'lib', 'web_ui'));
25+
final io.Directory integrationTestsDir = io.Directory(pathlib.join(engineSrcDir.path, 'flutter', 'e2etests', 'web'));
2526

2627
for (io.Directory expectedDirectory in <io.Directory>[engineSrcDir, outDir, hostDebugUnoptDir, dartSdkDir, webUiRootDir]) {
2728
if (!expectedDirectory.existsSync()) {
@@ -34,6 +35,7 @@ class Environment {
3435
self: self,
3536
webUiRootDir: webUiRootDir,
3637
engineSrcDir: engineSrcDir,
38+
integrationTestsDir: integrationTestsDir,
3739
outDir: outDir,
3840
hostDebugUnoptDir: hostDebugUnoptDir,
3941
dartSdkDir: dartSdkDir,
@@ -44,6 +46,7 @@ class Environment {
4446
this.self,
4547
this.webUiRootDir,
4648
this.engineSrcDir,
49+
this.integrationTestsDir,
4750
this.outDir,
4851
this.hostDebugUnoptDir,
4952
this.dartSdkDir,
@@ -58,6 +61,9 @@ class Environment {
5861
/// Path to the engine's "src" directory.
5962
final io.Directory engineSrcDir;
6063

64+
/// Path to the web integration tests.
65+
final io.Directory integrationTestsDir;
66+
6167
/// Path to the engine's "out" directory.
6268
///
6369
/// This is where you'll find the ninja output, such as the Dart SDK.

lib/web_ui/dev/felt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ install_deps() {
5656
KERNEL_NAME=`uname`
5757
if [[ $KERNEL_NAME == *"Darwin"* ]]
5858
then
59-
echo "Running on MacOS. Increase the user limits"
60-
ulimit -n 50000
61-
ulimit -u 4096
59+
echo "Running on MacOS. Increase the user limits"
60+
ulimit -n 50000
61+
ulimit -u 4096
6262
fi
6363

6464
if [[ "$FELT_USE_SNAPSHOT" == "false" || "$FELT_USE_SNAPSHOT" == "0" ]]; then

lib/web_ui/dev/felt.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:args/command_runner.dart';
99

1010
import 'build.dart';
1111
import 'clean.dart';
12+
import 'common.dart';
1213
import 'licenses.dart';
1314
import 'test_runner.dart';
1415

@@ -41,12 +42,29 @@ void main(List<String> args) async {
4142
io.exit(64); // Exit code 64 indicates a usage error.
4243
} catch (e) {
4344
rethrow;
45+
} finally {
46+
_cleanup();
4447
}
4548

4649
// Sometimes the Dart VM refuses to quit.
4750
io.exit(io.exitCode);
4851
}
4952

53+
void _cleanup() {
54+
// Cleanup remaining processes if any.
55+
if (processesToCleanUp.length > 0) {
56+
for (io.Process process in processesToCleanUp) {
57+
process.kill();
58+
}
59+
}
60+
// Delete temporary directories.
61+
if (temporaryDirectories.length > 0) {
62+
for (io.Directory directory in temporaryDirectories) {
63+
directory.deleteSync(recursive: true);
64+
}
65+
}
66+
}
67+
5068
void _listenToShutdownSignals() {
5169
io.ProcessSignal.sigint.watch().listen((_) {
5270
print('Received SIGINT. Shutting down.');

0 commit comments

Comments
 (0)