Skip to content

Commit 649fe10

Browse files
authored
[Linux] Make unit tests abort on critical errors, and fix two such errors (flutter#32348)
1 parent 884aa38 commit 649fe10

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎shell/platform/linux/fl_dart_project_test.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ TEST(FlDartProjectTest, DartEntrypointArgs) {
4444
char** retrieved_args =
4545
fl_dart_project_get_dart_entrypoint_arguments(project);
4646

47-
EXPECT_EQ(g_strv_length(retrieved_args), 0U);
47+
EXPECT_EQ(retrieved_args, nullptr);
4848

4949
GPtrArray* args_array = g_ptr_array_new();
5050
g_ptr_array_add(args_array, const_cast<char*>("arg_one"));

‎shell/platform/linux/fl_engine_test.cc‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ void on_pre_engine_restart_destroy_notify(gpointer user_data) {
240240

241241
// Checks restarting the engine invokes the correct callback.
242242
TEST(FlEngineTest, OnPreEngineRestart) {
243-
g_autoptr(FlEngine) engine = make_mock_engine();
243+
FlEngine* engine = make_mock_engine();
244244
FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
245245

246246
OnPreEngineRestartCallback callback;
@@ -271,7 +271,10 @@ TEST(FlEngineTest, OnPreEngineRestart) {
271271

272272
int count = 0;
273273

274-
// Set a handler, and the call should has an effect.
274+
// Set handler so that:
275+
//
276+
// * When the engine restarts, count += 1;
277+
// * When the engine is freed, count += 10.
275278
fl_engine_set_on_pre_engine_restart_handler(
276279
engine, on_pre_engine_restart_cb, &count,
277280
on_pre_engine_restart_destroy_notify);

‎shell/platform/linux/fl_key_embedder_responder.cc‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,9 @@ static void fl_key_embedder_responder_handle_event_impl(
766766
}
767767
}
768768

769-
update_pressing_state(self, physical_key, is_down_event ? logical_key : 0);
769+
if (out_event.type != kFlutterKeyEventTypeRepeat) {
770+
update_pressing_state(self, physical_key, is_down_event ? logical_key : 0);
771+
}
770772
possibly_update_lock_bit(self, logical_key, is_down_event);
771773
if (is_down_event) {
772774
update_mapping_record(self, physical_key, logical_key);

‎testing/run_tests.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def FindExecutablePath(path):
106106

107107

108108
def RunEngineExecutable(build_dir, executable_name, filter, flags=[],
109-
cwd=buildroot_dir, forbidden_output=[], expect_failure=False, coverage=False):
109+
cwd=buildroot_dir, forbidden_output=[], expect_failure=False, coverage=False,
110+
extra_env={}):
110111
if filter is not None and executable_name not in filter:
111112
print('Skipping %s due to filter.' % executable_name)
112113
return
@@ -138,6 +139,8 @@ def RunEngineExecutable(build_dir, executable_name, filter, flags=[],
138139
if not env:
139140
env = os.environ.copy()
140141
env['FLUTTER_BUILD_DIRECTORY'] = build_dir
142+
for key, value in extra_env.items():
143+
env[key] = value
141144

142145
try:
143146
RunCmd(test_command, cwd=cwd, forbidden_output=forbidden_output, expect_failure=expect_failure, env=env)
@@ -238,7 +241,9 @@ def RunCCTests(build_dir, filter, coverage, capture_core_dump):
238241
RunEngineExecutable(build_dir, 'txt_unittests', filter, icu_flags + shuffle_flags, coverage=coverage)
239242

240243
if IsLinux():
241-
RunEngineExecutable(build_dir, 'flutter_linux_unittests', filter, shuffle_flags, coverage=coverage)
244+
gtk_flags = ['--icu-data-file-path=%s' % os.path.join(build_dir, 'icudtl.dat')]
245+
RunEngineExecutable(build_dir, 'flutter_linux_unittests', filter, shuffle_flags, coverage=coverage,
246+
extra_env={'G_DEBUG': 'fatal-criticals'})
242247
RunEngineExecutable(build_dir, 'flutter_glfw_unittests', filter, shuffle_flags, coverage=coverage)
243248

244249
# Impeller tests are only supported on macOS for now.

0 commit comments

Comments
 (0)