Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ task:
cd $ENGINE_PATH/src
./flutter/testing/run_tests.sh host_debug_unopt
test_web_engine_script: |
google-chrome --version
cd $ENGINE_PATH/src/flutter/web_sdk/web_engine_tester
$ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/pub get
cd $ENGINE_PATH/src/flutter/lib/web_ui
$ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/pub get
$ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/dart dev/test.dart
CHROME_NO_SANDBOX=true $ENGINE_PATH/src/out/host_debug_unopt/dart-sdk/bin/dart dev/test.dart
fetch_framework_script: |
mkdir -p $FRAMEWORK_PATH
cd $FRAMEWORK_PATH
Expand Down
1 change: 0 additions & 1 deletion ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ FILE: ../../../flutter/lib/ui/window/viewport_metrics.cc
FILE: ../../../flutter/lib/ui/window/viewport_metrics.h
FILE: ../../../flutter/lib/ui/window/window.cc
FILE: ../../../flutter/lib/ui/window/window.h
FILE: ../../../flutter/lib/web_ui/dev/test.dart
FILE: ../../../flutter/lib/web_ui/lib/assets/houdini_painter.js
FILE: ../../../flutter/lib/web_ui/lib/src/engine.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/alarm_clock.dart
Expand Down
2 changes: 1 addition & 1 deletion ci/licenses_golden/tool_signature
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Signature: 24e0fa6ad08ae80380158c2b4ba44c65
Signature: d510e80277a674c258a08394950ac485

1 change: 1 addition & 0 deletions lib/web_ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
11 changes: 11 additions & 0 deletions lib/web_ui/build.yaml
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
167 changes: 167 additions & 0 deletions lib/web_ui/dev/environment.dart
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);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

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;
}
Loading