mbox series

[v5,0/3] t4113: modernize style

Message ID 20230209154417.10763-1-cheskaqiqi@gmail.com (mailing list archive)
Headers show
Series t4113: modernize style | expand

Message

Shuqi Liang Feb. 9, 2023, 3:44 p.m. UTC
different with V4: 
1.chain test assertions

For example:

-cat >test-patch <<\EOF
-diff --git a/file b/file

+ cat >test-patch <<-\EOF &&
+ diff --git a/file b/file


2.change the modern style with echo 
   echo x >file &&
        echo y >>file &&
        echo z >>file

  Change it to this stlye :
        {
        echo x &&
        echo y &&
        echo z
        } >file

3.In order to escape for executable lines inside the test_expect_success.
Change ' in executable lines to '\'' in order to escape.



(V4 didn't test before sumbit so I show the difference between orgin t4113 )

Shuqi Liang (3):
  t4113: modernize test script
  t4113: indent with tab
  t4113: put executable lines to test_expect_success

 t/t4113-apply-ending.sh | 81 ++++++++++++++++++++---------------------
 1 file changed, 40 insertions(+), 41 deletions(-)


base-commit: c48035d29b4e524aed3a32f0403676f0d9128863

Comments

Shuqi Liang Feb. 15, 2023, 2:39 a.m. UTC | #1
different with 5 :

1.change the commit message to be more succinct.

2.
use  

test_write_lines a b c >file && 

instead of :
 
{
    echo a &&
    echo b &&
    echo c
} >file &&




Shuqi Liang (3):
  t4113: modernize test script
  t4113: indent with tab
  t4113: put executable lines to test_expect_success

 t/t4113-apply-ending.sh | 75 +++++++++++++++++++----------------------
 1 file changed, 34 insertions(+), 41 deletions(-)

Range-diff against v5:
1:  4d55e522a6 ! 1:  cb29da5d42 t4113: modernize test script
    @@ Commit message
         where the test_expect_success command and test title are written on
         separate lines. Change the old style to modern style.
     
    -    for example :
    -    -test_expect_success setup \
    -    -    'git update-index --add file'
    -    -
    -    +test_expect_success setup '
    -    +    git update-index --add file
    -    +'
    -
         Signed-off-by: Shuqi Liang <cheskaqiqi@gmail.com>
     
      ## t/t4113-apply-ending.sh ##
2:  cb997bc422 = 2:  09efa23ba4 t4113: indent with tab
3:  726d2fcb47 ! 3:  0169cbd402 t4113: put executable lines to test_expect_success
    @@ Commit message
         t4113: put executable lines to test_expect_success
     
         As t/README says, put all code inside test_expect_success and
    -    other assertions. This script is written in old style,where there are
    -    some executable lines outside test_expect_success. Put the executable
    -    lines inside the test_expect_success.
    -
    -    As t/README says,use "<<-" instead of "<<"
    -    to strip leading TABs used for indentation. Change the "<<" to "<<-"
    -
    -    for example:
    -    -cat >test-patch <<\EOF
    -    -diff a/file b/file
    -
    -     test_expect_success 'apply at the beginning' '
    -    +       cat >test-patch <<-\EOF
    -    +       diff a/file b/file
    -    +       --- a/file
    -
    -    As t/README says,chain test assertions.Chain this test assertions
    -    with &&.
    -
    -    For example:
    -
    -    -cat >test-patch <<\EOF
    -    -diff --git a/file b/file
    -
    -    + cat >test-patch <<-\EOF &&
    -    + diff --git a/file b/file
    -
    -    This script is written in old style,where there are something like
    -
    -            echo x >file &&
    -            echo y >>file &&
    -            echo z >>file
    -
    -      Change it to this stlye :
    -            {
    -            echo x &&
    -            echo y &&
    -            echo z
    -            } >file
    -
    -    In order to escape for executable lines inside the test_expect_success.
    -    Change ' in executable lines to '\'' in order to escape.
    +    other assertions. This old test scripts have setup code
    +    outside of tests. This is problematic since any failures of the
    +    setup code will go unnoticed. Therefore, move setup code into the tests
    +    themselves so that failures are properly flagged. t/README also says,
    +    use "<<-" instead of "<<" to strip leading TABs used for indentation.
    +    Fix it. We should chain test assertions(t/README). Therefore,Chain
    +    this test assertions with &&. What's more,take advantage of modern
    +    style. Use test_write_lines instead.
     
         Signed-off-by: Shuqi Liang <cheskaqiqi@gmail.com>
     
    @@ -1,2 +1,3 @@
     +	+c
     +	EOF
     +
    -+	{
    -+	echo '\''a'\'' &&
    -+	echo '\''b'\'' &&
    -+	echo '\''c'\''
    -+	} >file &&
    ++	test_write_lines a b c >file &&
      	git update-index --add file
      '
     -# test
    @@ -1,2 +1,3 @@
     +	 c
     +	EOF
     +
    -+	echo >file '\''a
    -+	b
    -+	c'\'' &&
    ++	test_write_lines a b c >file &&
     +	git update-index file &&
      	test_must_fail git apply --index test-patch
      '