Skip to contentSkip to conversation

t0001: avoid pipes in test scripts

PATCH Superseded Srujith A Poojary via GitGitGadget 5 participants 13 messages Oct 18 – Oct 30

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 t0001: avoid pipes in test scripts

From: Srujith Poojary <[email protected]>

Avoid piping output from git version directly into sed to ensure

that any command failure is properly caught by test scripts.

---
[Outreachy PATCH] t0001: avoid pipes in test scripts

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2260%2Fpoojarysrujith%2Fmicroproject-init-pipe-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2260/poojarysrujith/microproject-init-pipe-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2260

 t/t0001-init.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/t0001-init.sh +1 -1
index f1d227f271..e835afee68 100755
@@ -678,7 +678,7 @@ test_expect_success 'default ref format' '
 		sane_unset GIT_DEFAULT_REF_STORAGE_FORMAT &&
 		git init refformat
 	) &&
-	git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
+	git version --build-options >build-options && sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
 	git -C refformat rev-parse --show-ref-storage-format >actual &&
 	test_cmp expect actual
 '

base-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd

Signature · 1 line
gitgitgadget
#1 lore raw

t/t0001-init.sh test_expect_success 'default ref format' ' · line 681

Quoted 10 lines
t/t0001-init.sh +1 -1
index f1d227f271..e835afee68 100755
@@ -678,7 +678,7 @@ test_expect_success 'default ref format' '
                sane_unset GIT_DEFAULT_REF_STORAGE_FORMAT &&
                git init refformat
        ) &&
-       git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
+       git version --build-options >build-options && sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&

We can put this in two lines, something like this:

git version --build-options >build-options && sed -ne "s/^default-ref-storage-format: //p"
build-options >expect &&

t/t0001-init.sh test_expect_success 'default ref format' ' · line 682

Quoted 1 line
t/t0001-init.sh +0 -0
        git -C refformat rev-parse --show-ref-storage-format >actual &&

Thanks for the patch.

#2 lore raw

PATCH v2 1/1 t0001: avoid pipes in test scripts

In reply to Srujith A Poojary via GitGitGadget

From: Srujith Poojary <[email protected]>

Avoid piping output from git version directly into sed to ensure

that any command failure is properly caught by test scripts.

---
[Outreachy PATCH] t0001: avoid pipes in test scripts

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2260%2Fpoojarysrujith%2Fmicroproject-init-pipe-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2260/poojarysrujith/microproject-init-pipe-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/2260

Range-diff vs v1:

1: 92ecaec2cd ! 1: 7d118290ce [Outreachy PATCH] t0001: avoid pipes in test scripts

     @@ t/t0001-init.sh: test_expect_success 'default ref format' '
       		git init refformat
       	) &&
      -	git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
     -+	git version --build-options >build-options && sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
     ++	git version --build-options >build-options &&
     ++		sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
       	git -C refformat rev-parse --show-ref-storage-format >actual &&
       	test_cmp expect actual
       '
 t/t0001-init.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
t/t0001-init.sh +2 -1
index f1d227f271..02217a9bf8 100755
@@ -678,7 +678,8 @@ test_expect_success 'default ref format' '
 		sane_unset GIT_DEFAULT_REF_STORAGE_FORMAT &&
 		git init refformat
 	) &&
-	git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
+	git version --build-options >build-options &&
+		sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
 	git -C refformat rev-parse --show-ref-storage-format >actual &&
 	test_cmp expect actual
 '

base-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd

Signature · 1 line
gitgitgadget
#3 lore raw

Hi Usman,

Thanks for the suggestion! I have updated the script to split the command into two separate lines as recommended and resolved a trailing whitespace issue.
I've submitted v2 of the patch to the mailing list via GitGitGadget.

Best regards,
Srujith

Quoted 51 lines · Srujith A Poojary via GitGitGadget

From: Srujith Poojary <[email protected]>

Avoid piping output from git version directly into sed to ensure

that any command failure is properly caught by test scripts.

---
[Outreachy PATCH] t0001: avoid pipes in test scripts

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2260%2Fpoojarysrujith%2Fmicroproject-init-pipe-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2260/poojarysrujith/microproject-init-pipe-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/2260

Range-diff vs v1:

1: 92ecaec2cd ! 1: 7d118290ce [Outreachy PATCH] t0001: avoid pipes in test scripts

     @@ t/t0001-init.sh: test_expect_success 'default ref format' '
                git init refformat
        ) &&
      - git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
     -+ git version --build-options >build-options && sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
     ++ git version --build-options >build-options &&
     ++         sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
        git -C refformat rev-parse --show-ref-storage-format >actual &&
        test_cmp expect actual
       '
 t/t0001-init.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
t/t0001-init.sh +2 -1
index f1d227f271..02217a9bf8 100755
@@ -678,7 +678,8 @@ test_expect_success 'default ref format' '
                sane_unset GIT_DEFAULT_REF_STORAGE_FORMAT &&
                git init refformat
        ) &&
-       git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
+       git version --build-options >build-options &&
+               sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
        git -C refformat rev-parse --show-ref-storage-format >actual &&
        test_cmp expect actual
 '

base-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd --
gitgitgadget

#4 lore raw
In reply to Srujith A Poojary via GitGitGadget

"Srujith A Poojary via GitGitGadget" <[email protected]>

Quoted 8 lines · writes:

From: Srujith Poojary <[email protected]>

Avoid piping output from git version directly into sed to ensure

that any command failure is properly caught by test scripts.

---

You do not want a blank line in the middle of a sentence.

t/t0001-init.sh test_expect_success 'default ref format' ' · line 682

Quoted 11 lines
t/t0001-init.sh +2 -1
index f1d227f271..02217a9bf8 100755
@@ -678,7 +678,8 @@ test_expect_success 'default ref format' '
 		sane_unset GIT_DEFAULT_REF_STORAGE_FORMAT &&
 		git init refformat
 	) &&
-	git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
+	git version --build-options >build-options &&
+		sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&

Unnecessary indentation. The only reason why you thought it was needed was because the original was (wrongly) expressed as a single pipeline. Once that glitch is gone, anybody reading the resulting code has no reason to think that this "sed" is associated stronger to the previous "git version" than with the next "git rev-parse" line.

Quoted 5 lines
t/t0001-init.sh +0 -0
 	git -C refformat rev-parse --show-ref-storage-format >actual &&
 	test_cmp expect actual
 '

base-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd

#5 lore raw

Hi Junio,

Thanks for pointing that out! I've removed the extra indentation in v3 so the sed line aligns properly with the surrounding commands.

Best,
Srujith

Quoted 39 lines · Junio C Hamano

"Srujith A Poojary via GitGitGadget" <[email protected]>

Quoted 8 lines · writes:

From: Srujith Poojary <[email protected]>

Avoid piping output from git version directly into sed to ensure

that any command failure is properly caught by test scripts.

---

You do not want a blank line in the middle of a sentence.

t/t0001-init.sh test_expect_success 'default ref format' ' · line 682

Quoted 11 lines
t/t0001-init.sh +2 -1
index f1d227f271..02217a9bf8 100755
@@ -678,7 +678,8 @@ test_expect_success 'default ref format' '
              sane_unset GIT_DEFAULT_REF_STORAGE_FORMAT &&
              git init refformat
      ) &&
-     git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
+     git version --build-options >build-options &&
+             sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&

Unnecessary indentation. The only reason why you thought it was needed was because the original was (wrongly) expressed as a single pipeline. Once that glitch is gone, anybody reading the resulting code has no reason to think that this "sed" is associated stronger to the previous "git version" than with the next "git rev-parse" line.

Quoted 5 lines
t/t0001-init.sh +0 -0
      git -C refformat rev-parse --show-ref-storage-format >actual &&
      test_cmp expect actual
 '

base-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd

#6 lore raw

PATCH v3 1/1 t0001: avoid pipes in test scripts

In reply to Srujith A Poojary via GitGitGadget

From: Srujith Poojary <[email protected]>

Avoid piping output from git version directly into sed to ensure

that any command failure is properly caught by test scripts.

---
[Outreachy PATCH] t0001: avoid pipes in test scripts

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2260%2Fpoojarysrujith%2Fmicroproject-init-pipe-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2260/poojarysrujith/microproject-init-pipe-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/2260

Range-diff vs v2:

1: 7d118290ce ! 1: a70ccdf49e [Outreachy PATCH] t0001: avoid pipes in test scripts

     @@ t/t0001-init.sh: test_expect_success 'default ref format' '
       	) &&
      -	git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
      +	git version --build-options >build-options &&
     -+		sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
     ++	sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
       	git -C refformat rev-parse --show-ref-storage-format >actual &&
       	test_cmp expect actual
       '
 t/t0001-init.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
t/t0001-init.sh +2 -1
index f1d227f271..c8c74f681b 100755
@@ -678,7 +678,8 @@ test_expect_success 'default ref format' '
 		sane_unset GIT_DEFAULT_REF_STORAGE_FORMAT &&
 		git init refformat
 	) &&
-	git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
+	git version --build-options >build-options &&
+	sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
 	git -C refformat rev-parse --show-ref-storage-format >actual &&
 	test_cmp expect actual
 '

base-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd

Signature · 1 line
gitgitgadget
#7 lore raw

Hi,

I have submitted v3 of the t0001 patch to the mailing list. Just a quick note on the CI: there is a single failure in win test (5), but it is caused by t1051-large-conversion running out of memory during a 5GB conversion test, which is unrelated to the t0001 changes.

The patch is ready for review.

Best regards,
Srujith

Quoted 50 lines · Srujith A Poojary via GitGitGadget

From: Srujith Poojary <[email protected]>

Avoid piping output from git version directly into sed to ensure

that any command failure is properly caught by test scripts.

---
[Outreachy PATCH] t0001: avoid pipes in test scripts

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2260%2Fpoojarysrujith%2Fmicroproject-init-pipe-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2260/poojarysrujith/microproject-init-pipe-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/2260

Range-diff vs v2:

1: 7d118290ce ! 1: a70ccdf49e [Outreachy PATCH] t0001: avoid pipes in test scripts

     @@ t/t0001-init.sh: test_expect_success 'default ref format' '
        ) &&
      - git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
      + git version --build-options >build-options &&
     -+         sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
     ++ sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
        git -C refformat rev-parse --show-ref-storage-format >actual &&
        test_cmp expect actual
       '
 t/t0001-init.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
t/t0001-init.sh +2 -1
index f1d227f271..c8c74f681b 100755
@@ -678,7 +678,8 @@ test_expect_success 'default ref format' '
                sane_unset GIT_DEFAULT_REF_STORAGE_FORMAT &&
                git init refformat
        ) &&
-       git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
+       git version --build-options >build-options &&
+       sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
        git -C refformat rev-parse --show-ref-storage-format >actual &&
        test_cmp expect actual
 '

base-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd --
gitgitgadget

#8 lore raw
In reply to Srujith A Poojary via GitGitGadget
Quoted 5 lines · Srujith A Poojary via GitGitGadget

From: Srujith Poojary <[email protected]>

Avoid piping output from git version directly into sed to ensure

that any command failure is properly caught by test scripts.

Formatting of your commit message is off a bit with an empty line in the middle of the sentence.

Quoted 5 lines
t/t0001-init.sh +0 -0
index f1d227f271..c8c74f681b 100755

t/t0001-init.sh test_expect_success 'default ref format' ' · line 685

Quoted 9 lines
t/t0001-init.sh +2 -1
@@ -678,7 +678,8 @@ test_expect_success 'default ref format' '
 		sane_unset GIT_DEFAULT_REF_STORAGE_FORMAT &&
 		git init refformat
 	) &&
-	git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
+	git version --build-options >build-options &&
+	sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
 	git -C refformat rev-parse --show-ref-storage-format >actual &&
 	test_cmp expect actual
 '

The changes look good to me though. Thanks!

Patrick

#9 lore raw
Quoted 28 lines · Patrick Steinhardt
Quoted 5 lines · Srujith A Poojary via GitGitGadget

From: Srujith Poojary <[email protected]>

Avoid piping output from git version directly into sed to ensure

that any command failure is properly caught by test scripts.

Formatting of your commit message is off a bit with an empty line in the middle of the sentence.

Quoted 5 lines
t/t0001-init.sh +0 -0
index f1d227f271..c8c74f681b 100755

t/t0001-init.sh test_expect_success 'default ref format' ' · line 685

Quoted 9 lines
t/t0001-init.sh +2 -1
@@ -678,7 +678,8 @@ test_expect_success 'default ref format' '
              sane_unset GIT_DEFAULT_REF_STORAGE_FORMAT &&
              git init refformat
      ) &&
-     git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
+     git version --build-options >build-options &&
+     sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
      git -C refformat rev-parse --show-ref-storage-format >actual &&
      test_cmp expect actual
 '

The changes look good to me though. Thanks!

Quoted 1 line

Patrick

Hi Patrick,

Thank you for reviewing! Good catch—I've removed the empty line in the commit message and submitted the updated version.

Best regards,
Srujith

#10 lore raw

PATCH v4 1/1 t0001: avoid pipes in test scripts

In reply to Srujith A Poojary via GitGitGadget

From: Srujith Poojary <[email protected]>

Avoid piping output from git version directly into sed to ensure that any command failure is properly caught by test scripts.

---
[Outreachy PATCH] t0001: avoid pipes in test scripts

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2260%2Fpoojarysrujith%2Fmicroproject-init-pipe-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2260/poojarysrujith/microproject-init-pipe-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/2260

Range-diff vs v3:

1: a70ccdf49e ! 1: 4373eef413 [Outreachy PATCH] t0001: avoid pipes in test scripts
@@ Commit message
[Outreachy PATCH] t0001: avoid pipes in test scripts

Avoid piping output from git version directly into sed to ensure
-
that any command failure is properly caught by test scripts.

 t/t0001-init.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
t/t0001-init.sh +2 -1
index f1d227f271..c8c74f681b 100755
@@ -678,7 +678,8 @@ test_expect_success 'default ref format' '
 		sane_unset GIT_DEFAULT_REF_STORAGE_FORMAT &&
 		git init refformat
 	) &&
-	git version --build-options | sed -ne "s/^default-ref-storage-format: //p" >expect &&
+	git version --build-options >build-options &&
+	sed -ne "s/^default-ref-storage-format: //p" build-options >expect &&
 	git -C refformat rev-parse --show-ref-storage-format >actual &&
 	test_cmp expect actual
 '

base-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd

Signature · 1 line
gitgitgadget
#11 lore raw
Quoted 11 lines · Srujith A Poojary via GitGitGadget

Range-diff vs v3:

1: a70ccdf49e ! 1: 4373eef413 [Outreachy PATCH] t0001: avoid pipes in test scripts
@@ Commit message
[Outreachy PATCH] t0001: avoid pipes in test scripts

Avoid piping output from git version directly into sed to ensure
-
that any command failure is properly caught by test scripts.

Thanks, this version looks good to me.

Patrick

#12 lore raw
Quoted 12 lines · Patrick Steinhardt
Quoted 10 lines · Srujith A Poojary via GitGitGadget

Range-diff vs v3:

1: a70ccdf49e ! 1: 4373eef413 [Outreachy PATCH] t0001: avoid pipes in test scripts
@@ Commit message
[Outreachy PATCH] t0001: avoid pipes in test scripts

Avoid piping output from git version directly into sed to ensure
-
that any command failure is properly caught by test scripts.

Quoted 5 lines
Quoted 1 line

Thanks, this version looks good to me.

Patrick

Hi Patrick,

Thank you for the review and guidance throughout this patch!

Best regards,
Srujith