git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: AbdAlRahman Gad <abdobngad@gmail.com>
To: git@vger.kernel.org
Cc: AbdAlRahman Gad <abdobngad@gmail.com>
Subject: [PATCH v3 4/6] [Newcomer] t7004-tag: do not prepare except outside test_expect_success
Date: Sun,  4 Aug 2024 10:11:35 +0300	[thread overview]
Message-ID: <20240804071137.30326-5-abdobngad@gmail.com> (raw)
In-Reply-To: <20240804071137.30326-1-abdobngad@gmail.com>

do not prepare expect outside test_expect_success

Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
---
 t/t7004-tag.sh | 224 +++++++++++++++++++++++++++----------------------
 1 file changed, 123 insertions(+), 101 deletions(-)

diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index cfe7653317..96aa908eaf 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -131,10 +131,10 @@ test_expect_success 'listing all tags if one exists should succeed' '
 	git tag
 '
 
-cat >expect <<EOF
-mytag
-EOF
 test_expect_success 'Multiple -l or --list options are equivalent to one -l option' '
+	cat >expect <<-\EOF &&
+	mytag
+	EOF
 	git tag -l -l >actual &&
 	test_cmp expect actual &&
 	git tag --list --list >actual &&
@@ -209,12 +209,12 @@ test_expect_success 'trying to delete an unknown tag should fail' '
 	test_must_fail git tag -d unknown-tag
 '
 
-cat >expect <<EOF
-myhead
-mytag
-EOF
 test_expect_success \
 	'trying to delete tags without params should succeed and do nothing' '
+	cat >expect <<-\EOF &&
+	myhead
+	mytag
+	EOF
 	git tag -l >actual &&
 	test_cmp expect actual &&
 	git tag -d &&
@@ -252,18 +252,18 @@ test_expect_success 'trying to delete an already deleted tag should fail' \
 
 # listing various tags with pattern matching:
 
-cat >expect <<EOF
-a1
-aa1
-cba
-t210
-t211
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-EOF
 test_expect_success 'listing all tags should print them ordered' '
+	cat >expect <<-\EOF &&
+	a1
+	aa1
+	cba
+	t210
+	t211
+	v0.2.1
+	v1.0
+	v1.0.1
+	v1.1.3
+	EOF
 	git tag v1.0.1 &&
 	git tag t211 &&
 	git tag aa1 &&
@@ -279,62 +279,62 @@ test_expect_success 'listing all tags should print them ordered' '
 	test_cmp expect actual
 '
 
-cat >expect <<EOF
-a1
-aa1
-cba
-EOF
 test_expect_success \
 	'listing tags with substring as pattern must print those matching' '
+	cat >expect <<-\EOF &&
+	a1
+	aa1
+	cba
+	EOF
 	rm *a* &&
 	git tag -l "*a*" >current &&
 	test_cmp expect current
 '
 
-cat >expect <<EOF
-v0.2.1
-v1.0.1
-EOF
 test_expect_success \
 	'listing tags with a suffix as pattern must print those matching' '
+	cat >expect <<-\EOF &&
+	v0.2.1
+	v1.0.1
+	EOF
 	git tag -l "*.1" >actual &&
 	test_cmp expect actual
 '
 
-cat >expect <<EOF
-t210
-t211
-EOF
 test_expect_success \
 	'listing tags with a prefix as pattern must print those matching' '
+	cat >expect <<-\EOF &&
+	t210
+	t211
+	EOF
 	git tag -l "t21*" >actual &&
 	test_cmp expect actual
 '
 
-cat >expect <<EOF
-a1
-EOF
 test_expect_success \
 	'listing tags using a name as pattern must print that one matching' '
+	cat >expect <<-\EOF &&
+	a1
+	EOF
 	git tag -l a1 >actual &&
 	test_cmp expect actual
 '
 
-cat >expect <<EOF
-v1.0
-EOF
 test_expect_success \
 	'listing tags using a name as pattern must print that one matching' '
+	cat >expect <<-\EOF &&
+	v1.0
+	EOF
 	git tag -l v1.0 >actual &&
 	test_cmp expect actual
 '
 
-cat >expect <<EOF
-v1.0.1
-v1.1.3
-EOF
 test_expect_success \
 	'listing tags with ? in the pattern should print those matching' '
+	cat >expect <<-\EOF &&
+	v1.0.1
+	v1.1.3
+	EOF
 	git tag -l "v1.?.?" >actual &&
 	test_cmp expect actual
 '
@@ -345,19 +345,25 @@ test_expect_success \
 	test_must_be_empty actual
 '
 
-cat >expect <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-EOF
 test_expect_success \
 	'listing tags using v* should print only those having v' '
+	cat >expect <<-\EOF &&
+	v0.2.1
+	v1.0
+	v1.0.1
+	v1.1.3
+	EOF
 	git tag -l "v*" >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'tag -l can accept multiple patterns' '
+	cat >expect <<-\EOF &&
+	v0.2.1
+	v1.0
+	v1.0.1
+	v1.1.3
+	EOF
 	git tag -l "v1*" "v0*" >actual &&
 	test_cmp expect actual
 '
@@ -371,6 +377,12 @@ test_expect_success 'tag -l can accept multiple patterns' '
 # out if we're going to break this long-documented form of taking
 # multiple patterns.
 test_expect_success 'tag -l <pattern> -l <pattern> works, as our buggy documentation previously suggested' '
+	cat >expect <<-\EOF &&
+	v0.2.1
+	v1.0
+	v1.0.1
+	v1.1.3
+	EOF
 	git tag -l "v1*" -l "v0*" >actual &&
 	test_cmp expect actual
 '
@@ -1683,23 +1695,21 @@ test_expect_success 'checking that first commit is in all tags (relative)' "
 	test_must_be_empty actual
 "
 
-cat >expected <<EOF
-v2.0
-EOF
-
 test_expect_success 'checking that second commit only has one tag' "
+	cat >expected <<-\EOF &&
+	v2.0
+	EOF
 	git tag -l --contains $hash2 v* >actual &&
 	test_cmp expected actual
 "
 
-cat >expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-EOF
-
 test_expect_success 'inverse of the last test, with --no-contains' "
+	cat >expected <<-\EOF &&
+	v0.2.1
+	v1.0
+	v1.0.1
+	v1.1.3
+	EOF
 	git tag -l --no-contains $hash2 v* >actual &&
 	test_cmp expected actual
 "
@@ -1709,15 +1719,14 @@ test_expect_success 'checking that third commit has no tags' "
 	test_must_be_empty actual
 "
 
-cat >expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-EOF
-
 test_expect_success 'conversely --no-contains on the third commit lists all tags' "
+	cat >expected <<-\EOF &&
+	v0.2.1
+	v1.0
+	v1.0.1
+	v1.1.3
+	v2.0
+	EOF
 	git tag -l --no-contains $hash3 v* >actual &&
 	test_cmp expected actual
 "
@@ -1734,24 +1743,22 @@ test_expect_success 'creating simple branch' '
 
 hash4=$(git rev-parse HEAD)
 
-cat >expected <<EOF
-v3.0
-EOF
-
 test_expect_success 'checking that branch head only has one tag' "
+	cat >expected <<-\EOF &&
+	v3.0
+	EOF
 	git tag -l --contains $hash4 v* >actual &&
 	test_cmp expected actual
 "
 
-cat >expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-EOF
-
 test_expect_success 'checking that branch head with --no-contains lists all but one tag' "
+	cat >expected <<-\EOF &&
+	v0.2.1
+	v1.0
+	v1.0.1
+	v1.1.3
+	v2.0
+	EOF
 	git tag -l --no-contains $hash4 v* >actual &&
 	test_cmp expected actual
 "
@@ -1761,50 +1768,65 @@ test_expect_success 'merging original branch into this branch' '
         git tag v4.0
 '
 
-cat >expected <<EOF
-v4.0
-EOF
-
 test_expect_success 'checking that original branch head has one tag now' "
+	cat >expected <<-\EOF &&
+	v4.0
+	EOF
 	git tag -l --contains $hash3 v* >actual &&
 	test_cmp expected actual
 "
 
-cat >expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-v3.0
-EOF
-
 test_expect_success 'checking that original branch head with --no-contains lists all but one tag now' "
+	cat >expected <<-\EOF &&
+	v0.2.1
+	v1.0
+	v1.0.1
+	v1.1.3
+	v2.0
+	v3.0
+	EOF
 	git tag -l --no-contains $hash3 v* >actual &&
 	test_cmp expected actual
 "
 
-cat >expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-v3.0
-v4.0
-EOF
-
 test_expect_success 'checking that initial commit is in all tags' "
+	cat >expected <<-\EOF &&
+	v0.2.1
+	v1.0
+	v1.0.1
+	v1.1.3
+	v2.0
+	v3.0
+	v4.0
+	EOF
 	git tag -l --contains $hash1 v* >actual &&
 	test_cmp expected actual
 "
 
 test_expect_success 'checking that --contains can be used in non-list mode' '
+	cat >expected <<-\EOF &&
+	v0.2.1
+	v1.0
+	v1.0.1
+	v1.1.3
+	v2.0
+	v3.0
+	v4.0
+	EOF
 	git tag --contains $hash1 v* >actual &&
 	test_cmp expected actual
 '
 
 test_expect_success 'checking that initial commit is in all tags with --no-contains' "
+	cat >expected <<-\EOF &&
+	v0.2.1
+	v1.0
+	v1.0.1
+	v1.1.3
+	v2.0
+	v3.0
+	v4.0
+	EOF
 	git tag -l --no-contains $hash1 v* >actual &&
 	test_must_be_empty actual
 "
-- 
2.43.0


  parent reply	other threads:[~2024-08-04  7:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-04  7:11 [PATCH v3 0/6] [Newcomer] t7004: modernize the style AbdAlRahman Gad
2024-08-04  7:11 ` [PATCH v3 1/6] [Newcomer] t7004-tag: redirection operator AbdAlRahman Gad
2024-08-05  9:36   ` Patrick Steinhardt
2024-08-04  7:11 ` [PATCH v3 2/6] [Newcomer] t7004-tag: do not lose exit status to pipe AbdAlRahman Gad
2024-08-05  9:36   ` Patrick Steinhardt
2024-08-04  7:11 ` [PATCH v3 3/6] [Newcomer] t7004-tag: one command per line AbdAlRahman Gad
2024-08-05  9:36   ` Patrick Steinhardt
2024-08-04  7:11 ` AbdAlRahman Gad [this message]
2024-08-04  7:32   ` [PATCH v3 4/6] [Newcomer] t7004-tag: do not prepare except outside test_expect_success Eric Sunshine
2024-08-04  9:01     ` AbdAlRahman Gad
2024-08-04 16:46   ` Junio C Hamano
2024-08-04  7:11 ` [PATCH v3 5/6] [Newcomer] t7004-tag: here-doc modernization AbdAlRahman Gad
2024-08-05  9:42   ` Patrick Steinhardt
2024-08-04  7:11 ` [PATCH v3 6/6] [Newcomer] t7004-tag: description on the same line as test_expect_success AbdAlRahman Gad
2024-08-05  9:42   ` Patrick Steinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240804071137.30326-5-abdobngad@gmail.com \
    --to=abdobngad@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).