Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cbracken committed Apr 20, 2024
1 parent c95c55b commit 449045c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tools/engine_tool/test/build_command_test.dart
Expand Up @@ -403,12 +403,13 @@ void main() {
]);
expect(result, equals(0));
expect(testEnv.processHistory, containsCommand((List<String> command) {
return command.length > 7 &&
return command.length > 8 &&
command[0].contains('ninja') &&
command[2].endsWith('/host_debug') &&
command[5] == 'flutter/display_list:display_list_unittests' &&
command[6] == 'flutter/flow:flow_unittests' &&
command[7] == 'flutter/fml:fml_arc_unittests';
command[7] == 'flutter/fml:fml_arc_unittests' &&
command[8] == 'flutter/tools/engine_tool:build_command_test';
}));
} finally {
testEnv.cleanup();
Expand Down
17 changes: 16 additions & 1 deletion tools/engine_tool/test/fixtures.dart
Expand Up @@ -316,6 +316,21 @@ String gnDescOutput() => '''
"toolchain": "//build/toolchain/mac:clang_x64",
"type": "executable",
"visibility": [ "*" ]
}
},
"//flutter/tools/engine_tool:build_command_test": {
"args": [ "../../flutter/prebuilts/macos-x64/dart-sdk/bin/dart", "--deterministic", "compile", "exe", "--packages=/Users/chris/Developer/flutter/engine/src/flutter/tools/engine_tool/.dart_tool/package_config.json", "--output=/Users/chris/Developer/flutter/engine/src/out/host_debug/gen/flutter/tools/engine_tool/build_command_test", "/Users/chris/Developer/flutter/engine/src/flutter/tools/engine_tool/test/build_command_test.dart" ],
"deps": [ ],
"inputs": [ "//flutter/tools/engine_tool/test/build_command_test.dart", "//flutter/tools/engine_tool/.dart_tool/package_config.json" ],
"metadata": {
"action_type": [ "dart_executable" ]
},
"outputs": [ "//out/host_debug/gen/flutter/tools/engine_tool/build_command_test" ],
"public": "*",
"script": "//build/gn_run_binary.py",
"testonly": true,
"toolchain": "//build/toolchain/mac:clang_x64",
"type": "action",
"visibility": [ "*" ]
}
}
''';
36 changes: 35 additions & 1 deletion tools/engine_tool/test/test_command_test.dart
Expand Up @@ -42,9 +42,19 @@ void main() {
final List<CannedProcess> cannedProcesses = <CannedProcess>[
CannedProcess((List<String> command) => command.contains('desc'),
stdout: fixtures.gnDescOutput()),
CannedProcess(
(List<String> command) =>
command.contains('outputs') &&
command.contains("display_list_unittests"),
stdout: fixtures.gnOutputsDisplayListUnittestsOutput()),
CannedProcess(
(List<String> command) =>
command.contains('outputs') &&
command.contains("build_command_test"),
stdout: fixtures.gnOutputsBuildCommandTestOutput()),
];

test('test command executes test', () async {
test('test command executes executable test', () async {
final TestEnvironment testEnvironment = TestEnvironment.withTestEngine(
cannedProcesses: cannedProcesses,
);
Expand All @@ -68,6 +78,30 @@ void main() {
}
});

test('test command executes dart_executable test', () async {
final TestEnvironment testEnvironment = TestEnvironment.withTestEngine(
cannedProcesses: cannedProcesses,
);
try {
final Environment env = testEnvironment.environment;
final ToolCommandRunner runner = ToolCommandRunner(
environment: env,
configs: configs,
);
final int result = await runner.run(<String>[
'test',
'//flutter/tools/engine_test:build_command_test',
]);
expect(result, equals(0));
expect(testEnvironment.processHistory.length, greaterThan(3));
final int offset = testEnvironment.processHistory.length - 1;
expect(testEnvironment.processHistory[offset].command[0],
endsWith('build_command_test'));
} finally {
testEnvironment.cleanup();
}
});

test('test command skips non-testonly executables', () async {
final TestEnvironment testEnvironment = TestEnvironment.withTestEngine(
cannedProcesses: cannedProcesses,
Expand Down

0 comments on commit 449045c

Please sign in to comment.