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 7 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: 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
175 changes: 175 additions & 0 deletions lib/web_ui/dev/environment.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
// 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 {
if (Environment.commandLineArguments == null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check already exists in the Environment constructor. Is there a reason for duplicating it here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

io.stderr.writeln('Command-line options not passed to Environment.');
io.exit(1);
}
if (_environment == null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return _environment ??= Environment(); if you wanna be concise :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

_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
Copy Markdown
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
Copy Markdown
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 webUiRootDir = self.parent.parent;
final io.Directory engineSrcDir = webUiRootDir.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 String dartExecutable = pathlib.canonicalize(io.File(_which(io.Platform.executable)).absolute.path);
final io.Directory dartSdkDir = io.File(dartExecutable).parent.parent;

// Googlers frequently have their Dart SDK misconfigured for open-source projects. Let's help them out.
if (dartExecutable.startsWith('/usr/lib/google-dartlang')) {
io.stderr.writeln('ERROR: Using unsupported version of the Dart SDK: $dartExecutable');
io.exit(1);
}

return Environment._(
self: self,
webUiRootDir: webUiRootDir,
engineSrcDir: engineSrcDir,
outDir: outDir,
hostDebugUnoptDir: hostDebugUnoptDir,
dartExecutable: dartExecutable,
dartSdkDir: dartSdkDir,
requestedShards: shards,
isDebug: isDebug,
targets: targets,
);
}

Environment._({
this.self,
this.webUiRootDir,
this.engineSrcDir,
this.outDir,
this.hostDebugUnoptDir,
this.dartSdkDir,
this.dartExecutable,
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;

/// The "dart" executable file.
final String dartExecutable;

/// 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 "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