Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Add tests
  • Loading branch information
cbracken committed Apr 21, 2024
commit f58c789c4c9fdde7aa5610f89ba2d6b94e7a9404
24 changes: 14 additions & 10 deletions tools/engine_tool/test/build_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,11 @@ void main() {
'//flutter/fml:fml_arc_unittests',
]);
expect(result, equals(0));
expect(testEnv.processHistory.length, greaterThan(6));
expect(testEnv.processHistory[6].command[0], contains('ninja'));
expect(testEnv.processHistory[6].command[2], endsWith('/host_debug'));
expect(testEnv.processHistory.length, greaterThan(7));
expect(testEnv.processHistory[7].command[0], contains('ninja'));
expect(testEnv.processHistory[7].command[2], endsWith('/host_debug'));
expect(
testEnv.processHistory[6].command[5],
testEnv.processHistory[7].command[5],
equals('flutter/fml:fml_arc_unittests'),
);
} finally {
Expand All @@ -389,21 +389,25 @@ void main() {
'//flutter/...',
]);
expect(result, equals(0));
expect(testEnv.processHistory.length, greaterThan(6));
expect(testEnv.processHistory[6].command[0], contains('ninja'));
expect(testEnv.processHistory[6].command[2], endsWith('/host_debug'));
expect(testEnv.processHistory.length, greaterThan(7));
expect(testEnv.processHistory[7].command[0], contains('ninja'));
expect(testEnv.processHistory[7].command[2], endsWith('/host_debug'));
expect(
testEnv.processHistory[6].command[5],
testEnv.processHistory[7].command[5],
equals('flutter/display_list:display_list_unittests'),
);
expect(
testEnv.processHistory[6].command[6],
testEnv.processHistory[7].command[6],
equals('flutter/flow:flow_unittests'),
);
expect(
testEnv.processHistory[6].command[7],
testEnv.processHistory[7].command[7],
equals('flutter/fml:fml_arc_unittests'),
);
expect(
testEnv.processHistory[7].command[8],
equals('flutter/tools/engine_tool:build_command_test'),
);
} finally {
testEnv.cleanup();
}
Expand Down
17 changes: 16 additions & 1 deletion tools/engine_tool/test/fixtures.dart
Original file line number Diff line number Diff line change
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": [ "*" ]
}
}
''';
21 changes: 18 additions & 3 deletions tools/engine_tool/test/gn_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,18 @@ void main() {
final List<CannedProcess> cannedProcesses = <CannedProcess>[
CannedProcess((List<String> command) => command.contains('desc'),
stdout: fixtures.gnDescOutput()),
CannedProcess((List<String> command) => command.contains('outputs'),
CannedProcess((List<String> command) =>
command.contains('outputs') && command.contains('//flutter/display_list:display_list_unittests'),
stdout: 'display_list_unittests'),
CannedProcess((List<String> command) =>
command.contains('outputs') && command.contains('//flutter/flow:flow_unittests'),
stdout: 'flow_unittests'),
CannedProcess((List<String> command) =>
command.contains('outputs') && command.contains('//flutter/fml:fml_arc_unittests'),
stdout: 'fml_arc_unittests'),
CannedProcess((List<String> command) =>
command.contains('outputs') && command.contains('//flutter/tools/engine_tool:build_command_test'),
stdout: 'build_command_test'),
];

test('find test targets', () async {
Expand All @@ -49,14 +59,19 @@ void main() {
final Environment env = testEnvironment.environment;
final Map<String, BuildTarget> testTargets =
await findTargets(env, engine.outDir);
expect(testTargets.length, equals(3));
expect(testTargets.length, equals(4));
expect(testTargets['//flutter/display_list:display_list_unittests'],
notEquals(null));
expect(
testTargets['//flutter/display_list:display_list_unittests']!
.executable!
.path,
endsWith('display_list_unittests'));
expect(
testTargets['//flutter/tools/engine_tool:build_command_test']!
.executable!
.path,
endsWith('build_command_test'));
});

test('process queue failure', () async {
Expand All @@ -65,7 +80,7 @@ void main() {
final Environment env = testEnvironment.environment;
final Map<String, BuildTarget> testTargets =
await findTargets(env, engine.outDir);
expect(selectTargets(<String>['//...'], testTargets).length, equals(3));
expect(selectTargets(<String>['//...'], testTargets).length, equals(4));
expect(
selectTargets(<String>['//flutter/display_list'], testTargets).length,
equals(0));
Expand Down
2 changes: 1 addition & 1 deletion tools/engine_tool/test/query_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void main() {
expect(result, equals(0));
expect(
env.logger.testLogs.length,
equals(4),
equals(5),
);
expect(env.logger.testLogs[1].message,
startsWith('//flutter/display_list:display_list_unittests'));
Expand Down
32 changes: 29 additions & 3 deletions tools/engine_tool/test/test_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ void main() {
final List<CannedProcess> cannedProcesses = <CannedProcess>[
CannedProcess((List<String> command) => command.contains('desc'),
stdout: fixtures.gnDescOutput()),
CannedProcess((List<String> command) => command.contains('outputs'),
CannedProcess((List<String> command) => command.contains('outputs') && command.contains('//flutter/display_list:display_list_unittests'),
stdout: 'display_list_unittests'),
CannedProcess((List<String> command) => command.contains('outputs') && command.contains('//flutter/tools/engine_tool:build_command_test'),
stdout: 'build_command_test'),
];

test('test command executes test', () async {
test('test command executes executable test', () async {
final TestEnvironment testEnvironment = TestEnvironment.withTestEngine(
cannedProcesses: cannedProcesses,
);
Expand All @@ -70,6 +72,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_tool: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 All @@ -85,7 +111,7 @@ void main() {
'//third_party/protobuf:protoc',
]);
expect(result, equals(1));
expect(testEnvironment.processHistory.length, lessThan(6));
expect(testEnvironment.processHistory.length, lessThan(7));
expect(testEnvironment.processHistory.where((ExecutedProcess process) {
return process.command[0].contains('protoc');
}), isEmpty);
Expand Down