git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] t3404: be resilient against running with the -x flag

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 10, 2016, 14:07 UTC
Message-ID
<alpine.DEB.2.20.1605101607180.4092@virtualbox>
In-Reply-To
<cover.1462888768.git.johannes.schindelin@gmx.de>

The -x flag (trace commands) is a priceless tool when hunting down bugs that trigger test failures. It is a worthless tool if the -x flag *itself* triggers test failures.

So let's change the offending tests so that they are a bit less stringent and do not stumble over the "+..." lines generated by the -x flag.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/t3404-rebase-interactive.sh | 67 ++++++++++---------------------------------
 1 file changed, 15 insertions(+), 52 deletions(-)
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 66348f1..25f1118 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -882,7 +882,8 @@ test_expect_success 'rebase -i --exec without <CMD>' '
 	git reset --hard execute &&
 	set_fake_editor &&
 	test_must_fail git rebase -i --exec 2>tmp &&
-	sed -e "1d" tmp >actual &&
+	sed -e "/option .exec. requires a value/d" -e '/^+/d' \
+		tmp >actual &&
 	test_must_fail git rebase -h >expected &&
 	test_cmp expected actual &&
 	git checkout master
@@ -1149,10 +1150,6 @@ test_expect_success 'drop' '
 	test A = $(git cat-file commit HEAD^^ | sed -ne \$p)
 '
 
-cat >expect <<EOF
-Successfully rebased and updated refs/heads/missing-commit.
-EOF
-
 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
 	test_config rebase.missingCommitsCheck ignore &&
 	rebase_setup_and_clean missing-commit &&
@@ -1160,52 +1157,33 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
 	FAKE_LINES="1 2 3 4" \
 		git rebase -i --root 2>actual &&
 	test D = $(git cat-file commit HEAD | sed -ne \$p) &&
-	test_cmp expect actual
+	test_i18ngrep \
+		"Successfully rebased and updated refs/heads/missing-commit." \
+		actual
 '
 
-cat >expect <<EOF
-Warning: some commits may have been dropped accidentally.
-Dropped commits (newer to older):
- - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
-To avoid this message, use "drop" to explicitly remove a commit.
-
-Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
-The possible behaviours are: ignore, warn, error.
-
-Successfully rebased and updated refs/heads/missing-commit.
-EOF
-
 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
+	line="$(git rev-list --pretty=oneline --abbrev-commit -1 master)" &&
 	test_config rebase.missingCommitsCheck warn &&
 	rebase_setup_and_clean missing-commit &&
 	set_fake_editor &&
 	FAKE_LINES="1 2 3 4" \
 		git rebase -i --root 2>actual &&
-	test_cmp expect actual &&
+	test_i18ngrep "Warning: some commits may have been dropped" actual &&
+	test_i18ngrep "^ - $line" actual &&
 	test D = $(git cat-file commit HEAD | sed -ne \$p)
 '
 
-cat >expect <<EOF
-Warning: some commits may have been dropped accidentally.
-Dropped commits (newer to older):
- - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
- - $(git rev-list --pretty=oneline --abbrev-commit -1 master~2)
-To avoid this message, use "drop" to explicitly remove a commit.
-
-Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
-The possible behaviours are: ignore, warn, error.
-
-You can fix this with 'git rebase --edit-todo'.
-Or you can abort the rebase with 'git rebase --abort'.
-EOF
-
 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
+	line1="$(git rev-list --pretty=oneline --abbrev-commit -1 master)" &&
+	line2="$(git rev-list --pretty=oneline --abbrev-commit -1 master~2)" &&
 	test_config rebase.missingCommitsCheck error &&
 	rebase_setup_and_clean missing-commit &&
 	set_fake_editor &&
 	test_must_fail env FAKE_LINES="1 2 4" \
 		git rebase -i --root 2>actual &&
-	test_cmp expect actual &&
+	test_i18ngrep "^ - $line1" actual &&
+	test_i18ngrep "^ - $line2" actual &&
 	cp .git/rebase-merge/git-rebase-todo.backup \
 		.git/rebase-merge/git-rebase-todo &&
 	FAKE_LINES="1 2 drop 3 4 drop 5" \
@@ -1215,20 +1193,13 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
 	test B = $(git cat-file commit HEAD^ | sed -ne \$p)
 '
 
-cat >expect <<EOF
-Warning: the command isn't recognized in the following line:
- - badcmd $(git rev-list --oneline -1 master~1)
-
-You can fix this with 'git rebase --edit-todo'.
-Or you can abort the rebase with 'git rebase --abort'.
-EOF
-
 test_expect_success 'static check of bad command' '
+	line=" - badcmd $(git rev-list --oneline -1 master~1)" &&
 	rebase_setup_and_clean bad-cmd &&
 	set_fake_editor &&
 	test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
 		git rebase -i --root 2>actual &&
-	test_cmp expect actual &&
+	test_i18ngrep "^$line" actual &&
 	FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo &&
 	git rebase --continue &&
 	test E = $(git cat-file commit HEAD | sed -ne \$p) &&
@@ -1250,20 +1221,12 @@ test_expect_success 'tabs and spaces are accepted in the todolist' '
 	test E = $(git cat-file commit HEAD | sed -ne \$p)
 '
 
-cat >expect <<EOF
-Warning: the SHA-1 is missing or isn't a commit in the following line:
- - edit XXXXXXX False commit
-
-You can fix this with 'git rebase --edit-todo'.
-Or you can abort the rebase with 'git rebase --abort'.
-EOF
-
 test_expect_success 'static check of bad SHA-1' '
 	rebase_setup_and_clean bad-sha &&
 	set_fake_editor &&
 	test_must_fail env FAKE_LINES="1 2 edit fakesha 3 4 5 #" \
 		git rebase -i --root 2>actual &&
-	test_cmp expect actual &&
+	test_i18ngrep "^ - edit XXXXXXX False commit" actual &&
 	FAKE_LINES="1 2 4 5 6" git rebase --edit-todo &&
 	git rebase --continue &&
 	test E = $(git cat-file commit HEAD | sed -ne \$p)
-- 
2.8.2.463.g99156ee
Previous: Johannes SchindelinNext: Junio C Hamano
Message 3 of 17 in “Work on t3404 in preparation for rebase--helper”
  1. 0/2 Work on t3404 in preparation for rebase--helperJohannes Schindelin, May 10, 2016
  2. 1/2 t3404: fix typoJohannes Schindelin, May 10, 2016
  3. 2/2 t3404: be resilient against running with the -x flagJohannes Schindelin, May 10, 2016
  4. Junio C HamanoMay 10, 2016
  5. Jeff KingMay 10, 2016
  6. Junio C HamanoMay 10, 2016
  7. test-lib: set BASH_XTRACEFD automaticallyJeff King, May 10, 2016
  8. Junio C HamanoMay 10, 2016
  9. test-lib: set BASH_XTRACEFD automaticallyJeff King, May 11, 2016
  10. Johannes SchindelinMay 12, 2016
  11. 0/2 Work on t3404 in preparation for rebase--helperJohannes Schindelin, May 12, 2016
  12. 1/2 t3404: fix typoJohannes Schindelin, May 12, 2016
  13. 2/2 test-lib: set BASH_XTRACEFD automaticallyJohannes Schindelin, May 12, 2016
  14. Junio C HamanoMay 12, 2016
  15. Johannes SchindelinMay 13, 2016
  16. Junio C HamanoMay 13, 2016
  17. Johannes SchindelinMay 16, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.