[GSoC][RFC PATCH 2/2] t: add tests for refs list subcommand

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Test the implemented functionality of `git refs list` and verify
backward compatibility with `git show-ref` for the supported flags
and patterns.

Mentored-by: Patrick Steinhardt <ps@xxxxxx>
Mentored-by: shejialuo <shejialuo@xxxxxxxxx>
Mentored-by: Karthik Nayak <karthik.188@xxxxxxxxx>
Signed-off-by: Meet Soni <meetsoni3017@xxxxxxxxx>
---
 t/meson.build        |  1 +
 t/t1461-refs-list.sh | 95 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+)
 create mode 100755 t/t1461-refs-list.sh

diff --git a/t/meson.build b/t/meson.build
index d052fc3e23..c9d0863490 100644
--- a/t/meson.build
+++ b/t/meson.build
@@ -224,6 +224,7 @@ integration_tests = [
   't1450-fsck.sh',
   't1451-fsck-buffer.sh',
   't1460-refs-migrate.sh',
+  't1461-refs-list.sh',
   't1500-rev-parse.sh',
   't1501-work-tree.sh',
   't1502-rev-parse-parseopt.sh',
diff --git a/t/t1461-refs-list.sh b/t/t1461-refs-list.sh
new file mode 100755
index 0000000000..d628a193fc
--- /dev/null
+++ b/t/t1461-refs-list.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+test_description='Verify git refs list functionality and compatibility with git show-ref'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+test_expect_success setup '
+	test_commit --annotate A &&
+	git checkout -b side &&
+	test_commit --annotate B &&
+	git checkout main &&
+	test_commit C &&
+	git branch B A^0
+'
+
+test_expect_success 'refs list --branches, --tags, --head, pattern' '
+	for branch in B main side
+	do
+		echo $(git rev-parse refs/heads/$branch) refs/heads/$branch || return 1
+	done >expect.branches &&
+	git refs list --branches >actual &&
+	test_cmp expect.branches actual &&
+
+	for tag in A B C
+	do
+		echo $(git rev-parse refs/tags/$tag) refs/tags/$tag || return 1
+	done >expect.tags &&
+	git refs list --tags >actual &&
+	test_cmp expect.tags actual &&
+
+	cat expect.branches expect.tags >expect &&
+	git refs list --branches --tags >actual &&
+	test_cmp expect actual &&
+
+	{
+		echo $(git rev-parse HEAD) HEAD &&
+		cat expect.branches expect.tags
+	} >expect &&
+	git refs list --branches --tags --head >actual &&
+	test_cmp expect actual &&
+
+	{
+		echo $(git rev-parse HEAD) HEAD &&
+		echo $(git rev-parse refs/heads/B) refs/heads/B &&
+		echo $(git rev-parse refs/tags/B) refs/tags/B
+	} >expect &&
+	git refs list --head B >actual &&
+	test_cmp expect actual &&
+
+	{
+		echo $(git rev-parse refs/heads/B) refs/heads/B &&
+		echo $(git rev-parse refs/tags/A) refs/tags/A &&
+		echo $(git rev-parse refs/tags/B) refs/tags/B
+	} >expect &&
+	git refs list A B >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'Backward compatibility with show-ref' '
+	git show-ref >expect&&
+	git refs list >actual&&
+	test_cmp expect actual &&
+
+	git show-ref --branches >expect &&
+	git refs list --branches >actual &&
+	test_cmp expect actual &&
+
+	git show-ref --tags >expect &&
+	git refs list --tags >actual &&
+	test_cmp expect actual &&
+
+	git show-ref --head >expect &&
+	git refs list --head >actual &&
+	test_cmp expect actual &&
+
+	git show-ref --branches --tags --head >expect &&
+	git refs list --branches --tags --head >actual &&
+	test_cmp expect actual &&
+
+	git show-ref B >expect &&
+	git refs list B >actual &&
+	test_cmp expect actual &&
+
+	git show-ref --head B >expect &&
+	git refs list --head B >actual &&
+	test_cmp expect actual &&
+
+	git show-ref A B >expect &&
+	git refs list A B >actual &&
+	test_cmp expect actual
+'
+
+test_done
-- 
2.34.1





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux