Skip to content

Commit

Permalink
Test_SyncDefaultGems: Fail when editor run (#9365)
Browse files Browse the repository at this point in the history
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.
git/git@39edfd5
i.e. Ubuntu 20.04, Debian Bullseye doesn't satisfy this prerequisite.)
  • Loading branch information
sorah committed Dec 26, 2023
1 parent 17e1d8c commit fac2536
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tool/test/test_sync_default_gems.rb
Expand Up @@ -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)
Expand Down

0 comments on commit fac2536

Please sign in to comment.