diff mbox series

[03/10] tests: assume the hooks are disabled by default

Message ID patch-03.10-0519102edeb-20220302T131859Z-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series tests: add and use a "test_hook" wrapper + hook fixes | expand

Commit Message

Ævar Arnfjörð Bjarmason March 2, 2022, 1:22 p.m. UTC
Stop moving the .git/hooks directory out of the way, or creating it
during test setup. Instead assume that it will contain
harmless *.sample files.

That we can assume that is discussed in point #4 of
f0d4d398e28 (test-lib: split up and deprecate test_create_repo(),
2021-05-10).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t1416-ref-transaction-hooks.sh | 1 -
 t/t5516-fetch-push.sh            | 3 +--
 t/t7519-status-fsmonitor.sh      | 2 --
 3 files changed, 1 insertion(+), 5 deletions(-)

Comments

Junio C Hamano March 2, 2022, 9:13 p.m. UTC | #1
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Stop moving the .git/hooks directory out of the way, or creating it
> during test setup. Instead assume that it will contain
> harmless *.sample files.

Makes sense.  We ship sample files and no activated hooks in the
default install, and we do want to assume that in most of our tests
(except for ones that validate that asssumptions, of course).

> diff --git a/t/t1416-ref-transaction-hooks.sh b/t/t1416-ref-transaction-hooks.sh
> index 4e1e84a91f3..d21dd5e5df0 100755
> --- a/t/t1416-ref-transaction-hooks.sh
> +++ b/t/t1416-ref-transaction-hooks.sh
> @@ -8,7 +8,6 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
>  . ./test-lib.sh
>  
>  test_expect_success setup '
> -	mkdir -p .git/hooks &&

Interesting.  This becomes part of the tests that validate the
assumption that we do ship the hooks/ directory with sample files
;-)

>  	test_commit PRE &&
>  	PRE_OID=$(git rev-parse PRE) &&
>  	test_commit POST &&
> diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
> index 3137eb8d4d2..1a20e54adc1 100755
> --- a/t/t5516-fetch-push.sh
> +++ b/t/t5516-fetch-push.sh
> @@ -28,8 +28,7 @@ mk_empty () {
>  	(
>  		cd "$repo_name" &&
>  		git init &&
> -		git config receive.denyCurrentBranch warn &&
> -		mv .git/hooks .git/hooks-disabled
> +		git config receive.denyCurrentBranch warn
>  	)
>  }

Good.

> diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh
> index a6308acf006..63a0f609866 100755
> --- a/t/t7519-status-fsmonitor.sh
> +++ b/t/t7519-status-fsmonitor.sh
> @@ -56,7 +56,6 @@ test_lazy_prereq UNTRACKED_CACHE '
>  '
>  
>  test_expect_success 'setup' '
> -	mkdir -p .git/hooks &&
>  	: >tracked &&
>  	: >modified &&
>  	mkdir dir1 &&
> @@ -322,7 +321,6 @@ test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR'
>  	test_create_repo dot-git &&
>  	(
>  		cd dot-git &&
> -		mkdir -p .git/hooks &&
>  		: >tracked &&
>  		: >modified &&
>  		mkdir dir1 &&

Nice.  Presumably these should have been done when we stopped
mucking with hooks-disabled in test_create_repo helper but we
forgot to do so, and these are the only remaining bits?

Thanks for tying the loose ends.
diff mbox series

Patch

diff --git a/t/t1416-ref-transaction-hooks.sh b/t/t1416-ref-transaction-hooks.sh
index 4e1e84a91f3..d21dd5e5df0 100755
--- a/t/t1416-ref-transaction-hooks.sh
+++ b/t/t1416-ref-transaction-hooks.sh
@@ -8,7 +8,6 @@  export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 . ./test-lib.sh
 
 test_expect_success setup '
-	mkdir -p .git/hooks &&
 	test_commit PRE &&
 	PRE_OID=$(git rev-parse PRE) &&
 	test_commit POST &&
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 3137eb8d4d2..1a20e54adc1 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -28,8 +28,7 @@  mk_empty () {
 	(
 		cd "$repo_name" &&
 		git init &&
-		git config receive.denyCurrentBranch warn &&
-		mv .git/hooks .git/hooks-disabled
+		git config receive.denyCurrentBranch warn
 	)
 }
 
diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh
index a6308acf006..63a0f609866 100755
--- a/t/t7519-status-fsmonitor.sh
+++ b/t/t7519-status-fsmonitor.sh
@@ -56,7 +56,6 @@  test_lazy_prereq UNTRACKED_CACHE '
 '
 
 test_expect_success 'setup' '
-	mkdir -p .git/hooks &&
 	: >tracked &&
 	: >modified &&
 	mkdir dir1 &&
@@ -322,7 +321,6 @@  test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR'
 	test_create_repo dot-git &&
 	(
 		cd dot-git &&
-		mkdir -p .git/hooks &&
 		: >tracked &&
 		: >modified &&
 		mkdir dir1 &&