Message ID | 20200805174921.16000-4-shouryashukla.oo@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | t7401: modernize, cleanup and warn | expand |
On Wed, Aug 05, 2020 at 11:19:20PM +0530, Shourya Shukla wrote: > 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. ... serves me right for not reading the whole thread before responding to the previous patch ;). On a technical note, I don't think this is different enough from the previous patch that they couldn't be combined. (A good indicator of this is that I expected this change to be included in 2/4 and was surprised that it was a separate step afterwords). > 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 > " I think that this is on the right track, but you can use a '<<-\EOF' here instead of '<<-EOF' to make the tabulation a little more flexible. > > test_expect_success 'fail when using --files together with --cached' " > -- > 2.27.0 Thanks, Taylor
Shourya Shukla <shouryashukla.oo@gmail.com> writes: > 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. There are a handful examples in t5401 and another one in t3700 that give the "golden master" from the standard input. When the expected output is used only once, I do not think it is particularlly bad to have it this way. So,... meh? Unless there is a compelling reason to insist both are files (that may make it easier to enhance test_cmp in a certain way you plan to, for example), that is. > 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' "
Taylor Blau <me@ttaylorr.com> writes: >> 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 >> " > > I think that this is on the right track, but you can use a '<<-\EOF' > here instead of '<<-EOF' to make the tabulation a little more flexible. You are correct that the patch could have indented the here-doc and the line with EOF with a tab to make it easier to read. The leading '-' after '<<' is what controls tabulation, so <<-EOF as written in the patch is good enough; you do not want to quote it further, because $head6 wants to be interpolated.
On Wed, Aug 05, 2020 at 03:25:17PM -0700, Junio C Hamano wrote: > Taylor Blau <me@ttaylorr.com> writes: > > >> 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 > >> " > > > > I think that this is on the right track, but you can use a '<<-\EOF' > > here instead of '<<-EOF' to make the tabulation a little more flexible. > > You are correct that the patch could have indented the here-doc and > the line with EOF with a tab to make it easier to read. > > The leading '-' after '<<' is what controls tabulation, so <<-EOF as > written in the patch is good enough; you do not want to quote it > further, because $head6 wants to be interpolated. Ah, I never actually knew the difference between those two (and apparently had been too lazy to look it up myself). Thanks for the clarification. Thanks, Taylor
On 05/08 02:30, Junio C Hamano wrote: > Shourya Shukla <shouryashukla.oo@gmail.com> writes: > > > 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. > > There are a handful examples in t5401 and another one in t3700 that > give the "golden master" from the standard input. When the expected > output is used only once, I do not think it is particularlly bad to > have it this way. So,... meh? I realised what you were trying to say after checking out t5400 and t3700. I understand that this change may not be immediately needed but I think it does make reading the diff a bit easier since having a '-' as a file name does get a bit confusing when reading the output. If a separeate commit just for this change is a problem then I can squash this with the previous commit? What do you think? > Unless there is a compelling reason to insist both are files > (that may make it easier to enhance test_cmp in a certain way > you plan to, for example), that is. > > > 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' "
Shourya Shukla <shouryashukla.oo@gmail.com> writes: > On 05/08 02:30, Junio C Hamano wrote: >> Shourya Shukla <shouryashukla.oo@gmail.com> writes: >> >> > 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. >> >> There are a handful examples in t5401 and another one in t3700 that >> give the "golden master" from the standard input. When the expected >> output is used only once, I do not think it is particularlly bad to >> have it this way. So,... meh? > > I realised what you were trying to say after checking out t5400 and > t3700. I understand that this change may not be immediately needed but I > think it does make reading the diff a bit easier since having a '-' as a > file name does get a bit confusing when reading the output. If so, perhaps justifying the change based on that, not on "consistency", would be a good idea. Side note: But would that mean you'd find it "confusing" to read output from 3700 and 5400? Would "test writers should get used to it" be a workable alternative solution? Since "test_cmp expect actual" and "test_cmp - actual <<HERE" are _both_ valid forms that are useful for different situations, I do not see a compelling reason to insist on one form is consistently used and ban the use of the other. So...
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' "
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(-)