Skip to content

Commit

Permalink
[Linux] Make unit tests abort on critical errors, and fix two such er…
Browse files Browse the repository at this point in the history
…rors (flutter#32348)
  • Loading branch information
dkwingsmt authored Apr 28, 2022
1 parent 884aa38 commit 649fe10
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion shell/platform/linux/fl_dart_project_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TEST(FlDartProjectTest, DartEntrypointArgs) {
char** retrieved_args =
fl_dart_project_get_dart_entrypoint_arguments(project);

EXPECT_EQ(g_strv_length(retrieved_args), 0U);
EXPECT_EQ(retrieved_args, nullptr);

GPtrArray* args_array = g_ptr_array_new();
g_ptr_array_add(args_array, const_cast<char*>("arg_one"));
Expand Down
7 changes: 5 additions & 2 deletions shell/platform/linux/fl_engine_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void on_pre_engine_restart_destroy_notify(gpointer user_data) {

// Checks restarting the engine invokes the correct callback.
TEST(FlEngineTest, OnPreEngineRestart) {
g_autoptr(FlEngine) engine = make_mock_engine();
FlEngine* engine = make_mock_engine();
FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);

OnPreEngineRestartCallback callback;
Expand Down Expand Up @@ -271,7 +271,10 @@ TEST(FlEngineTest, OnPreEngineRestart) {

int count = 0;

// Set a handler, and the call should has an effect.
// Set handler so that:
//
// * When the engine restarts, count += 1;
// * When the engine is freed, count += 10.
fl_engine_set_on_pre_engine_restart_handler(
engine, on_pre_engine_restart_cb, &count,
on_pre_engine_restart_destroy_notify);
Expand Down
4 changes: 3 additions & 1 deletion shell/platform/linux/fl_key_embedder_responder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,9 @@ static void fl_key_embedder_responder_handle_event_impl(
}
}

update_pressing_state(self, physical_key, is_down_event ? logical_key : 0);
if (out_event.type != kFlutterKeyEventTypeRepeat) {
update_pressing_state(self, physical_key, is_down_event ? logical_key : 0);
}
possibly_update_lock_bit(self, logical_key, is_down_event);
if (is_down_event) {
update_mapping_record(self, physical_key, logical_key);
Expand Down
9 changes: 7 additions & 2 deletions testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def FindExecutablePath(path):


def RunEngineExecutable(build_dir, executable_name, filter, flags=[],
cwd=buildroot_dir, forbidden_output=[], expect_failure=False, coverage=False):
cwd=buildroot_dir, forbidden_output=[], expect_failure=False, coverage=False,
extra_env={}):
if filter is not None and executable_name not in filter:
print('Skipping %s due to filter.' % executable_name)
return
Expand Down Expand Up @@ -138,6 +139,8 @@ def RunEngineExecutable(build_dir, executable_name, filter, flags=[],
if not env:
env = os.environ.copy()
env['FLUTTER_BUILD_DIRECTORY'] = build_dir
for key, value in extra_env.items():
env[key] = value

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

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

# Impeller tests are only supported on macOS for now.
Expand Down

0 comments on commit 649fe10

Please sign in to comment.