threads / patch / 33228

patcht7811 (grep-open): remove test_config() redefinition

Subject: [PATCH] t7811 (grep-open): remove test_config() redefinition

## tl;dr

6 messages between Mar 19, 2013 and Mar 20, 2013. Diffs are folded; open one to read it.

replies: 5people: 3as markdown or json

Ramkumar Ramachandra· Mar 19, 2013, 10:43 UTC · lore

test_config() is already a well-defined function in test-lib-functions.sh. Don't duplicate it unnecessarily.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 Found this while randomly grep'ping around.
 t/t7811-grep-open.sh | 5 -----
 1 file changed, 5 deletions(-)
Show changes to t/t7811-grep-open.sh +0 −5
diff --git a/t/t7811-grep-open.sh b/t/t7811-grep-open.sh
index a895778..e1951a5 100755
--- a/t/t7811-grep-open.sh
+++ b/t/t7811-grep-open.sh
@@ -125,11 +125,6 @@ test_expect_success 'modified file' '
 	test_cmp empty out
 '
 
-test_config() {
-	git config "$1" "$2" &&
-	test_when_finished "git config --unset $1"
-}
-
 test_expect_success 'copes with color settings' '
 	rm -f actual &&
 	echo grep.h >expect &&
-- 
1.8.2
Junio C Hamano· Mar 19, 2013, 16:09 UTC · re: Ramkumar Ramachandra · lore

Re: [PATCH] t7811 (grep-open): remove test_config() redefinition

Ramkumar Ramachandra <artagnon@gmail.com> writes:
> test_config() is already a well-defined function in
> test-lib-functions.sh.  Don't duplicate it unnecessarily.

There are other instances of it in t7810 and t4018, with slightly different styles.

t/t4018-diff-funcname.sh:test_config () { t/t7810-grep.sh:test_config() { t/t7811-grep-open.sh:test_config() { t/test-lib-functions.sh:test_config () {

Incidentally, this is why a consistent coding style helps. It should be possible to catch all ofhtme with a single

	git grep 'test_config () {' t/
but the ones in t78xx wouldn't have been found.
Show 23 quoted lines
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  Found this while randomly grep'ping around.
>
>  t/t7811-grep-open.sh | 5 -----
>  1 file changed, 5 deletions(-)
>
> diff --git a/t/t7811-grep-open.sh b/t/t7811-grep-open.sh
> index a895778..e1951a5 100755
> --- a/t/t7811-grep-open.sh
> +++ b/t/t7811-grep-open.sh
> @@ -125,11 +125,6 @@ test_expect_success 'modified file' '
>  	test_cmp empty out
>  '
>  
> -test_config() {
> -	git config "$1" "$2" &&
> -	test_when_finished "git config --unset $1"
> -}
> -
>  test_expect_success 'copes with color settings' '
>  	rm -f actual &&
>  	echo grep.h >expect &&
Ramkumar Ramachandra· Mar 20, 2013, 08:21 UTC · re: Junio C Hamano · lore

[PATCH] t: don't redefine test_config() in various places

test_config() is already a well-defined function in test-lib-functions.sh. Don't duplicate it unnecessarily in:

  t4018-diff-funcname.sh
  t7810-grep.sh
  t7811-grep-open.sh
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 Thanks, Junio.
 t/t4018-diff-funcname.sh | 5 -----
 t/t7810-grep.sh          | 5 -----
 t/t7811-grep-open.sh     | 5 -----
 3 files changed, 15 deletions(-)
Show changes to 3 files +0 −15

t/t4018-diff-funcname.sh, t/t7810-grep.sh, t/t7811-grep-open.sh

diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 082d3e8..38a092a 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -93,11 +93,6 @@ sed -e '
 	s/song;/song();/
 ' <Beer.perl >Beer-correct.perl
 
-test_config () {
-	git config "$1" "$2" &&
-	test_when_finished "git config --unset $1"
-}
-
 test_expect_funcname () {
 	lang=${2-java}
 	test_expect_code 1 git diff --no-index -U1 \
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index f698001..500eb50 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -1084,11 +1084,6 @@ test_expect_success 'grep -E pattern with grep.patternType=fixed' '
 	test_cmp expected actual
 '
 
-test_config() {
-	git config "$1" "$2" &&
-	test_when_finished "git config --unset $1"
-}
-
 cat >expected <<EOF
 hello.c<RED>:<RESET>int main(int argc, const char **argv)
 hello.c<RED>-<RESET>{
diff --git a/t/t7811-grep-open.sh b/t/t7811-grep-open.sh
index a895778..e1951a5 100755
--- a/t/t7811-grep-open.sh
+++ b/t/t7811-grep-open.sh
@@ -125,11 +125,6 @@ test_expect_success 'modified file' '
 	test_cmp empty out
 '
 
-test_config() {
-	git config "$1" "$2" &&
-	test_when_finished "git config --unset $1"
-}
-
 test_expect_success 'copes with color settings' '
 	rm -f actual &&
 	echo grep.h >expect &&
-- 
1.8.2
Jonathan Nieder· Mar 20, 2013, 18:40 UTC · re: Ramkumar Ramachandra · lore

Re: [PATCH] t: don't redefine test_config() in various places

Ramkumar Ramachandra wrote:
Show 8 quoted lines
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  Thanks, Junio.
>
>  t/t4018-diff-funcname.sh | 5 -----
>  t/t7810-grep.sh          | 5 -----
>  t/t7811-grep-open.sh     | 5 -----
>  3 files changed, 15 deletions(-)
Yeah, that looks like all of them.  FWIW,
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Junio C Hamano· Mar 20, 2013, 18:51 UTC · re: Ramkumar Ramachandra · lore

Re: [PATCH] t: don't redefine test_config() in various places

Ramkumar Ramachandra <artagnon@gmail.com> writes:
Show 10 quoted lines
> test_config() is already a well-defined function in
> test-lib-functions.sh.  Don't duplicate it unnecessarily in:
>
>   t4018-diff-funcname.sh
>   t7810-grep.sh
>   t7811-grep-open.sh
>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  Thanks, Junio.

Heh, I've pushed out the original one after fixing them up myself last night.

Ramkumar Ramachandra· Mar 20, 2013, 19:59 UTC · re: Junio C Hamano · lore

Re: [PATCH] t: don't redefine test_config() in various places

Junio C Hamano wrote:
Show 15 quoted lines
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>
>> test_config() is already a well-defined function in
>> test-lib-functions.sh.  Don't duplicate it unnecessarily in:
>>
>>   t4018-diff-funcname.sh
>>   t7810-grep.sh
>>   t7811-grep-open.sh
>>
>> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
>> ---
>>  Thanks, Junio.
>
> Heh, I've pushed out the original one after fixing them up myself
> last night.
Doing a fine job as the editor, as always.  I need to watch `pu` more closely.

← back to recent threads