diff mbox series

[2/3] t1509: make "setup" test more robust

Message ID 617f98dcb40d417fbb48d9c1de8fa9ab650f5370.1668999621.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit ce153b8d4d5be93d0960a143d08dcffd55694b0e
Headers show
Series fix t1509-root-work-tree failure | expand

Commit Message

Eric Sunshine Nov. 21, 2022, 3 a.m. UTC
From: Eric Sunshine <sunshine@sunshineco.com>

One of the t1509 setup tests is very particular about the output it
expects from `git init`, and fails if the output differs even slightly
which can happen easily if the script is run multiple times since it
doesn't do a good job of cleaning up after itself (i.e. it leaves
detritus in the root directory `/`). One bit of cruft in particular
(`/HEAD`) makes the test fail since its presence causes `git init` to
alter its output; rather than reporting "Initialized empty Git
repository", it instead reports "Reinitialized existing Git repository"
when `/HEAD` is present. Address this problem by making the test do a
more careful job of crafting its intended initial state.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 t/t1509-root-work-tree.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Johannes Schindelin Dec. 8, 2022, 11:49 a.m. UTC | #1
Hi Eric,

On Mon, 21 Nov 2022, Eric Sunshine via GitGitGadget wrote:

> From: Eric Sunshine <sunshine@sunshineco.com>
>
> One of the t1509 setup tests is very particular about the output it
> expects from `git init`, and fails if the output differs even slightly
> which can happen easily if the script is run multiple times since it
> doesn't do a good job of cleaning up after itself (i.e. it leaves
> detritus in the root directory `/`). One bit of cruft in particular
> (`/HEAD`) makes the test fail since its presence causes `git init` to
> alter its output; rather than reporting "Initialized empty Git
> repository", it instead reports "Reinitialized existing Git repository"
> when `/HEAD` is present. Address this problem by making the test do a
> more careful job of crafting its intended initial state.

Good explanation, and the patch is obviously correct.

ACK,
Johannes

>
> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> ---
>  t/t1509-root-work-tree.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t1509-root-work-tree.sh b/t/t1509-root-work-tree.sh
> index eb57fe7e19f..d0417626280 100755
> --- a/t/t1509-root-work-tree.sh
> +++ b/t/t1509-root-work-tree.sh
> @@ -243,7 +243,7 @@ say "auto bare gitdir"
>  # DESTROYYYYY!!!!!
>  test_expect_success 'setup' '
>  	rm -rf /refs /objects /info /hooks &&
> -	rm -f /expected /ls.expected /me /result &&
> +	rm -f /HEAD /expected /ls.expected /me /result &&
>  	cd / &&
>  	echo "Initialized empty Git repository in /" > expected &&
>  	git init --bare > result &&
> --
> gitgitgadget
>
>
diff mbox series

Patch

diff --git a/t/t1509-root-work-tree.sh b/t/t1509-root-work-tree.sh
index eb57fe7e19f..d0417626280 100755
--- a/t/t1509-root-work-tree.sh
+++ b/t/t1509-root-work-tree.sh
@@ -243,7 +243,7 @@  say "auto bare gitdir"
 # DESTROYYYYY!!!!!
 test_expect_success 'setup' '
 	rm -rf /refs /objects /info /hooks &&
-	rm -f /expected /ls.expected /me /result &&
+	rm -f /HEAD /expected /ls.expected /me /result &&
 	cd / &&
 	echo "Initialized empty Git repository in /" > expected &&
 	git init --bare > result &&