The helper function `set_fake_editor` installs a script as `GIT_EDITOR` that applies pre-defined editing rules to the files it is called with, which is a quite powerful tool when writing test cases for git-rebase--interactive. To aid in debugging the changes it makes, the installed script dumps the file contents to stdout before and after editing. That interferes with the output from git-rebase--interactive, however, and the debug information has to be removed from stdout in a error-prone way. Print the editor contents on stderr instead. When a test case wants to analyse stderr, we need to come up with a different solution. The less convenient possibility that always remains is to store the debug output in a file in the "trash" directory or even keeping copies of the edited files before and after editing. Signed-off-by: Fabian Ruch <bafain@xxxxxxxxx> --- t/lib-rebase.sh | 8 ++++---- t/t3404-rebase-interactive.sh | 18 ++++++------------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 6bd2522..0cd1193 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -41,8 +41,8 @@ set_fake_editor () { test -z "$FAKE_LINES" && exit grep -v '^#' < "$1" > "$1".tmp rm -f "$1" - echo 'rebase -i script before editing:' - cat "$1".tmp + echo 'rebase -i script before editing:' >&2 + cat "$1".tmp >&2 action=pick for line in $FAKE_LINES; do case $line in @@ -59,8 +59,8 @@ set_fake_editor () { action=pick;; esac done - echo 'rebase -i script after editing:' - cat "$1" + echo 'rebase -i script after editing:' >&2 + cat "$1" >&2 EOF test_set_editor "$(pwd)/fake-editor.sh" diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index f4e886f..7cc6ebf 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -882,9 +882,8 @@ test_expect_success 'running "git rebase -i --exec git show HEAD"' ' ( FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" && export FAKE_LINES && - git rebase -i HEAD~2 >expect + git rebase -i HEAD~2 >expected ) && - sed -e "1,9d" expect >expected && test_cmp expected actual ' @@ -896,9 +895,8 @@ test_expect_success 'running "git rebase --exec git show HEAD -i"' ' ( FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" && export FAKE_LINES && - git rebase -i HEAD~2 >expect + git rebase -i HEAD~2 >expected ) && - sed -e "1,9d" expect >expected && test_cmp expected actual ' @@ -910,9 +908,8 @@ test_expect_success 'running "git rebase -ix git show HEAD"' ' ( FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" && export FAKE_LINES && - git rebase -i HEAD~2 >expect + git rebase -i HEAD~2 >expected ) && - sed -e "1,9d" expect >expected && test_cmp expected actual ' @@ -924,9 +921,8 @@ test_expect_success 'rebase -ix with several <CMD>' ' ( FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd" && export FAKE_LINES && - git rebase -i HEAD~2 >expect + git rebase -i HEAD~2 >expected ) && - sed -e "1,9d" expect >expected && test_cmp expected actual ' @@ -939,9 +935,8 @@ test_expect_success 'rebase -ix with several instances of --exec' ' FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2 exec_git_show_HEAD exec_pwd" && export FAKE_LINES && - git rebase -i HEAD~2 >expect + git rebase -i HEAD~2 >expected ) && - sed -e "1,11d" expect >expected && test_cmp expected actual ' @@ -965,9 +960,8 @@ test_expect_success 'rebase -ix with --autosquash' ' git checkout -b autosquash_expected && FAKE_LINES="1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD" && export FAKE_LINES && - git rebase -i HEAD~4 >expect + git rebase -i HEAD~4 >expected ) && - sed -e "1,13d" expect >expected && test_cmp expected actual ' -- 2.0.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html