git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [GSoC][PATCH 0/4] t7401: modernize, cleanup and warn
@ 2020-07-26 14:25 Shourya Shukla
  2020-07-26 14:25 ` [PATCH 1/4] t7401: modernize style Shourya Shukla
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Shourya Shukla @ 2020-07-26 14:25 UTC (permalink / raw)
  To: git; +Cc: gitster, Johannes.Schindelin, peff, Shourya Shukla

Greetings,

The current phase of my GSoC project involves porting
'git submodule summary' from shell to C. While doing so, I, along with
my mentors Christian and Kaartic noticed some discrepancies in the test
script when trying to add a couple of tests to it. Though the test works
perfectly for my C port of 'summary', there were some unexpected behaviours
when trying to some tests to it. This patch series addresses these
issues in the test script by modernizing it, cleaning it up and warning
about some other issues.

Chiefly about patch 4/4 (t7401: add a WARNING and a NEEDSWORK),
when trying to write a test for verifying the summary output of
deinitialized submodule, doing a 'git submodule deinit <path>' did not
bear any fruit since the submodule never really got deinitialized. 
The deinit documentation states that:

	Unregister the given submodules, i.e. remove the whole
	submodule.$name section from .git/config together with
	their work tree.

Something which was not actually happening in the test. It appeared
that the reason for the deinit issue is that the test script uses
'git add' to add submodules instead of the command 'git submodule add'.

This behaviour also prompted the need to design a new test script to
have a testing of some niche cases such as those stated before, but
this is something that will be covered in the patch series responsible
for porting the 'summary' subcommand to C.

Comments and reviews are appreciated.

Thanks,
Shourya Shukla

Shourya Shukla (4):
  t7401: modernize style
  t7401: change test_i18ncmp syntax for clarity
  t7401: ensure uniformity in the '--for-status' test
  t7401: add a WARNING and a NEEDSWORK

 t/t7401-submodule-summary.sh | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] t7401: modernize style
  2020-07-26 14:25 [GSoC][PATCH 0/4] t7401: modernize, cleanup and warn Shourya Shukla
@ 2020-07-26 14:25 ` Shourya Shukla
  2020-07-26 14:25 ` [PATCH 2/4] t7401: change test_i18ncmp syntax for clarity Shourya Shukla
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Shourya Shukla @ 2020-07-26 14:25 UTC (permalink / raw)
  To: git
  Cc: gitster, Johannes.Schindelin, peff, Shourya Shukla,
	Christian Couder, Kaartic Sivaraam

The tests in 't7401-submodule-summary.sh' were written a long time ago
and have some violations with respect to our CodingGuidelines such as
incorrect spacing in usages of the redirection operator and absence
of line feed between statements in case of the '|' (pipe) operator.
Update it to match the CodingGuidelines.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com>
---
 t/t7401-submodule-summary.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
index 9bc841d085..4439fb7c17 100755
--- a/t/t7401-submodule-summary.sh
+++ b/t/t7401-submodule-summary.sh
@@ -16,12 +16,13 @@ add_file () {
 	owd=$(pwd)
 	cd "$sm"
 	for name; do
-		echo "$name" > "$name" &&
+		echo "$name" >"$name" &&
 		git add "$name" &&
 		test_tick &&
 		git commit -m "Add $name"
 	done >/dev/null
-	git rev-parse --verify HEAD | cut -c1-7
+	git rev-parse --verify HEAD |
+	cut -c1-7
 	cd "$owd"
 }
 commit_file () {
@@ -125,7 +126,8 @@ commit_file sm1 &&
 head3=$(
 	cd sm1 &&
 	git reset --hard HEAD~2 >/dev/null &&
-	git rev-parse --verify HEAD | cut -c1-7
+	git rev-parse --verify HEAD |
+	cut -c1-7
 )
 
 test_expect_success 'modified submodule(backward)' "
-- 
2.27.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/4] t7401: change test_i18ncmp syntax for clarity
  2020-07-26 14:25 [GSoC][PATCH 0/4] t7401: modernize, cleanup and warn Shourya Shukla
  2020-07-26 14:25 ` [PATCH 1/4] t7401: modernize style Shourya Shukla
@ 2020-07-26 14:25 ` Shourya Shukla
  2020-07-26 14:25 ` [PATCH 3/4] t7401: ensure uniformity in the '--for-status' test Shourya Shukla
  2020-07-26 14:25 ` [PATCH 4/4] t7401: add a WARNING and a NEEDSWORK Shourya Shukla
  3 siblings, 0 replies; 8+ messages in thread
From: Shourya Shukla @ 2020-07-26 14:25 UTC (permalink / raw)
  To: git
  Cc: gitster, Johannes.Schindelin, peff, Shourya Shukla,
	Christian Couder, Kaartic Sivaraam

Change the test_i18ncmp syntax from 'test_i18ncmp actual expected' to
'test_i18ncmp expected actual' to align it with the convention followed
by other tests in the test script.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com>
---
 t/t7401-submodule-summary.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
index 4439fb7c17..18fefdb0ba 100755
--- a/t/t7401-submodule-summary.sh
+++ b/t/t7401-submodule-summary.sh
@@ -183,7 +183,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --cached' "
   < Add foo5
 
 EOF
-	test_i18ncmp actual expected
+	test_i18ncmp expected actual
 "
 
 test_expect_success 'typechanged submodule(submodule->blob), --files' "
@@ -193,7 +193,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --files' "
   > Add foo5
 
 EOF
-	test_i18ncmp actual expected
+	test_i18ncmp expected actual
 "
 
 rm -rf sm1 &&
@@ -204,7 +204,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' "
 * sm1 $head4(submodule)->$head5(blob):
 
 EOF
-	test_i18ncmp actual expected
+	test_i18ncmp expected actual
 "
 
 rm -f sm1 &&
@@ -217,7 +217,7 @@ test_expect_success 'nonexistent commit' "
   Warn: sm1 doesn't contain commit $head4_full
 
 EOF
-	test_i18ncmp actual expected
+	test_i18ncmp expected actual
 "
 
 commit_file
-- 
2.27.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/4] t7401: ensure uniformity in the '--for-status' test
  2020-07-26 14:25 [GSoC][PATCH 0/4] t7401: modernize, cleanup and warn Shourya Shukla
  2020-07-26 14:25 ` [PATCH 1/4] t7401: modernize style Shourya Shukla
  2020-07-26 14:25 ` [PATCH 2/4] t7401: change test_i18ncmp syntax for clarity Shourya Shukla
@ 2020-07-26 14:25 ` Shourya Shukla
  2020-07-26 14:25 ` [PATCH 4/4] t7401: add a WARNING and a NEEDSWORK Shourya Shukla
  3 siblings, 0 replies; 8+ messages in thread
From: Shourya Shukla @ 2020-07-26 14:25 UTC (permalink / raw)
  To: git
  Cc: gitster, Johannes.Schindelin, peff, Shourya Shukla,
	Christian Couder, Kaartic Sivaraam

The '--for-status' test got its expected output from stdin. This is
inconsistent with the other tests in the test script which get their
expected output from a file named 'expected'.

So, change the syntax of the '--for-status' test for uniformity.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com>
---
 t/t7401-submodule-summary.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
index 18fefdb0ba..145914cd5a 100755
--- a/t/t7401-submodule-summary.sh
+++ b/t/t7401-submodule-summary.sh
@@ -285,13 +285,14 @@ EOF
 
 test_expect_success '--for-status' "
 	git submodule summary --for-status HEAD^ >actual &&
-	test_i18ncmp actual - <<EOF
+	cat >expected <<-EOF &&
 * sm1 $head6...0000000:
 
 * sm2 0000000...$head7 (2):
   > Add foo9
 
 EOF
+	test_i18ncmp expected actual
 "
 
 test_expect_success 'fail when using --files together with --cached' "
-- 
2.27.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/4] t7401: add a WARNING and a NEEDSWORK
  2020-07-26 14:25 [GSoC][PATCH 0/4] t7401: modernize, cleanup and warn Shourya Shukla
                   ` (2 preceding siblings ...)
  2020-07-26 14:25 ` [PATCH 3/4] t7401: ensure uniformity in the '--for-status' test Shourya Shukla
@ 2020-07-26 14:25 ` Shourya Shukla
  3 siblings, 0 replies; 8+ messages in thread
From: Shourya Shukla @ 2020-07-26 14:25 UTC (permalink / raw)
  To: git
  Cc: gitster, Johannes.Schindelin, peff, Shourya Shukla,
	Christian Couder, Kaartic Sivaraam

Add a WARNING regarding the usage of 'git add' instead of 'git
submodule add' to add submodules to the superproject. Also add a
NEEDSWORK regarding the outdated syntax and working of the test, which
may need to be improved to obtain better and desired results.

While at it, change the word 'test' to 'test script' in the test
description to avoid ambiguity.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com>
---
 t/t7401-submodule-summary.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
index 145914cd5a..2db4cf5cbf 100755
--- a/t/t7401-submodule-summary.sh
+++ b/t/t7401-submodule-summary.sh
@@ -5,8 +5,13 @@
 
 test_description='Summary support for submodules
 
-This test tries to verify the sanity of summary subcommand of git submodule.
+This test script tries to verify the sanity of summary subcommand of git submodule.
 '
+# WARNING: This test script uses 'git add' instead of 'git submodule add' to add
+# submodules to the superproject. Some submodule subcommands such as init and
+# deinit might not work as expected in this script.
+
+# NEEDSWORK: This test script is old fashioned and may need a big cleanup.
 
 . ./test-lib.sh
 
-- 
2.27.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] t7401: change test_i18ncmp syntax for clarity
  2020-08-05 17:49 ` [PATCH 2/4] t7401: change test_i18ncmp syntax for clarity Shourya Shukla
  2020-08-05 20:58   ` Taylor Blau
@ 2020-08-05 21:23   ` Junio C Hamano
  1 sibling, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2020-08-05 21:23 UTC (permalink / raw)
  To: Shourya Shukla
  Cc: git, christian.couder, kaartic.sivaraam, johannes.schindelin,
	liu.denton, Christian Couder

Shourya Shukla <shouryashukla.oo@gmail.com> writes:

> Change the test_i18ncmp syntax from 'test_i18ncmp actual expected' to
> 'test_i18ncmp expected actual' to align it with the convention followed
> by other tests in the test script.

Yeah, this is a good thing to do, as a failing test_cmp gives a diff
between the first file to the second file, i.e. a patch that turns
the expected output into what the tests actually produced, so that
the tester can see how the expectation is broken.
>
> Mentored-by: Christian Couder <chriscool@tuxfamily.org>
> Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
> Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com>
> ---
>  t/t7401-submodule-summary.sh | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
> index 4439fb7c17..18fefdb0ba 100755
> --- a/t/t7401-submodule-summary.sh
> +++ b/t/t7401-submodule-summary.sh
> @@ -183,7 +183,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --cached' "
>    < Add foo5
>  
>  EOF
> -	test_i18ncmp actual expected
> +	test_i18ncmp expected actual
>  "
>  
>  test_expect_success 'typechanged submodule(submodule->blob), --files' "
> @@ -193,7 +193,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --files' "
>    > Add foo5
>  
>  EOF
> -	test_i18ncmp actual expected
> +	test_i18ncmp expected actual
>  "
>  
>  rm -rf sm1 &&
> @@ -204,7 +204,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' "
>  * sm1 $head4(submodule)->$head5(blob):
>  
>  EOF
> -	test_i18ncmp actual expected
> +	test_i18ncmp expected actual
>  "
>  
>  rm -f sm1 &&
> @@ -217,7 +217,7 @@ test_expect_success 'nonexistent commit' "
>    Warn: sm1 doesn't contain commit $head4_full
>  
>  EOF
> -	test_i18ncmp actual expected
> +	test_i18ncmp expected actual
>  "
>  
>  commit_file

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] t7401: change test_i18ncmp syntax for clarity
  2020-08-05 17:49 ` [PATCH 2/4] t7401: change test_i18ncmp syntax for clarity Shourya Shukla
@ 2020-08-05 20:58   ` Taylor Blau
  2020-08-05 21:23   ` Junio C Hamano
  1 sibling, 0 replies; 8+ messages in thread
From: Taylor Blau @ 2020-08-05 20:58 UTC (permalink / raw)
  To: Shourya Shukla
  Cc: git, gitster, christian.couder, kaartic.sivaraam,
	johannes.schindelin, liu.denton, Christian Couder

On Wed, Aug 05, 2020 at 11:19:19PM +0530, Shourya Shukla wrote:
> Change the test_i18ncmp syntax from 'test_i18ncmp actual expected' to
> 'test_i18ncmp expected actual' to align it with the convention followed
> by other tests in the test script.
>
> Mentored-by: Christian Couder <chriscool@tuxfamily.org>
> Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
> Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com>
> ---
>  t/t7401-submodule-summary.sh | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
> index 4439fb7c17..18fefdb0ba 100755
> --- a/t/t7401-submodule-summary.sh
> +++ b/t/t7401-submodule-summary.sh
> @@ -183,7 +183,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --cached' "
>    < Add foo5
>
>  EOF
> -	test_i18ncmp actual expected
> +	test_i18ncmp expected actual
>  "
>
>  test_expect_success 'typechanged submodule(submodule->blob), --files' "
> @@ -193,7 +193,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --files' "
>    > Add foo5
>
>  EOF
> -	test_i18ncmp actual expected
> +	test_i18ncmp expected actual
>  "
>
>  rm -rf sm1 &&
> @@ -204,7 +204,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' "
>  * sm1 $head4(submodule)->$head5(blob):
>
>  EOF
> -	test_i18ncmp actual expected
> +	test_i18ncmp expected actual
>  "
>
>  rm -f sm1 &&
> @@ -217,7 +217,7 @@ test_expect_success 'nonexistent commit' "
>    Warn: sm1 doesn't contain commit $head4_full
>
>  EOF
> -	test_i18ncmp actual expected
> +	test_i18ncmp expected actual
>  "
>
>  commit_file
> --
> 2.27.0

This all looks good, and matches a long-standing convention of having
the expected value as the first argument and the comparison value as the
latter argument.

There's one spot you missed, which could be addressed by folding in this
diff on top:

--- >8 ---

Subject: [PATCH] fixup! t7401: change test_i18ncmp syntax for clarity

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 t/t7401-submodule-summary.sh | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
index 18fefdb0ba..bd8fc8511a 100755
--- a/t/t7401-submodule-summary.sh
+++ b/t/t7401-submodule-summary.sh
@@ -285,12 +285,14 @@ EOF

 test_expect_success '--for-status' "
 	git submodule summary --for-status HEAD^ >actual &&
-	test_i18ncmp actual - <<EOF
-* sm1 $head6...0000000:
+	cat >expected <<-\EOF &&
+	* sm1 $head6...0000000:

-* sm2 0000000...$head7 (2):
-  > Add foo9
+	* sm2 0000000...$head7 (2):
+	  > Add foo9

+	EOF
+	test_i18ncmp expected actual
 EOF
 "

--
2.28.0.rc1.13.ge78abce653

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/4] t7401: change test_i18ncmp syntax for clarity
  2020-08-05 17:49 [GSoC][RESEND][PATCH 0/4] t7401: modernize, cleanup and warn Shourya Shukla
@ 2020-08-05 17:49 ` Shourya Shukla
  2020-08-05 20:58   ` Taylor Blau
  2020-08-05 21:23   ` Junio C Hamano
  0 siblings, 2 replies; 8+ messages in thread
From: Shourya Shukla @ 2020-08-05 17:49 UTC (permalink / raw)
  To: git
  Cc: gitster, christian.couder, kaartic.sivaraam, johannes.schindelin,
	liu.denton, Shourya Shukla, Christian Couder

Change the test_i18ncmp syntax from 'test_i18ncmp actual expected' to
'test_i18ncmp expected actual' to align it with the convention followed
by other tests in the test script.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com>
---
 t/t7401-submodule-summary.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
index 4439fb7c17..18fefdb0ba 100755
--- a/t/t7401-submodule-summary.sh
+++ b/t/t7401-submodule-summary.sh
@@ -183,7 +183,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --cached' "
   < Add foo5
 
 EOF
-	test_i18ncmp actual expected
+	test_i18ncmp expected actual
 "
 
 test_expect_success 'typechanged submodule(submodule->blob), --files' "
@@ -193,7 +193,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --files' "
   > Add foo5
 
 EOF
-	test_i18ncmp actual expected
+	test_i18ncmp expected actual
 "
 
 rm -rf sm1 &&
@@ -204,7 +204,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' "
 * sm1 $head4(submodule)->$head5(blob):
 
 EOF
-	test_i18ncmp actual expected
+	test_i18ncmp expected actual
 "
 
 rm -f sm1 &&
@@ -217,7 +217,7 @@ test_expect_success 'nonexistent commit' "
   Warn: sm1 doesn't contain commit $head4_full
 
 EOF
-	test_i18ncmp actual expected
+	test_i18ncmp expected actual
 "
 
 commit_file
-- 
2.27.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-08-05 21:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-26 14:25 [GSoC][PATCH 0/4] t7401: modernize, cleanup and warn Shourya Shukla
2020-07-26 14:25 ` [PATCH 1/4] t7401: modernize style Shourya Shukla
2020-07-26 14:25 ` [PATCH 2/4] t7401: change test_i18ncmp syntax for clarity Shourya Shukla
2020-07-26 14:25 ` [PATCH 3/4] t7401: ensure uniformity in the '--for-status' test Shourya Shukla
2020-07-26 14:25 ` [PATCH 4/4] t7401: add a WARNING and a NEEDSWORK Shourya Shukla
2020-08-05 17:49 [GSoC][RESEND][PATCH 0/4] t7401: modernize, cleanup and warn Shourya Shukla
2020-08-05 17:49 ` [PATCH 2/4] t7401: change test_i18ncmp syntax for clarity Shourya Shukla
2020-08-05 20:58   ` Taylor Blau
2020-08-05 21:23   ` Junio C Hamano

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git