[PATCH v10 04/12] merge-index tests: add usage tests

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

 



Add tests that stress the current behavior of the options parsing in
cmd_merge_index(), in preparation for moving it over to
parse_options().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 t/t6060-merge-index.sh | 44 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/t/t6060-merge-index.sh b/t/t6060-merge-index.sh
index 079151ee06d..edc03b41ab9 100755
--- a/t/t6060-merge-index.sh
+++ b/t/t6060-merge-index.sh
@@ -5,6 +5,50 @@ test_description='basic git merge-index / git-merge-one-file tests'
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
+test_expect_success 'usage: 1 argument' '
+	test_expect_code 129 git merge-index a >out 2>err &&
+	test_must_be_empty out &&
+	grep ^usage err
+'
+
+test_expect_success 'usage: 2 arguments' '
+	cat >expect <<-\EOF &&
+	fatal: git merge-index: b not in the cache
+	EOF
+	test_expect_code 128 git merge-index a b >out 2>actual &&
+	test_must_be_empty out &&
+	test_cmp expect actual
+'
+
+test_expect_success 'usage: -a before <program>' '
+	cat >expect <<-\EOF &&
+	fatal: git merge-index: b not in the cache
+	EOF
+	test_expect_code 128 git merge-index -a b program >out 2>actual &&
+	test_must_be_empty out &&
+	test_cmp expect actual
+'
+
+for opt in -q -o
+do
+	test_expect_success "usage: $opt after -a" '
+		cat >expect <<-EOF &&
+		fatal: git merge-index: unknown option $opt
+		EOF
+		test_expect_code 128 git merge-index -a $opt >out 2>actual &&
+		test_must_be_empty out &&
+		test_cmp expect actual
+	'
+
+	test_expect_success "usage: $opt program" '
+		test_expect_code 0 git merge-index $opt program
+	'
+done
+
+test_expect_success 'usage: program' '
+	test_expect_code 129 git merge-index program
+'
+
 test_expect_success 'setup diverging branches' '
 	test_write_lines 1 2 3 4 5 6 7 8 9 10 >file &&
 	cp file file2 &&
-- 
2.39.0.rc2.1048.g0e5493b8d5b




[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