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

[PATCH 1/6] t7502: clean up fake_editor tests

From
Jeff King <peff@peff.net>
Date
Jul 26, 2012, 20:27 UTC
Message-ID
<20120726202754.GA16048@sigill.intra.peff.net>
In-Reply-To
<20120726202644.GA15043@sigill.intra.peff.net>

Using write_script saves us a few lines of code, and means we consistently use $SHELL_PATH.

We can also drop the setting of the $pwd variable from $(pwd). In the first instance, there is no reason to use it (we can just use $(pwd) directly two lines later, since we are interpolating the here-document). In the second instance, it is totally pointless and probably just a cut-and-paste from the first instance.

Finally, we can use a non-interpolating here document for the final script, which saves some quoting.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t7502-commit.sh | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 181456a..ddce53a 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -266,13 +266,10 @@ test_expect_success 'committer is automatic' '
 	test_i18ncmp expect actual
 '
 
-pwd=`pwd`
-cat >> .git/FAKE_EDITOR << EOF
-#! /bin/sh
-echo editor started > "$pwd/.git/result"
+write_script .git/FAKE_EDITOR <<EOF
+echo editor started > "$(pwd)/.git/result"
 exit 0
 EOF
-chmod +x .git/FAKE_EDITOR
 
 test_expect_success 'do not fire editor in the presence of conflicts' '
 
@@ -300,9 +297,7 @@ test_expect_success 'do not fire editor in the presence of conflicts' '
 	test "$(cat .git/result)" = "editor not started"
 '
 
-pwd=`pwd`
-cat >.git/FAKE_EDITOR <<EOF
-#! $SHELL_PATH
+write_script .git/FAKE_EDITOR <<EOF
 # kill -TERM command added below.
 EOF
 
@@ -339,13 +334,12 @@ test_expect_success 'A single-liner subject with a token plus colon is not a foo
 
 '
 
-cat >.git/FAKE_EDITOR <<EOF
-#!$SHELL_PATH
-mv "\$1" "\$1.orig"
+write_script .git/FAKE_EDITOR <<\EOF
+mv "$1" "$1.orig"
 (
 	echo message
-	cat "\$1.orig"
-) >"\$1"
+	cat "$1.orig"
+) >"$1"
 EOF
 
 echo '## Custom template' >template
-- 
1.7.11.3.8.ge78f547
Previous: Jeff KingNext: Jeff King
Message 9 of 15 in “Test "t/t7502-commit.sh" failed”
  1. Jiang XinJul 26, 2012
  2. Jeff KingJul 26, 2012
  3. Junio C HamanoJul 26, 2012
  4. Jeff KingJul 26, 2012
  5. Junio C HamanoJul 26, 2012
  6. Jeff KingJul 26, 2012
  7. Junio C HamanoJul 26, 2012
  8. 0/6 t7502 fixesJeff King, Jul 26, 2012
  9. 1/6 t7502: clean up fake_editor testsJeff King, Jul 26, 2012
  10. 2/6 t7502: properly quote GIT_EDITORJeff King, Jul 26, 2012
  11. 3/6 t7502: narrow checks for author/committer name in templateJeff King, Jul 26, 2012
  12. 4/6 t7502: drop confusing test_might_fail callJeff King, Jul 26, 2012
  13. 5/6 t7502: handle systems where auto-identity is brokenJeff King, Jul 26, 2012
  14. 6/6 t7502: test early quit from commit with bad identJeff King, Jul 26, 2012
  15. Junio C HamanoJul 26, 2012

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.