This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Add custom test plugin that supports screenshot tests #12079
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b361595
add golden file tester for web
1d71e83
custom test plugin to run unit and screenshot tests
yjbanov f52e9c9
add package:js dependency
yjbanov 9c98ec7
pub get in web_engine_tester
yjbanov e4320c0
--no-sandbox
yjbanov 14aa404
env fix
yjbanov a98d628
print chrome version
yjbanov dbe74e4
temporarily silence Cirrus failures
yjbanov eb4563d
do not fail smoke test
yjbanov ba63b63
fix licenses
yjbanov ad7bfe7
Address comments
yjbanov 0416eb0
update tool_signature
yjbanov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| Signature: 24e0fa6ad08ae80380158c2b4ba44c65 | ||
| Signature: d510e80277a674c258a08394950ac485 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| targets: | ||
| $default: | ||
| builders: | ||
| build_web_compilers|entrypoint: | ||
| options: | ||
| compiler: dart2js | ||
| dart2js_args: | ||
| - --no-minify | ||
| - --enable-asserts | ||
| generate_for: | ||
| - test/**.dart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| // Copyright 2013 The Flutter 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:io' as io; | ||
| import 'package:args/args.dart' as args; | ||
| import 'package:path/path.dart' as pathlib; | ||
|
|
||
| /// Contains various environment variables, such as common file paths and command-line options. | ||
| Environment get environment { | ||
| _environment ??= Environment(); | ||
| return _environment; | ||
| } | ||
| Environment _environment; | ||
|
|
||
| args.ArgParser get _argParser { | ||
| return args.ArgParser() | ||
| ..addMultiOption( | ||
| 'target', | ||
| abbr: 't', | ||
| help: 'The path to the target to run. When omitted, runs all targets.', | ||
| ) | ||
| ..addMultiOption( | ||
| 'shard', | ||
| abbr: 's', | ||
| help: 'The category of tasks to run.', | ||
| ) | ||
| ..addFlag( | ||
| 'debug', | ||
| help: 'Pauses the browser before running a test, giving you an ' | ||
| 'opportunity to add breakpoints or inspect loaded code before ' | ||
| 'running the code.', | ||
| ); | ||
| } | ||
|
|
||
| /// Contains various environment variables, such as common file paths and command-line options. | ||
| class Environment { | ||
| /// Command-line arguments. | ||
| static List<String> commandLineArguments; | ||
|
|
||
| factory Environment() { | ||
| if (commandLineArguments == null) { | ||
| io.stderr.writeln('Command-line arguments not set.'); | ||
| io.exit(1); | ||
| } | ||
|
|
||
| final args.ArgResults options = _argParser.parse(commandLineArguments); | ||
| final List<String> shards = options['shard']; | ||
| final bool isDebug = options['debug']; | ||
| final List<String> targets = options['target']; | ||
|
|
||
| final io.File self = io.File.fromUri(io.Platform.script); | ||
| final io.Directory engineSrcDir = self.parent.parent.parent.parent.parent; | ||
| 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')); | ||
| final io.Directory webUiRootDir = io.Directory(pathlib.join(engineSrcDir.path, 'flutter', 'lib', 'web_ui')); | ||
|
|
||
| for (io.Directory expectedDirectory in <io.Directory>[engineSrcDir, outDir, hostDebugUnoptDir, dartSdkDir, webUiRootDir]) { | ||
| if (!expectedDirectory.existsSync()) { | ||
| io.stderr.writeln('$expectedDirectory does not exist.'); | ||
| io.exit(1); | ||
| } | ||
| } | ||
|
|
||
| return Environment._( | ||
| self: self, | ||
| webUiRootDir: webUiRootDir, | ||
| engineSrcDir: engineSrcDir, | ||
| outDir: outDir, | ||
| hostDebugUnoptDir: hostDebugUnoptDir, | ||
| dartSdkDir: dartSdkDir, | ||
| requestedShards: shards, | ||
| isDebug: isDebug, | ||
| targets: targets, | ||
| ); | ||
| } | ||
|
|
||
| Environment._({ | ||
| this.self, | ||
| this.webUiRootDir, | ||
| this.engineSrcDir, | ||
| this.outDir, | ||
| this.hostDebugUnoptDir, | ||
| this.dartSdkDir, | ||
| this.requestedShards, | ||
| this.isDebug, | ||
| this.targets, | ||
| }); | ||
|
|
||
| /// The Dart script that's currently running. | ||
| final io.File self; | ||
|
|
||
| /// Path to the "web_ui" package sources. | ||
| final io.Directory webUiRootDir; | ||
|
|
||
| /// Path to the engine's "src" directory. | ||
| final io.Directory engineSrcDir; | ||
|
|
||
| /// Path to the engine's "out" directory. | ||
| /// | ||
| /// This is where you'll find the ninja output, such as the Dart SDK. | ||
| final io.Directory outDir; | ||
|
|
||
| /// The "host_debug_unopt" build of the Dart SDK. | ||
| final io.Directory hostDebugUnoptDir; | ||
|
|
||
| /// The root of the Dart SDK. | ||
| final io.Directory dartSdkDir; | ||
|
|
||
| /// Shards specified on the command-line. | ||
| final List<String> requestedShards; | ||
|
|
||
| /// Whether to start the browser in debug mode. | ||
| /// | ||
| /// In this mode the browser pauses before running the test to allow | ||
| /// you set breakpoints or inspect the code. | ||
| final bool isDebug; | ||
|
|
||
| /// Paths to targets to run, e.g. a single test. | ||
| final List<String> targets; | ||
|
|
||
| /// The "dart" executable file. | ||
| String get dartExecutable => pathlib.join(dartSdkDir.path, 'bin', 'dart'); | ||
|
|
||
| /// The "pub" executable file. | ||
| String get pubExecutable => pathlib.join(dartSdkDir.path, 'bin', 'pub'); | ||
|
|
||
| /// The "dart2js" executable file. | ||
| String get dart2jsExecutable => pathlib.join(dartSdkDir.path, 'bin', 'dart2js'); | ||
|
|
||
| /// Path to where github.com/flutter/engine is checked out inside the engine workspace. | ||
| io.Directory get flutterDirectory => io.Directory(pathlib.join(engineSrcDir.path, 'flutter')); | ||
| io.Directory get webSdkRootDir => io.Directory(pathlib.join( | ||
| flutterDirectory.path, | ||
| 'web_sdk', | ||
| )); | ||
|
|
||
| /// Path to the "web_engine_tester" package. | ||
| io.Directory get goldenTesterRootDir => io.Directory(pathlib.join( | ||
| webSdkRootDir.path, | ||
| 'web_engine_tester', | ||
| )); | ||
|
|
||
| /// Path to the "build" directory, generated by "package:build_runner". | ||
| /// | ||
| /// This is where compiled output goes. | ||
| io.Directory get webUiBuildDir => io.Directory(pathlib.join( | ||
| webUiRootDir.path, | ||
| 'build', | ||
| )); | ||
|
|
||
| /// Path to the ".dart_tool" directory, generated by various Dart tools. | ||
| io.Directory get webUiDartToolDir => io.Directory(pathlib.join( | ||
| webUiRootDir.path, | ||
| '.dart_tool', | ||
| )); | ||
| } | ||
|
|
||
| String _which(String executable) { | ||
| final io.ProcessResult result = io.Process.runSync('which', <String>[executable]); | ||
| if (result.exitCode != 0) { | ||
| io.stderr.writeln(result.stderr); | ||
| io.exit(result.exitCode); | ||
| } | ||
| return result.stdout; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It looks to me like all you need to compute here is the engine src dir. Everything else can be a getter that's derived from engine src.
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.
Thanks! That cleaned it up significantly.