From fac253677604e5acc6a49b632355616b068d5a15 Mon Sep 17 00:00:00 2001 From: Sorah Fukumori Date: Wed, 27 Dec 2023 06:43:23 +0900 Subject: [PATCH] Test_SyncDefaultGems: Fail when editor run (#9365) When something went wrong and git launches editor, and a editor chosen was terminal-based, a test run unnoticeably hangs. As we intend editors not to be ran with --no-edit, GIT_EDITOR should be defaulted to `false` so let Git command fails when it attempts to start a editor. This allows catching such unintentional behaviour in test suite. (Note: Prior to Git v2.32.0, git cherry-pick --no-edit doesn't work for conflict resolution so currently the test hangs when older Git is in use. https://github.com/git/git/commit/39edfd5cbc4d168db19ec1bc867d78ec7211ec39 i.e. Ubuntu 20.04, Debian Bullseye doesn't satisfy this prerequisite.) --- tool/test/test_sync_default_gems.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tool/test/test_sync_default_gems.rb b/tool/test/test_sync_default_gems.rb index 3bf87b32580617..e64c6c6fda9e21 100755 --- a/tool/test/test_sync_default_gems.rb +++ b/tool/test/test_sync_default_gems.rb @@ -175,13 +175,13 @@ def assert_sync(commits = true, success: true, editor: nil) result = nil out = capture_process_output_to([STDOUT, STDERR]) do Dir.chdir("src") do - if editor - editor, ENV["GIT_EDITOR"] = ENV["GIT_EDITOR"], editor - edit = true - end + orig_editor = ENV["GIT_EDITOR"] + ENV["GIT_EDITOR"] = editor || 'false' + edit = true if editor + result = SyncDefaultGems.sync_default_gems_with_commits(@target, commits, edit: edit) ensure - ENV["GIT_EDITOR"] = editor if edit + ENV["GIT_EDITOR"] = orig_editor end end assert_equal(success, result, out)