From 6b4db1f60a24f8f59ab90a29954aa521be73be7e Mon Sep 17 00:00:00 2001 From: John McCutchan Date: Thu, 4 Apr 2024 11:28:04 -0700 Subject: [PATCH] Expand understanding of build targets in et (flutter/engine#51868) - s/TestTarget/BuildTarget. - Use a more informative way of querying for build targets from gn - Port existing code to use new interfaces - Replace 'query tests' with 'query targets' and a --testonly flag - Extend 'et build' with support for build target selectors. - Extend 'et query targets' with support for build target selectors. --- .../lib/src/commands/build_command.dart | 30 ++- .../engine_tool/lib/src/commands/flags.dart | 1 + .../lib/src/commands/query_command.dart | 42 +++- .../lib/src/commands/test_command.dart | 28 ++- .../tools/engine_tool/lib/src/gn_utils.dart | 177 ++++++++++------ .../tools/engine_tool/lib/src/json_utils.dart | 33 +++ .../engine_tool/test/build_command_test.dart | 192 ++++++++---------- .../tools/engine_tool/test/fixtures.dart | 103 +++++++++- .../tools/engine_tool/test/gn_utils_test.dart | 25 +-- .../engine_tool/test/query_command_test.dart | 18 +- .../engine_tool/test/test_command_test.dart | 14 +- .../flutter/tools/engine_tool/test/utils.dart | 9 +- 12 files changed, 420 insertions(+), 252 deletions(-) diff --git a/engine/src/flutter/tools/engine_tool/lib/src/commands/build_command.dart b/engine/src/flutter/tools/engine_tool/lib/src/commands/build_command.dart index 2b5c2210fc..cbd45ee08b 100644 --- a/engine/src/flutter/tools/engine_tool/lib/src/commands/build_command.dart +++ b/engine/src/flutter/tools/engine_tool/lib/src/commands/build_command.dart @@ -2,9 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:io'; + import 'package:engine_build_configs/engine_build_configs.dart'; +import 'package:path/path.dart' as p; import '../build_utils.dart'; +import '../gn_utils.dart'; import 'command.dart'; import 'flags.dart'; @@ -18,7 +22,9 @@ final class BuildCommand extends CommandBase { builds = runnableBuilds(environment, configs); debugCheckBuilds(builds); addConfigOption( - environment, argParser, runnableBuilds(environment, configs), + environment, + argParser, + runnableBuilds(environment, configs), ); argParser.addFlag( rbeFlag, @@ -35,7 +41,9 @@ final class BuildCommand extends CommandBase { String get name => 'build'; @override - String get description => 'Builds the engine'; + String get description => 'Builds the engine' + 'et build //flutter/fml/... # Build all targets in `//flutter/fml/`' + 'et build //flutter/fml:fml_benchmarks # Build a specific target in `//flutter/fml/`'; @override Future run() async { @@ -53,6 +61,22 @@ final class BuildCommand extends CommandBase { if (!useRbe) '--no-rbe', ]; - return runBuild(environment, build, extraGnArgs: extraGnArgs); + final Map allTargets = await findTargets(environment, + Directory(p.join(environment.engine.outDir.path, build.ninja.config))); + final Set selectedTargets = + selectTargets(argResults!.rest, allTargets); + if (selectedTargets.isEmpty) { + environment.logger.error( + 'No build targets matched ${argResults!.rest}\nRun `et query targets` to see list of targets.'); + return 1; + } + + // Chop off the '//' prefix. + final List buildTargets = selectedTargets + .map( + (BuildTarget target) => target.label.substring('//'.length)) + .toList(); + return runBuild(environment, build, + extraGnArgs: extraGnArgs, targets: buildTargets); } } diff --git a/engine/src/flutter/tools/engine_tool/lib/src/commands/flags.dart b/engine/src/flutter/tools/engine_tool/lib/src/commands/flags.dart index 6d13847bd2..711ca8a591 100644 --- a/engine/src/flutter/tools/engine_tool/lib/src/commands/flags.dart +++ b/engine/src/flutter/tools/engine_tool/lib/src/commands/flags.dart @@ -19,3 +19,4 @@ const String quietFlag = 'quiet'; const String rbeFlag = 'rbe'; const String runTestsFlag = 'run-tests'; const String verboseFlag = 'verbose'; +const String testOnlyFlag = 'testonly'; diff --git a/engine/src/flutter/tools/engine_tool/lib/src/commands/query_command.dart b/engine/src/flutter/tools/engine_tool/lib/src/commands/query_command.dart index 4b7fa50230..5dfe175eea 100644 --- a/engine/src/flutter/tools/engine_tool/lib/src/commands/query_command.dart +++ b/engine/src/flutter/tools/engine_tool/lib/src/commands/query_command.dart @@ -48,7 +48,7 @@ final class QueryCommand extends CommandBase { environment: environment, configs: configs, )); - addSubcommand(QueryTestsCommand( + addSubcommand(QueryTargetsCommand( environment: environment, configs: configs, )); @@ -131,17 +131,25 @@ final class QueryBuildersCommand extends CommandBase { } } -/// The query tests command. -final class QueryTestsCommand extends CommandBase { - /// Constructs the 'query tests' command. - QueryTestsCommand({ +/// The query targets command. +final class QueryTargetsCommand extends CommandBase { + /// Constructs the 'query targets' command. + QueryTargetsCommand({ required super.environment, required this.configs, }) { builds = runnableBuilds(environment, configs); debugCheckBuilds(builds); addConfigOption( - environment, argParser, runnableBuilds(environment, configs), + environment, + argParser, + runnableBuilds(environment, configs), + ); + argParser.addFlag( + testOnlyFlag, + abbr: 't', + help: 'Filter build targets to only include tests', + negatable: false, ); } @@ -152,14 +160,17 @@ final class QueryTestsCommand extends CommandBase { late final List builds; @override - String get name => 'tests'; + String get name => 'targets'; @override - String get description => 'Provides information about test targets'; + String get description => 'Provides information about build targets' + 'et query targets --testonly # List only test targets' + 'et query targets //flutter/fml/... # List all targets under `//flutter/fml`'; @override Future run() async { final String configName = argResults![configFlag] as String; + final bool testOnly = argResults![testOnlyFlag] as bool; final String demangledName = demangleConfigName(environment, configName); final Build? build = builds.where((Build build) => build.name == demangledName).firstOrNull; @@ -167,9 +178,20 @@ final class QueryTestsCommand extends CommandBase { environment.logger.error('Could not find config $configName'); return 1; } - final Map targets = await findTestTargets(environment, + final Map allTargets = await findTargets(environment, Directory(p.join(environment.engine.outDir.path, build.ninja.config))); - for (final TestTarget target in targets.values) { + final Set selectedTargets = + selectTargets(argResults!.rest, allTargets); + if (selectedTargets.isEmpty) { + environment.logger.error( + 'No build targets matched ${argResults!.rest}\nRun `et query targets` to see list of targets.'); + return 1; + } + for (final BuildTarget target in selectedTargets) { + if (testOnly && + (!target.testOnly || target.type != BuildTargetType.executable)) { + continue; + } environment.logger.status(target.label); } return 0; diff --git a/engine/src/flutter/tools/engine_tool/lib/src/commands/test_command.dart b/engine/src/flutter/tools/engine_tool/lib/src/commands/test_command.dart index 4ba6d6ac62..fe75fb25dc 100644 --- a/engine/src/flutter/tools/engine_tool/lib/src/commands/test_command.dart +++ b/engine/src/flutter/tools/engine_tool/lib/src/commands/test_command.dart @@ -24,7 +24,9 @@ final class TestCommand extends CommandBase { builds = runnableBuilds(environment, configs); debugCheckBuilds(builds); addConfigOption( - environment, argParser, runnableBuilds(environment, configs), + environment, + argParser, + runnableBuilds(environment, configs), ); } @@ -50,19 +52,29 @@ final class TestCommand extends CommandBase { return 1; } - final Map allTargets = await findTestTargets( - environment, + final Map allTargets = await findTargets(environment, Directory(p.join(environment.engine.outDir.path, build.ninja.config))); - final Set selectedTargets = + final Set selectedTargets = selectTargets(argResults!.rest, allTargets); if (selectedTargets.isEmpty) { environment.logger.error( - 'No build targets matched ${argResults!.rest}\nRun `et query tests` to see list of targets.'); + 'No build targets matched ${argResults!.rest}\nRun `et query targets --testonly` to see list of targets.'); return 1; } + for (final BuildTarget target in selectedTargets) { + if (!target.testOnly || target.type != BuildTargetType.executable) { + // Remove any targets that aren't testOnly and aren't executable. + selectedTargets.remove(target); + } + if (target.executable == null) { + environment.logger.fatal( + '$target is an executable but is missing the executable path'); + } + } // Chop off the '//' prefix. final List buildTargets = selectedTargets - .map((TestTarget target) => target.label.substring('//'.length)) + .map( + (BuildTarget target) => target.label.substring('//'.length)) .toList(); // TODO(johnmccutchan): runBuild manipulates buildTargets and adds some // targets listed in Build. Fix this. @@ -74,8 +86,8 @@ final class TestCommand extends CommandBase { final WorkerPool workerPool = WorkerPool(environment, ProcessTaskProgressReporter(environment)); final Set tasks = {}; - for (final TestTarget target in selectedTargets) { - final List commandLine = [target.executable.path]; + for (final BuildTarget target in selectedTargets) { + final List commandLine = [target.executable!.path]; tasks.add(ProcessTask( target.label, environment, environment.engine.srcDir, commandLine)); } diff --git a/engine/src/flutter/tools/engine_tool/lib/src/gn_utils.dart b/engine/src/flutter/tools/engine_tool/lib/src/gn_utils.dart index ace20254eb..5a527a38e5 100644 --- a/engine/src/flutter/tools/engine_tool/lib/src/gn_utils.dart +++ b/engine/src/flutter/tools/engine_tool/lib/src/gn_utils.dart @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:convert'; import 'dart:io'; import 'package:path/path.dart' as p; import 'package:process_runner/process_runner.dart'; import 'environment.dart'; +import 'json_utils.dart'; import 'proc_utils.dart'; /// Canonicalized build targets start with this prefix. @@ -16,87 +18,117 @@ const String buildTargetPrefix = '//'; /// A suffix to build targets that recursively selects all child build targets. const String _buildTargetGlobSuffix = '/...'; -/// Information about a test build target. -final class TestTarget { - /// Construct a test target. - TestTarget(this.label, this.executable); +/// The type of a BuildTarget +enum BuildTargetType { + /// Produces an executable program. + executable, - /// The build target label. `//flutter/fml:fml_unittests` - final String label; + /// Produces a shared library. + sharedLibrary, - /// The executable file produced after the build target is built. - final File executable; + /// Produces a static library. + staticLibrary, +} - @override - String toString() { - return 'target=$label executable=${executable.path}'; +BuildTargetType? _buildTargetTypeFromString(String type) { + switch (type) { + case 'executable': + return BuildTargetType.executable; + case 'shared_library': + return BuildTargetType.sharedLibrary; + case 'static_library': + return BuildTargetType.staticLibrary; + default: + // We ignore a number of types here. + return null; } } -/// Returns test targets for a given build directory. -Future> findTestTargets( +// TODO(johnmccutchan): What should we do about source_sets and other +// output-less targets? Also, what about action targets which are kind of +// "internal" build steps? For now we are ignoring them. + +/// Information about a build target. +final class BuildTarget { + //// Construct a build target. + BuildTarget(this.type, this.label, {this.executable, this.testOnly = false}); + + /// The type of build target. + final BuildTargetType type; + + /// The build target label. `//flutter/fml:fml_unittests`. + final String label; + + /// The executable file produced after the build target is built. + final File? executable; + + /// Is this a target that is only used by tests? + final bool testOnly; + + @override + String toString() { + return 'target=$label type=$type testOnly=$testOnly executable=${executable ?? "N/A"}'; + } +} + +/// Returns all targets for a given build directory. +Future> findTargets( Environment environment, Directory buildDir) async { - final Map r = {}; - final List getLabelsCommandLine = [ + final Map r = {}; + final List getBuildInfoCommandLine = [ gnBinPath(environment), - 'ls', + 'desc', buildDir.path, - '--type=executable', - '--testonly=true', - '--as=label', - ]; - final List getOutputsCommandLine = [ - gnBinPath(environment), - 'ls', - buildDir.path, - '--type=executable', - '--testonly=true', - '--as=output' + '*', + '--format=json', ]; - // Spawn the two processes concurrently. - final Future futureLabelsResult = - environment.processRunner.runProcess(getLabelsCommandLine, - workingDirectory: environment.engine.srcDir, failOk: true); - final Future futureOutputsResult = - environment.processRunner.runProcess(getOutputsCommandLine, - workingDirectory: environment.engine.srcDir, failOk: true); - - // Await the futures, we need both to complete so the order doesn't matter. - final ProcessRunnerResult labelsResult = await futureLabelsResult; - final ProcessRunnerResult outputsResult = await futureOutputsResult; + final ProcessRunnerResult result = await environment.processRunner.runProcess( + getBuildInfoCommandLine, + workingDirectory: environment.engine.srcDir, + failOk: true); // Handle any process failures. - fatalIfFailed(environment, getLabelsCommandLine, labelsResult); - fatalIfFailed(environment, getOutputsCommandLine, outputsResult); + fatalIfFailed(environment, getBuildInfoCommandLine, result); - // Extract the labels - final String rawLabels = labelsResult.stdout; - final String rawOutputs = outputsResult.stdout; - final List labels = rawLabels.split('\n'); - final List outputs = rawOutputs.split('\n'); - if (labels.length != outputs.length) { + late final Map jsonResult; + try { + jsonResult = jsonDecode(result.stdout) as Map; + } catch (e) { environment.logger.fatal( - 'gn ls output is inconsistent A and B should be the same length:\nA=$labels\nB=$outputs'); + 'gn desc output could not be parsed:\nE=$e\nIN=${result.stdout}\n'); } - // Drop the empty line at the end of the output. - if (labels.isNotEmpty) { - if (labels.last.isNotEmpty || outputs.last.isNotEmpty) { - throw AssertionError('expected last line of output to be blank.'); + + for (final MapEntry targetEntry in jsonResult.entries) { + final String label = targetEntry.key; + if (targetEntry.value == null) { + environment.logger + .fatal('gn desc output is malformed $label has no value.'); } - labels.removeLast(); - outputs.removeLast(); - } - for (int i = 0; i < labels.length; i++) { - final String label = labels[i]; - final String output = outputs[i]; - if (label.isEmpty) { - throw AssertionError('expected line to not be empty.'); + final Map properties = + targetEntry.value! as Map; + final String? typeString = getString(properties, 'type'); + if (typeString == null) { + environment.logger.fatal('gn desc is missing target type: $properties'); } - if (output.isEmpty) { - throw AssertionError('expected line to not be empty.'); + final BuildTargetType? type = _buildTargetTypeFromString(typeString!); + if (type == null) { + // Target is a type that we don't support. + continue; } - r[label] = TestTarget(label, File(p.join(buildDir.path, output))); + final bool testOnly = getBool(properties, 'testonly'); + final List outputs = + getListOfString(properties, 'outputs') ?? []; + File? executable; + if (type == BuildTargetType.executable) { + if (outputs.isEmpty) { + environment.logger.fatal('gn executable target $label has no outputs.'); + } + executable = File(p.join(buildDir.path, outputs.first)); + } + final BuildTarget target = + BuildTarget(type, label, testOnly: testOnly, executable: executable); + r[label] = target; } return r; } @@ -106,9 +138,20 @@ Future> findTestTargets( /// We support: /// 1) Exact label matches (the '//' prefix will be stripped off). /// 2) '/...' suffix which selects all targets that match the prefix. -Set selectTargets( - List selectors, Map allTargets) { - final Set selected = {}; +/// +/// NOTE: if selectors is empty all targets will be selected. +Set selectTargets( + List selectors, Map allTargets) { + final Set selected = {}; + + if (selectors.isEmpty) { + // Default to all if no selectors are specified. + // TODO(johnmccutchan): Reconsider this default or at least lift + // this logic up to the caller. + allTargets.values.forEach(selected.add); + return selected; + } + for (String selector in selectors) { if (!selector.startsWith(buildTargetPrefix)) { // Insert the prefix when necessary. @@ -120,13 +163,13 @@ Set selectTargets( selector = selector.substring( 0, selector.length - _buildTargetGlobSuffix.length); // TODO(johnmccutchan): Accelerate this by using a trie. - for (final TestTarget target in allTargets.values) { + for (final BuildTarget target in allTargets.values) { if (target.label.startsWith(selector)) { selected.add(target); } } } else { - for (final TestTarget target in allTargets.values) { + for (final BuildTarget target in allTargets.values) { if (target.label == selector) { selected.add(target); } diff --git a/engine/src/flutter/tools/engine_tool/lib/src/json_utils.dart b/engine/src/flutter/tools/engine_tool/lib/src/json_utils.dart index 07cc42ca21..e813512e7c 100644 --- a/engine/src/flutter/tools/engine_tool/lib/src/json_utils.dart +++ b/engine/src/flutter/tools/engine_tool/lib/src/json_utils.dart @@ -84,3 +84,36 @@ const JsonEncoder _jsonEncoder = JsonEncoder.withIndent(' '); /// Same as [jsonEncode] but is formatted to be human readable. String jsonEncodePretty(Object? object) => _jsonEncoder.convert(object); + +/// Returns the value in map[field] iff it is a String. null otherwise. +String? getString(Map map, String field) { + if (map[field] case final String value) { + return value; + } + return null; +} + +/// Returns the value in map[field] iff it is a bool. missingValue otherwise. +bool getBool(Map map, String field, + [bool missingValue = false]) { + if (map[field] case final bool value) { + return value; + } + return missingValue; +} + +/// Returns the value in map[field] iff it is a List. null otherwise. +List? getListOfString(Map map, String field) { + if (map[field] == null) { + return null; + } + if (map[field]! is! List) { + return null; + } + for (final Object? obj in map[field]! as List) { + if (obj is! String) { + return null; + } + } + return (map[field]! as List).cast(); +} diff --git a/engine/src/flutter/tools/engine_tool/test/build_command_test.dart b/engine/src/flutter/tools/engine_tool/test/build_command_test.dart index 759e660d0f..13f7fb6cee 100644 --- a/engine/src/flutter/tools/engine_tool/test/build_command_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/build_command_test.dart @@ -11,14 +11,12 @@ import 'package:engine_repo_tools/engine_repo_tools.dart'; import 'package:engine_tool/src/build_utils.dart'; import 'package:engine_tool/src/commands/command_runner.dart'; import 'package:engine_tool/src/environment.dart'; -import 'package:engine_tool/src/logger.dart'; import 'package:litetest/litetest.dart'; import 'package:path/path.dart' as path; import 'package:platform/platform.dart'; -import 'package:process_fakes/process_fakes.dart'; -import 'package:process_runner/process_runner.dart'; import 'fixtures.dart' as fixtures; +import 'utils.dart'; void main() { final BuilderConfig linuxTestConfig = BuilderConfig.fromJson( @@ -46,10 +44,12 @@ void main() { 'win_test_config': winTestConfig, }; - (Environment, List>) linuxEnv( - Logger logger, { - bool withRbe = false, - }) { + final List cannedProcesses = [ + CannedProcess((List command) => command.contains('desc'), + stdout: fixtures.gnDescOutput()), + ]; + + TestEnvironment makeTestEnv({bool withRbe = false}) { final io.Directory rootDir = io.Directory.systemTemp.createTempSync('et'); final TestEngine engine = TestEngine.createTemp(rootDir: rootDir); if (withRbe) { @@ -60,60 +60,35 @@ void main() { 'rbe', )).createSync(recursive: true); } - final List> runHistory = >[]; - return ( - Environment( - abi: ffi.Abi.linuxX64, - engine: engine, - platform: FakePlatform( - operatingSystem: Platform.linux, - resolvedExecutable: io.Platform.resolvedExecutable, - pathSeparator: '/'), - processRunner: ProcessRunner( - processManager: FakeProcessManager( - canRun: (Object? exe, {String? workingDirectory}) => true, - onStart: (List command) { - runHistory.add(command); - return FakeProcess(); - }, - onRun: (List command) { - runHistory.add(command); - return io.ProcessResult(81, 0, '', ''); - }, - ), - ), - logger: logger, - ), - runHistory - ); + final TestEnvironment testEnvironment = TestEnvironment(engine, + abi: ffi.Abi.linuxX64, cannedProcesses: cannedProcesses); + return testEnvironment; } - void cleanupEnv(Environment env) { + void cleanupEnv(TestEnvironment testEnv) { try { - env.engine.srcDir.parent.deleteSync(recursive: true); + testEnv.environment.engine.srcDir.parent.deleteSync(recursive: true); } catch (_) { // Ignore failure to clean up. } } test('can find host runnable build', () async { - final Logger logger = Logger.test(); - final (Environment env, _) = linuxEnv(logger); + final TestEnvironment testEnv = makeTestEnv(); try { - final List result = runnableBuilds(env, configs); + final List result = runnableBuilds(testEnv.environment, configs); expect(result.length, equals(8)); expect(result[0].name, equals('ci/build_name')); } finally { - cleanupEnv(env); + cleanupEnv(testEnv); } }); test('build command invokes gn', () async { - final Logger logger = Logger.test(); - final (Environment env, List> runHistory) = linuxEnv(logger); + final TestEnvironment testEnv = makeTestEnv(); try { final ToolCommandRunner runner = ToolCommandRunner( - environment: env, + environment: testEnv.environment, configs: configs, ); final int result = await runner.run([ @@ -121,21 +96,20 @@ void main() { '--config', 'ci/build_name', ]); + print(testEnv.processHistory); expect(result, equals(0)); - expect(runHistory.length, greaterThanOrEqualTo(1)); - expect(runHistory[0].length, greaterThanOrEqualTo(1)); - expect(runHistory[0][0], contains('gn')); + expect(testEnv.processHistory.length, greaterThanOrEqualTo(1)); + expect(testEnv.processHistory[0].command[0], contains('gn')); } finally { - cleanupEnv(env); + cleanupEnv(testEnv); } }); test('build command invokes ninja', () async { - final Logger logger = Logger.test(); - final (Environment env, List> runHistory) = linuxEnv(logger); + final TestEnvironment testEnv = makeTestEnv(); try { final ToolCommandRunner runner = ToolCommandRunner( - environment: env, + environment: testEnv.environment, configs: configs, ); final int result = await runner.run([ @@ -144,20 +118,18 @@ void main() { 'ci/build_name', ]); expect(result, equals(0)); - expect(runHistory.length, greaterThanOrEqualTo(2)); - expect(runHistory[1].length, greaterThanOrEqualTo(1)); - expect(runHistory[1][0], contains('ninja')); + expect(testEnv.processHistory.length, greaterThanOrEqualTo(2)); + expect(testEnv.processHistory[2].command[0], contains('ninja')); } finally { - cleanupEnv(env); + cleanupEnv(testEnv); } }); test('build command invokes generator', () async { - final Logger logger = Logger.test(); - final (Environment env, List> runHistory) = linuxEnv(logger); + final TestEnvironment testEnv = makeTestEnv(); try { final ToolCommandRunner runner = ToolCommandRunner( - environment: env, + environment: testEnv.environment, configs: configs, ); final int result = await runner.run([ @@ -166,22 +138,21 @@ void main() { 'ci/build_name', ]); expect(result, equals(0)); - expect(runHistory.length, greaterThanOrEqualTo(3)); + expect(testEnv.processHistory.length, greaterThanOrEqualTo(3)); expect( - runHistory[2], + testEnv.processHistory[3].command, containsStringsInOrder(['python3', 'gen/script.py']), ); } finally { - cleanupEnv(env); + cleanupEnv(testEnv); } }); test('build command does not invoke tests', () async { - final Logger logger = Logger.test(); - final (Environment env, List> runHistory) = linuxEnv(logger); + final TestEnvironment testEnv = makeTestEnv(); try { final ToolCommandRunner runner = ToolCommandRunner( - environment: env, + environment: testEnv.environment, configs: configs, ); final int result = await runner.run([ @@ -190,20 +161,17 @@ void main() { 'ci/build_name', ]); expect(result, equals(0)); - expect(runHistory.length, lessThanOrEqualTo(3)); + expect(testEnv.processHistory.length, lessThanOrEqualTo(4)); } finally { - cleanupEnv(env); + cleanupEnv(testEnv); } }); test('build command runs rbe on an rbe build', () async { - final Logger logger = Logger.test(); - final (Environment env, List> runHistory) = linuxEnv( - logger, withRbe: true, - ); + final TestEnvironment testEnv = makeTestEnv(withRbe: true); try { final ToolCommandRunner runner = ToolCommandRunner( - environment: env, + environment: testEnv.environment, configs: configs, ); final int result = await runner.run([ @@ -212,22 +180,21 @@ void main() { 'ci/android_debug_rbe_arm64', ]); expect(result, equals(0)); - expect(runHistory[0][0], contains(path.join('tools', 'gn'))); - expect(runHistory[0][4], equals('--rbe')); - expect(runHistory[1][0], contains(path.join('reclient', 'bootstrap'))); + expect(testEnv.processHistory[1].command[0], + contains(path.join('tools', 'gn'))); + expect(testEnv.processHistory[1].command[4], equals('--rbe')); + expect(testEnv.processHistory[2].command[0], + contains(path.join('reclient', 'bootstrap'))); } finally { - cleanupEnv(env); + cleanupEnv(testEnv); } }); test('build command does not run rbe when disabled', () async { - final Logger logger = Logger.test(); - final (Environment env, List> runHistory) = linuxEnv( - logger, withRbe: true, - ); + final TestEnvironment testEnv = makeTestEnv(withRbe: true); try { final ToolCommandRunner runner = ToolCommandRunner( - environment: env, + environment: testEnv.environment, configs: configs, ); final int result = await runner.run([ @@ -237,20 +204,23 @@ void main() { '--no-rbe', ]); expect(result, equals(0)); - expect(runHistory[0][0], contains(path.join('tools', 'gn'))); - expect(runHistory[0], doesNotContainAny(['--rbe'])); - expect(runHistory[1][0], contains(path.join('ninja', 'ninja'))); + expect(testEnv.processHistory[1].command[0], + contains(path.join('tools', 'gn'))); + expect(testEnv.processHistory[1].command, + doesNotContainAny(['--rbe'])); + expect(testEnv.processHistory[2].command[0], + contains(path.join('ninja', 'ninja'))); } finally { - cleanupEnv(env); + cleanupEnv(testEnv); } }); - test('build command does not run rbe when rbe configs do not exist', () async { - final Logger logger = Logger.test(); - final (Environment env, List> runHistory) = linuxEnv(logger); + test('build command does not run rbe when rbe configs do not exist', + () async { + final TestEnvironment testEnv = makeTestEnv(); try { final ToolCommandRunner runner = ToolCommandRunner( - environment: env, + environment: testEnv.environment, configs: configs, ); final int result = await runner.run([ @@ -259,35 +229,39 @@ void main() { 'ci/android_debug_rbe_arm64', ]); expect(result, equals(0)); - expect(runHistory[0][0], contains(path.join('tools', 'gn'))); - expect(runHistory[0], doesNotContainAny(['--rbe'])); - expect(runHistory[1][0], contains(path.join('ninja', 'ninja'))); + expect(testEnv.processHistory[1].command[0], + contains(path.join('tools', 'gn'))); + expect(testEnv.processHistory[1].command, + doesNotContainAny(['--rbe'])); + expect(testEnv.processHistory[2].command[0], + contains(path.join('ninja', 'ninja'))); } finally { - cleanupEnv(env); + cleanupEnv(testEnv); } }); test('mangleConfigName removes the OS and adds ci/ as needed', () { - final Logger logger = Logger.test(); - final (Environment env, _) = linuxEnv(logger); + final TestEnvironment testEnv = makeTestEnv(); + final Environment env = testEnv.environment; expect(mangleConfigName(env, 'linux/build'), equals('build')); expect(mangleConfigName(env, 'ci/build'), equals('ci/build')); }); test('mangleConfigName throws when the input config name is malformed', () { - final Logger logger = Logger.test(); - final (Environment env, _) = linuxEnv(logger); + final TestEnvironment testEnv = makeTestEnv(); + final Environment env = testEnv.environment; expectArgumentError(() => mangleConfigName(env, 'build')); }); test('demangleConfigName adds the OS and removes ci/ as needed', () { - final Logger logger = Logger.test(); - final (Environment env, _) = linuxEnv(logger); + final TestEnvironment testEnv = makeTestEnv(); + final Environment env = testEnv.environment; expect(demangleConfigName(env, 'build'), equals('linux/build')); expect(demangleConfigName(env, 'ci/build'), equals('ci/build')); }); - test('local config name on the command line is correctly translated', () async { + test('local config name on the command line is correctly translated', + () async { final BuilderConfig namespaceTestConfigs = BuilderConfig.fromJson( path: 'ci/builders/namespace_test_config.json', map: convert.jsonDecode(fixtures.configsToTestNamespacing) @@ -296,11 +270,10 @@ void main() { final Map configs = { 'namespace_test_config': namespaceTestConfigs, }; - final Logger logger = Logger.test(); - final (Environment env, List> runHistory) = linuxEnv(logger); + final TestEnvironment testEnv = makeTestEnv(); try { final ToolCommandRunner runner = ToolCommandRunner( - environment: env, + environment: testEnv.environment, configs: configs, ); final int result = await runner.run([ @@ -309,10 +282,12 @@ void main() { 'host_debug', ]); expect(result, equals(0)); - expect(runHistory[1][0], contains(path.join('ninja', 'ninja'))); - expect(runHistory[1][2], contains('local_host_debug')); + expect(testEnv.processHistory[2].command[0], + contains(path.join('ninja', 'ninja'))); + expect( + testEnv.processHistory[2].command[2], contains('local_host_debug')); } finally { - cleanupEnv(env); + cleanupEnv(testEnv); } }); @@ -325,8 +300,8 @@ void main() { final Map configs = { 'namespace_test_config': namespaceTestConfigs, }; - final Logger logger = Logger.test(); - final (Environment env, List> runHistory) = linuxEnv(logger); + final TestEnvironment testEnv = makeTestEnv(); + final Environment env = testEnv.environment; try { final ToolCommandRunner runner = ToolCommandRunner( environment: env, @@ -338,10 +313,11 @@ void main() { 'ci/host_debug', ]); expect(result, equals(0)); - expect(runHistory[1][0], contains(path.join('ninja', 'ninja'))); - expect(runHistory[1][2], contains('ci/host_debug')); + expect(testEnv.processHistory[2].command[0], + contains(path.join('ninja', 'ninja'))); + expect(testEnv.processHistory[2].command[2], contains('ci/host_debug')); } finally { - cleanupEnv(env); + cleanupEnv(testEnv); } }); } diff --git a/engine/src/flutter/tools/engine_tool/test/fixtures.dart b/engine/src/flutter/tools/engine_tool/test/fixtures.dart index 02511d2459..c2ba3ba91b 100644 --- a/engine/src/flutter/tools/engine_tool/test/fixtures.dart +++ b/engine/src/flutter/tools/engine_tool/test/fixtures.dart @@ -224,14 +224,97 @@ String attachedDevices() => ''' ] '''; -// NOTE: The final empty line is intentional. -String gnLsTestOutputs() => ''' -display_list_unittests -flow_unittests -fml_arc_unittests'''; +String gnDescOutput() => ''' +{ + "//flutter/display_list:display_list_unittests": { + "all_dependent_configs": [ "//flutter/skia:fontmgr_mac_ct_public", "//flutter/skia:gpu_public", "//flutter/skia:gpu_shared_public", "//flutter/skia:jpeg_encode_public", "//flutter/skia:png_encode_public", "//flutter/skia:webp_encode_public", "//flutter/skia:jpeg_decode_public", "//flutter/skia:png_decode_public", "//flutter/skia:webp_decode_public", "//flutter/skia:wuffs_public", "//flutter/skia:xml_public" ], + "allow_circular_includes_from": [ ], + "asmflags": [ "-fno-strict-aliasing", "-fstack-protector-all", "--target=x86_64-apple-macos", "-arch", "x86_64", "-fcolor-diagnostics" ], + "cflags": [ "-fno-strict-aliasing", "-fstack-protector-all", "--target=x86_64-apple-macos", "-arch", "x86_64", "-fcolor-diagnostics", "-Wall", "-Wextra", "-Wendif-labels", "-Werror", "-Wno-missing-field-initializers", "-Wno-unused-parameter", "-Wno-unused-but-set-parameter", "-Wno-unused-but-set-variable", "-Wno-implicit-int-float-conversion", "-Wno-deprecated-copy", "-Wno-psabi", "-Wno-deprecated-literal-operator", "-Wno-unqualified-std-cast-call", "-Wno-non-c-typedef-for-linkage", "-Wno-range-loop-construct", "-Wunguarded-availability", "-Wno-deprecated-declarations", "-fvisibility=hidden", "-Wstring-conversion", "-Wnewline-eof", "-O2", "-fno-ident", "-fdata-sections", "-ffunction-sections", "-g2", "-Wunreachable-code", "-Wno-newline-eof" ], + "cflags_c": [ "-std=c99" ], + "cflags_cc": [ "-fvisibility-inlines-hidden", "-std=c++17", "-fno-rtti", "-nostdinc++", "-nostdinc++", "-fvisibility=hidden", "-fno-exceptions", "-stdlib=libc++", "-Wno-inconsistent-missing-override" ], + "cflags_objcc": [ "-fvisibility-inlines-hidden", "-fobjc-call-cxx-cdtors", "-std=c++17", "-fno-rtti", "-nostdinc++", "-nostdinc++", "-fvisibility=hidden", "-fno-exceptions", "-Wno-unguarded-availability" ], + "check_includes": true, + "configs": [ "//build/config:feature_flags", "//build/config/compiler:compiler", "//build/config/compiler:cxx_version_default", "//build/config/compiler:compiler_arm_fpu", "//build/config/compiler:chromium_code", "//build/config/compiler:default_include_dirs", "//build/config/compiler:no_rtti", "//build/config/compiler:runtime_library", "//third_party/libcxxabi:libcxxabi_config", "//third_party/libcxx:libcxx_config", "//build/config/gcc:no_exceptions", "//build/config/gcc:symbol_visibility_hidden", "//build/config:symbol_visibility_hidden", "//build/config/mac:sdk", "//build/config/clang:extra_warnings", "//build/config/clang:find_bad_constructs", "//build/config:release", "//build/config/compiler:optimize", "//build/config/compiler:default_optimization", "//build/config/compiler:symbols", "//build/config:default_libs", "//build/config/mac:mac_dynamic_flags", "//build/config/mac:mac_executable_flags", "//flutter/skia:fontmgr_mac_ct_public", "//flutter/skia:gpu_public", "//flutter/skia:gpu_shared_public", "//flutter/skia:jpeg_encode_public", "//flutter/skia:png_encode_public", "//flutter/skia:webp_encode_public", "//flutter/skia:jpeg_decode_public", "//flutter/skia:png_decode_public", "//flutter/skia:webp_decode_public", "//flutter/skia:wuffs_public", "//flutter/skia:xml_public", "//flutter/display_list:display_list_config", "//flutter:config", "//flutter/common:flutter_config", "//flutter/impeller:impeller_public_config", "//flutter/impeller/runtime_stage:runtime_stage_config", "//flutter/third_party/flatbuffers:flatbuffers_public_configs", "//flutter/impeller/renderer:embed_embed_mtl_compute_shaders", "//flutter/impeller/renderer:reflect_reflect_mtl_compute_shaders", "//flutter/impeller/renderer:embed_embed_vk_compute_shaders", "//flutter/skia:skia_public", "//flutter/testing:dynamic_symbols", "//flutter/third_party/googletest:gmock_config", "//flutter/third_party/googletest:gtest_config" ], + "defines": [ "USE_OPENSSL=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "_FORTIFY_SOURCE=2", "_LIBCPP_DISABLE_AVAILABILITY=1", "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS", "_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS", "NDEBUG", "NVALGRIND", "DYNAMIC_ANNOTATIONS_ENABLED=0", "SK_TYPEFACE_FACTORY_CORETEXT", "SK_FONTMGR_CORETEXT_AVAILABLE", "SK_GL", "SK_METAL", "SK_CODEC_DECODES_JPEG", "SK_CODEC_DECODES_PNG", "SK_CODEC_DECODES_ICO", "SK_CODEC_DECODES_WEBP", "SK_HAS_WUFFS_LIBRARY", "SK_CODEC_DECODES_GIF", "SK_XML", "FLUTTER_RUNTIME_MODE_DEBUG=1", "FLUTTER_RUNTIME_MODE_PROFILE=2", "FLUTTER_RUNTIME_MODE_RELEASE=3", "FLUTTER_RUNTIME_MODE_JIT_RELEASE=4", "DART_LEGACY_API=[[deprecated]]", "FLUTTER_RUNTIME_MODE=1", "FLUTTER_JIT_RUNTIME=1", "IMPELLER_DEBUG=1", "IMPELLER_ENABLE_CAPTURE=1", "IMPELLER_SUPPORTS_RENDERING=1", "IMPELLER_ENABLE_METAL=1", "IMPELLER_ENABLE_OPENGLES=1", "IMPELLER_ENABLE_VULKAN=1", "SK_CODEC_DECODES_BMP", "SK_CODEC_DECODES_WBMP", "SK_ENABLE_DUMP_GPU", "SK_FORCE_AAA", "SK_LEGACY_IGNORE_DRAW_VERTICES_BLEND_WITH_NO_SHADER", "SK_RESOLVE_FILTERS_BEFORE_RESTORE", "SK_DISABLE_LEGACY_METAL_BACKEND_SURFACE", "SK_DISABLE_LEGACY_SHADERCONTEXT", "SK_DISABLE_LOWP_RASTER_PIPELINE", "SK_FORCE_RASTER_PIPELINE_BLITTER", "SK_METAL_WAIT_UNTIL_SCHEDULED", "SK_DISABLE_EFFECT_DESERIALIZATION", "SK_ENABLE_PRECOMPILE", "SK_GANESH", "SK_USE_PERFETTO" ], + "deps": [ "//flutter/display_list:display_list", "//flutter/display_list:display_list_fixtures", "//flutter/display_list/testing:display_list_testing", "//flutter/testing:skia", "//flutter/testing:testing", "//third_party/libcxx:libcxx" ], + "externs": { -// NOTE: The empty blank line is intentional. -String gnLsTestLabels() => ''' -//flutter/display_list:display_list_unittests -//flutter/flow:flow_unittests -//flutter/fml:fml_arc_unittests'''; + }, + "frameworks": [ "Foundation.framework", "ApplicationServices.framework", "OpenGL.framework", "AppKit.framework", "Metal.framework" ], + "include_dirs": [ "//", "//out/host_debug/gen/", "//third_party/libcxx/include/", "//third_party/libcxxabi/include/", "//flutter/build/secondary/third_party/libcxx/config/", "//flutter/", "//out/host_debug/gen/flutter/", "//out/host_debug/gen/flutter/impeller/runtime_stage/", "//flutter/third_party/flatbuffers/include/", "//flutter/third_party/skia/", "//flutter/third_party/googletest/googlemock/include/", "//flutter/third_party/googletest/googletest/include/" ], + "ldflags": [ "--target=x86_64-apple-macos", "-arch", "x86_64", "-nostdlib++", "-Wl,-dead_strip", "-Wl,-search_paths_first", "-L.", "-Wl,-rpath,@loader_path/.", "-Wl,-rpath,/usr/local/lib/.", "-Wl,-rpath,@loader_path/../../..", "-Wl,-pie" ], + "libs": [ "dl" ], + "metadata": { + + }, + "outputs": [ "//out/host_debug/display_list_unittests" ], + "public": "*", + "sources": [ "//flutter/display_list/benchmarking/dl_complexity_unittests.cc", "//flutter/display_list/display_list_unittests.cc", "//flutter/display_list/dl_color_unittests.cc", "//flutter/display_list/dl_paint_unittests.cc", "//flutter/display_list/dl_vertices_unittests.cc", "//flutter/display_list/effects/dl_color_filter_unittests.cc", "//flutter/display_list/effects/dl_color_source_unittests.cc", "//flutter/display_list/effects/dl_image_filter_unittests.cc", "//flutter/display_list/effects/dl_mask_filter_unittests.cc", "//flutter/display_list/effects/dl_path_effect_unittests.cc", "//flutter/display_list/geometry/dl_region_unittests.cc", "//flutter/display_list/geometry/dl_rtree_unittests.cc", "//flutter/display_list/skia/dl_sk_conversions_unittests.cc", "//flutter/display_list/skia/dl_sk_paint_dispatcher_unittests.cc", "//flutter/display_list/utils/dl_matrix_clip_tracker_unittests.cc" ], + "testonly": true, + "toolchain": "//build/toolchain/mac:clang_x64", + "type": "executable", + "visibility": [ "*" ] + }, + "//flutter/flow:flow_unittests": { + "all_dependent_configs": [ "//flutter/skia:fontmgr_mac_ct_public", "//flutter/skia:gpu_public", "//flutter/skia:gpu_shared_public", "//flutter/skia:jpeg_encode_public", "//flutter/skia:png_encode_public", "//flutter/skia:webp_encode_public", "//flutter/skia:jpeg_decode_public", "//flutter/skia:png_decode_public", "//flutter/skia:webp_decode_public", "//flutter/skia:wuffs_public", "//flutter/skia:xml_public" ], + "allow_circular_includes_from": [ ], + "asmflags": [ "-fno-strict-aliasing", "-fstack-protector-all", "--target=x86_64-apple-macos", "-arch", "x86_64", "-fcolor-diagnostics" ], + "cflags": [ "-fno-strict-aliasing", "-fstack-protector-all", "--target=x86_64-apple-macos", "-arch", "x86_64", "-fcolor-diagnostics", "-Wall", "-Wextra", "-Wendif-labels", "-Werror", "-Wno-missing-field-initializers", "-Wno-unused-parameter", "-Wno-unused-but-set-parameter", "-Wno-unused-but-set-variable", "-Wno-implicit-int-float-conversion", "-Wno-deprecated-copy", "-Wno-psabi", "-Wno-deprecated-literal-operator", "-Wno-unqualified-std-cast-call", "-Wno-non-c-typedef-for-linkage", "-Wno-range-loop-construct", "-Wunguarded-availability", "-Wno-deprecated-declarations", "-fvisibility=hidden", "-Wstring-conversion", "-Wnewline-eof", "-O2", "-fno-ident", "-fdata-sections", "-ffunction-sections", "-g2", "-Wunreachable-code", "-Wno-newline-eof" ], + "cflags_c": [ "-std=c99" ], + "cflags_cc": [ "-fvisibility-inlines-hidden", "-std=c++17", "-fno-rtti", "-nostdinc++", "-nostdinc++", "-fvisibility=hidden", "-fno-exceptions", "-stdlib=libc++", "-Wno-inconsistent-missing-override" ], + "cflags_objcc": [ "-fvisibility-inlines-hidden", "-fobjc-call-cxx-cdtors", "-std=c++17", "-fno-rtti", "-nostdinc++", "-nostdinc++", "-fvisibility=hidden", "-fno-exceptions", "-Wno-unguarded-availability" ], + "check_includes": true, + "configs": [ "//build/config:feature_flags", "//build/config/compiler:compiler", "//build/config/compiler:cxx_version_default", "//build/config/compiler:compiler_arm_fpu", "//build/config/compiler:chromium_code", "//build/config/compiler:default_include_dirs", "//build/config/compiler:no_rtti", "//build/config/compiler:runtime_library", "//third_party/libcxxabi:libcxxabi_config", "//third_party/libcxx:libcxx_config", "//build/config/gcc:no_exceptions", "//build/config/gcc:symbol_visibility_hidden", "//build/config:symbol_visibility_hidden", "//build/config/mac:sdk", "//build/config/clang:extra_warnings", "//build/config/clang:find_bad_constructs", "//build/config:release", "//build/config/compiler:optimize", "//build/config/compiler:default_optimization", "//build/config/compiler:symbols", "//build/config:default_libs", "//build/config/mac:mac_dynamic_flags", "//build/config/mac:mac_executable_flags", "//flutter/skia:fontmgr_mac_ct_public", "//flutter/skia:gpu_public", "//flutter/skia:gpu_shared_public", "//flutter/skia:jpeg_encode_public", "//flutter/skia:png_encode_public", "//flutter/skia:webp_encode_public", "//flutter/skia:jpeg_decode_public", "//flutter/skia:png_decode_public", "//flutter/skia:webp_decode_public", "//flutter/skia:wuffs_public", "//flutter/skia:xml_public", "//flutter:config", "//flutter/common:flutter_config", "//flutter/display_list:display_list_config", "//flutter/impeller:impeller_public_config", "//flutter/impeller/runtime_stage:runtime_stage_config", "//flutter/third_party/flatbuffers:flatbuffers_public_configs", "//flutter/impeller/renderer:embed_embed_mtl_compute_shaders", "//flutter/impeller/renderer:reflect_reflect_mtl_compute_shaders", "//flutter/impeller/renderer:embed_embed_vk_compute_shaders", "//flutter/skia:skia_public", "//flutter/third_party/txt:txt_config", "//flutter/third_party/harfbuzz:harfbuzz_config", "//flutter/third_party/icu:icu_config", "//flutter/third_party/googletest:gmock_config", "//flutter/third_party/googletest:gtest_config", "//third_party/dart/runtime:dart_public_config" ], + "defines": [ "USE_OPENSSL=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "_FORTIFY_SOURCE=2", "_LIBCPP_DISABLE_AVAILABILITY=1", "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS", "_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS", "NDEBUG", "NVALGRIND", "DYNAMIC_ANNOTATIONS_ENABLED=0", "SK_TYPEFACE_FACTORY_CORETEXT", "SK_FONTMGR_CORETEXT_AVAILABLE", "SK_GL", "SK_METAL", "SK_CODEC_DECODES_JPEG", "SK_CODEC_DECODES_PNG", "SK_CODEC_DECODES_ICO", "SK_CODEC_DECODES_WEBP", "SK_HAS_WUFFS_LIBRARY", "SK_CODEC_DECODES_GIF", "SK_XML", "FLUTTER_RUNTIME_MODE_DEBUG=1", "FLUTTER_RUNTIME_MODE_PROFILE=2", "FLUTTER_RUNTIME_MODE_RELEASE=3", "FLUTTER_RUNTIME_MODE_JIT_RELEASE=4", "DART_LEGACY_API=[[deprecated]]", "FLUTTER_RUNTIME_MODE=1", "FLUTTER_JIT_RUNTIME=1", "IMPELLER_DEBUG=1", "IMPELLER_ENABLE_CAPTURE=1", "IMPELLER_SUPPORTS_RENDERING=1", "IMPELLER_ENABLE_METAL=1", "IMPELLER_ENABLE_OPENGLES=1", "IMPELLER_ENABLE_VULKAN=1", "SK_CODEC_DECODES_BMP", "SK_CODEC_DECODES_WBMP", "SK_ENABLE_DUMP_GPU", "SK_FORCE_AAA", "SK_LEGACY_IGNORE_DRAW_VERTICES_BLEND_WITH_NO_SHADER", "SK_RESOLVE_FILTERS_BEFORE_RESTORE", "SK_DISABLE_LEGACY_METAL_BACKEND_SURFACE", "SK_DISABLE_LEGACY_SHADERCONTEXT", "SK_DISABLE_LOWP_RASTER_PIPELINE", "SK_FORCE_RASTER_PIPELINE_BLITTER", "SK_METAL_WAIT_UNTIL_SCHEDULED", "SK_DISABLE_EFFECT_DESERIALIZATION", "SK_ENABLE_PRECOMPILE", "SK_GANESH", "SK_USE_PERFETTO", "U_USING_ICU_NAMESPACE=0", "U_ENABLE_DYLOAD=0", "USE_CHROMIUM_ICU=1", "U_ENABLE_TRACING=1", "U_ENABLE_RESOURCE_TRACING=0", "U_STATIC_IMPLEMENTATION", "ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE" ], + "deps": [ "//flutter/common/graphics:graphics", "//flutter/display_list/testing:display_list_testing", "//flutter/flow:flow", "//flutter/flow:flow_fixtures", "//flutter/flow:flow_testing", "//flutter/fml:fml", "//flutter/shell/common:base64", "//flutter/skia:skia", "//flutter/testing:skia", "//flutter/testing:testing_lib", "//flutter/third_party/googletest:gtest", "//third_party/dart/runtime:libdart_jit", "//third_party/libcxx:libcxx" ], + "externs": { + + }, + "frameworks": [ "Foundation.framework", "ApplicationServices.framework", "OpenGL.framework", "AppKit.framework", "Metal.framework" ], + "include_dirs": [ "//", "//out/host_debug/gen/", "//third_party/libcxx/include/", "//third_party/libcxxabi/include/", "//flutter/build/secondary/third_party/libcxx/config/", "//flutter/", "//out/host_debug/gen/flutter/", "//out/host_debug/gen/flutter/impeller/runtime_stage/", "//flutter/third_party/flatbuffers/include/", "//flutter/third_party/skia/", "//flutter/third_party/txt/src/", "//flutter/third_party/harfbuzz/src/", "//flutter/third_party/icu/source/common/", "//flutter/third_party/icu/source/i18n/", "//flutter/third_party/googletest/googlemock/include/", "//flutter/third_party/googletest/googletest/include/", "//third_party/dart/runtime/", "//third_party/dart/runtime/include/" ], + "ldflags": [ "--target=x86_64-apple-macos", "-arch", "x86_64", "-nostdlib++", "-Wl,-dead_strip", "-Wl,-search_paths_first", "-L.", "-Wl,-rpath,@loader_path/.", "-Wl,-rpath,/usr/local/lib/.", "-Wl,-rpath,@loader_path/../../..", "-Wl,-pie" ], + "libs": [ "dl", "pthread" ], + "metadata": { + + }, + "outputs": [ "//out/host_debug/flow_unittests" ], + "public": "*", + "sources": [ "//flutter/flow/diff_context_unittests.cc", "//flutter/flow/embedded_view_params_unittests.cc", "//flutter/flow/flow_run_all_unittests.cc", "//flutter/flow/flow_test_utils.cc", "//flutter/flow/flow_test_utils.h", "//flutter/flow/frame_timings_recorder_unittests.cc", "//flutter/flow/gl_context_switch_unittests.cc", "//flutter/flow/layers/backdrop_filter_layer_unittests.cc", "//flutter/flow/layers/checkerboard_layertree_unittests.cc", "//flutter/flow/layers/clip_path_layer_unittests.cc", "//flutter/flow/layers/clip_rect_layer_unittests.cc", "//flutter/flow/layers/clip_rrect_layer_unittests.cc", "//flutter/flow/layers/color_filter_layer_unittests.cc", "//flutter/flow/layers/container_layer_unittests.cc", "//flutter/flow/layers/display_list_layer_unittests.cc", "//flutter/flow/layers/image_filter_layer_unittests.cc", "//flutter/flow/layers/layer_state_stack_unittests.cc", "//flutter/flow/layers/layer_tree_unittests.cc", "//flutter/flow/layers/offscreen_surface_unittests.cc", "//flutter/flow/layers/opacity_layer_unittests.cc", "//flutter/flow/layers/performance_overlay_layer_unittests.cc", "//flutter/flow/layers/platform_view_layer_unittests.cc", "//flutter/flow/layers/shader_mask_layer_unittests.cc", "//flutter/flow/layers/texture_layer_unittests.cc", "//flutter/flow/layers/transform_layer_unittests.cc", "//flutter/flow/mutators_stack_unittests.cc", "//flutter/flow/raster_cache_unittests.cc", "//flutter/flow/skia_gpu_object_unittests.cc", "//flutter/flow/stopwatch_dl_unittests.cc", "//flutter/flow/stopwatch_unittests.cc", "//flutter/flow/surface_frame_unittests.cc", "//flutter/flow/testing/mock_layer_unittests.cc", "//flutter/flow/testing/mock_texture_unittests.cc", "//flutter/flow/texture_unittests.cc" ], + "testonly": true, + "toolchain": "//build/toolchain/mac:clang_x64", + "type": "executable", + "visibility": [ "*" ] + }, + "//flutter/fml:fml_arc_unittests": { + "all_dependent_configs": [ "//flutter/skia:fontmgr_mac_ct_public", "//flutter/skia:gpu_public", "//flutter/skia:gpu_shared_public", "//flutter/skia:jpeg_encode_public", "//flutter/skia:png_encode_public", "//flutter/skia:webp_encode_public", "//flutter/skia:jpeg_decode_public", "//flutter/skia:png_decode_public", "//flutter/skia:webp_decode_public", "//flutter/skia:wuffs_public", "//flutter/skia:xml_public" ], + "allow_circular_includes_from": [ ], + "asmflags": [ "-fno-strict-aliasing", "-fstack-protector-all", "--target=x86_64-apple-macos", "-arch", "x86_64", "-fcolor-diagnostics" ], + "cflags": [ "-fno-strict-aliasing", "-fstack-protector-all", "--target=x86_64-apple-macos", "-arch", "x86_64", "-fcolor-diagnostics", "-Wall", "-Wextra", "-Wendif-labels", "-Werror", "-Wno-missing-field-initializers", "-Wno-unused-parameter", "-Wno-unused-but-set-parameter", "-Wno-unused-but-set-variable", "-Wno-implicit-int-float-conversion", "-Wno-deprecated-copy", "-Wno-psabi", "-Wno-deprecated-literal-operator", "-Wno-unqualified-std-cast-call", "-Wno-non-c-typedef-for-linkage", "-Wno-range-loop-construct", "-Wunguarded-availability", "-Wno-deprecated-declarations", "-fvisibility=hidden", "-Wstring-conversion", "-Wnewline-eof", "-O2", "-fno-ident", "-fdata-sections", "-ffunction-sections", "-g2", "-Wunreachable-code", "-Wno-newline-eof" ], + "cflags_c": [ "-std=c99" ], + "cflags_cc": [ "-fvisibility-inlines-hidden", "-std=c++17", "-fno-rtti", "-nostdinc++", "-nostdinc++", "-fvisibility=hidden", "-fno-exceptions", "-stdlib=libc++", "-Wno-inconsistent-missing-override" ], + "cflags_objcc": [ "-Werror=overriding-method-mismatch", "-Werror=undeclared-selector", "-fapplication-extension", "-fobjc-arc", "-fvisibility-inlines-hidden", "-fobjc-call-cxx-cdtors", "-std=c++17", "-fno-rtti", "-nostdinc++", "-nostdinc++", "-fvisibility=hidden", "-fno-exceptions", "-Wno-unguarded-availability" ], + "check_includes": true, + "configs": [ "//build/config:feature_flags", "//build/config/compiler:compiler", "//build/config/compiler:cxx_version_default", "//build/config/compiler:compiler_arm_fpu", "//build/config/compiler:chromium_code", "//build/config/compiler:default_include_dirs", "//build/config/compiler:no_rtti", "//build/config/compiler:runtime_library", "//third_party/libcxxabi:libcxxabi_config", "//third_party/libcxx:libcxx_config", "//build/config/gcc:no_exceptions", "//build/config/gcc:symbol_visibility_hidden", "//build/config:symbol_visibility_hidden", "//build/config/mac:sdk", "//build/config/clang:extra_warnings", "//build/config/clang:find_bad_constructs", "//build/config:release", "//build/config/compiler:optimize", "//build/config/compiler:default_optimization", "//build/config/compiler:symbols", "//build/config:default_libs", "//build/config/mac:mac_dynamic_flags", "//build/config/mac:mac_executable_flags", "//flutter/skia:fontmgr_mac_ct_public", "//flutter/skia:gpu_public", "//flutter/skia:gpu_shared_public", "//flutter/skia:jpeg_encode_public", "//flutter/skia:png_encode_public", "//flutter/skia:webp_encode_public", "//flutter/skia:jpeg_decode_public", "//flutter/skia:png_decode_public", "//flutter/skia:webp_decode_public", "//flutter/skia:wuffs_public", "//flutter/skia:xml_public", "//flutter:config", "//flutter/common:flutter_config", "//flutter/testing:dynamic_symbols", "//flutter/display_list:display_list_config", "//flutter/impeller:impeller_public_config", "//flutter/impeller/runtime_stage:runtime_stage_config", "//flutter/third_party/flatbuffers:flatbuffers_public_configs", "//flutter/impeller/renderer:embed_embed_mtl_compute_shaders", "//flutter/impeller/renderer:reflect_reflect_mtl_compute_shaders", "//flutter/impeller/renderer:embed_embed_vk_compute_shaders", "//flutter/skia:skia_public", "//flutter/third_party/googletest:gmock_config", "//flutter/third_party/googletest:gtest_config" ], + "defines": [ "USE_OPENSSL=1", "__STDC_CONSTANT_MACROS", "__STDC_FORMAT_MACROS", "_FORTIFY_SOURCE=2", "_LIBCPP_DISABLE_AVAILABILITY=1", "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS", "_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS", "NDEBUG", "NVALGRIND", "DYNAMIC_ANNOTATIONS_ENABLED=0", "SK_TYPEFACE_FACTORY_CORETEXT", "SK_FONTMGR_CORETEXT_AVAILABLE", "SK_GL", "SK_METAL", "SK_CODEC_DECODES_JPEG", "SK_CODEC_DECODES_PNG", "SK_CODEC_DECODES_ICO", "SK_CODEC_DECODES_WEBP", "SK_HAS_WUFFS_LIBRARY", "SK_CODEC_DECODES_GIF", "SK_XML", "FLUTTER_RUNTIME_MODE_DEBUG=1", "FLUTTER_RUNTIME_MODE_PROFILE=2", "FLUTTER_RUNTIME_MODE_RELEASE=3", "FLUTTER_RUNTIME_MODE_JIT_RELEASE=4", "DART_LEGACY_API=[[deprecated]]", "FLUTTER_RUNTIME_MODE=1", "FLUTTER_JIT_RUNTIME=1", "IMPELLER_DEBUG=1", "IMPELLER_ENABLE_CAPTURE=1", "IMPELLER_SUPPORTS_RENDERING=1", "IMPELLER_ENABLE_METAL=1", "IMPELLER_ENABLE_OPENGLES=1", "IMPELLER_ENABLE_VULKAN=1", "SK_CODEC_DECODES_BMP", "SK_CODEC_DECODES_WBMP", "SK_ENABLE_DUMP_GPU", "SK_FORCE_AAA", "SK_LEGACY_IGNORE_DRAW_VERTICES_BLEND_WITH_NO_SHADER", "SK_RESOLVE_FILTERS_BEFORE_RESTORE", "SK_DISABLE_LEGACY_METAL_BACKEND_SURFACE", "SK_DISABLE_LEGACY_SHADERCONTEXT", "SK_DISABLE_LOWP_RASTER_PIPELINE", "SK_FORCE_RASTER_PIPELINE_BLITTER", "SK_METAL_WAIT_UNTIL_SCHEDULED", "SK_DISABLE_EFFECT_DESERIALIZATION", "SK_ENABLE_PRECOMPILE", "SK_GANESH", "SK_USE_PERFETTO" ], + "deps": [ "//flutter/fml:fml", "//flutter/fml:fml_fixtures", "//flutter/testing:testing", "//third_party/libcxx:libcxx" ], + "externs": { + + }, + "frameworks": [ "Foundation.framework", "ApplicationServices.framework", "OpenGL.framework", "AppKit.framework", "Metal.framework" ], + "include_dirs": [ "//", "//out/host_debug/gen/", "//third_party/libcxx/include/", "//third_party/libcxxabi/include/", "//flutter/build/secondary/third_party/libcxx/config/", "//flutter/", "//out/host_debug/gen/flutter/", "//out/host_debug/gen/flutter/impeller/runtime_stage/", "//flutter/third_party/flatbuffers/include/", "//flutter/third_party/skia/", "//flutter/third_party/googletest/googlemock/include/", "//flutter/third_party/googletest/googletest/include/" ], + "ldflags": [ "--target=x86_64-apple-macos", "-arch", "x86_64", "-nostdlib++", "-Wl,-dead_strip", "-Wl,-search_paths_first", "-L.", "-Wl,-rpath,@loader_path/.", "-Wl,-rpath,/usr/local/lib/.", "-Wl,-rpath,@loader_path/../../..", "-Wl,-pie" ], + "libs": [ "dl" ], + "metadata": { + + }, + "outputs": [ "//out/host_debug/fml_arc_unittests" ], + "public": "*", + "sources": [ "//flutter/fml/platform/darwin/scoped_nsobject_arc_unittests.mm", "//flutter/fml/platform/darwin/weak_nsobject_arc_unittests.mm" ], + "testonly": true, + "toolchain": "//build/toolchain/mac:clang_x64", + "type": "executable", + "visibility": [ "*" ] + } +} +'''; diff --git a/engine/src/flutter/tools/engine_tool/test/gn_utils_test.dart b/engine/src/flutter/tools/engine_tool/test/gn_utils_test.dart index e2a9846d73..e6ba96b04c 100644 --- a/engine/src/flutter/tools/engine_tool/test/gn_utils_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/gn_utils_test.dart @@ -9,6 +9,7 @@ import 'package:engine_tool/src/environment.dart'; import 'package:engine_tool/src/gn_utils.dart'; import 'package:litetest/litetest.dart'; +import 'fixtures.dart'; import 'utils.dart'; void main() { @@ -22,32 +23,22 @@ void main() { } final List cannedProcesses = [ - CannedProcess((List command) => command.contains('--as=label'), - stdout: ''' -//flutter/display_list:display_list_unittests -//flutter/flow:flow_unittests -//flutter/fml:fml_arc_unittests -'''), - CannedProcess((List command) => command.contains('--as=output'), - stdout: ''' -display_list_unittests -flow_unittests -fml_arc_unittests -''') + CannedProcess((List command) => command.contains('desc'), + stdout: gnDescOutput()), ]; test('find test targets', () async { final TestEnvironment testEnvironment = TestEnvironment(engine, cannedProcesses: cannedProcesses); final Environment env = testEnvironment.environment; - final Map testTargets = - await findTestTargets(env, engine.outDir); + final Map testTargets = + await findTargets(env, engine.outDir); expect(testTargets.length, equals(3)); expect(testTargets['//flutter/display_list:display_list_unittests'], notEquals(null)); expect( testTargets['//flutter/display_list:display_list_unittests']! - .executable + .executable! .path, endsWith('display_list_unittests')); }); @@ -56,8 +47,8 @@ fml_arc_unittests final TestEnvironment testEnvironment = TestEnvironment(engine, cannedProcesses: cannedProcesses); final Environment env = testEnvironment.environment; - final Map testTargets = - await findTestTargets(env, engine.outDir); + final Map testTargets = + await findTargets(env, engine.outDir); expect(selectTargets(['//...'], testTargets).length, equals(3)); expect( selectTargets(['//flutter/display_list'], testTargets).length, diff --git a/engine/src/flutter/tools/engine_tool/test/query_command_test.dart b/engine/src/flutter/tools/engine_tool/test/query_command_test.dart index f99878a9e1..c00acca4f6 100644 --- a/engine/src/flutter/tools/engine_tool/test/query_command_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/query_command_test.dart @@ -57,18 +57,8 @@ void main() { } final List cannedProcesses = [ - CannedProcess((List command) => command.contains('--as=label'), - stdout: ''' -//flutter/display_list:display_list_unittests -//flutter/flow:flow_unittests -//flutter/fml:fml_arc_unittests -'''), - CannedProcess((List command) => command.contains('--as=output'), - stdout: ''' -display_list_unittests -flow_unittests -fml_arc_unittests -''') + CannedProcess((List command) => command.contains('desc'), + stdout: fixtures.gnDescOutput()), ]; test('query command returns builds for the host platform.', () async { @@ -152,7 +142,7 @@ fml_arc_unittests ); }); - test('query tests', () async { + test('query targets', () async { final TestEnvironment testEnvironment = TestEnvironment(engine, abi: ffi.Abi.linuxX64, cannedProcesses: cannedProcesses); final Environment env = testEnvironment.environment; @@ -162,7 +152,7 @@ fml_arc_unittests ); final int result = await runner.run([ 'query', - 'tests', + 'targets', ]); expect(result, equals(0)); expect( diff --git a/engine/src/flutter/tools/engine_tool/test/test_command_test.dart b/engine/src/flutter/tools/engine_tool/test/test_command_test.dart index 081b81adae..a08b258822 100644 --- a/engine/src/flutter/tools/engine_tool/test/test_command_test.dart +++ b/engine/src/flutter/tools/engine_tool/test/test_command_test.dart @@ -52,18 +52,8 @@ void main() { }; final List cannedProcesses = [ - CannedProcess((List command) => command.contains('--as=label'), - stdout: ''' -//flutter/display_list:display_list_unittests -//flutter/flow:flow_unittests -//flutter/fml:fml_arc_unittests -'''), - CannedProcess((List command) => command.contains('--as=output'), - stdout: ''' -display_list_unittests -flow_unittests -fml_arc_unittests -''') + CannedProcess((List command) => command.contains('desc'), + stdout: fixtures.gnDescOutput()), ]; test('test command executes test', () async { diff --git a/engine/src/flutter/tools/engine_tool/test/utils.dart b/engine/src/flutter/tools/engine_tool/test/utils.dart index f1548ede24..6027e8674e 100644 --- a/engine/src/flutter/tools/engine_tool/test/utils.dart +++ b/engine/src/flutter/tools/engine_tool/test/utils.dart @@ -37,13 +37,14 @@ class CannedProcess { /// ExecutedProcess includes the command and the result. class ExecutedProcess { - ExecutedProcess(this.command, this.result); + ExecutedProcess(this.command, this.result, this.exitCode); final List command; final FakeProcess result; + final int exitCode; @override String toString() { - return command.join(' '); + return '${command.join(' ')} exitCode=$exitCode'; } } @@ -67,7 +68,9 @@ class TestEnvironment { processManager: FakeProcessManager(onStart: (List command) { final FakeProcess processResult = _getCannedResult(command, cannedProcesses); - processHistory.add(ExecutedProcess(command, processResult)); + processResult.exitCode.then((int exitCode) { + processHistory.add(ExecutedProcess(command, processResult, exitCode)); + }); return processResult; }, onRun: (List command) { throw UnimplementedError('onRun');