"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Tracey Emery <tracey@traceyemery.net>
Subject:
New and fixed tests
To:
gameoftrees@openbsd.org
Date:
Tue, 14 Sep 2021 09:10:52 -0600

Download raw body.

Thread
Hello,

This adds tests for the new update -q, checkout -q, and status -S
options. Also, there are fixes for the new output of checkout.

Everything look ok?

-- 

Tracey Emery

diff 00357e4dc78f7f5bd12eceaa07592ab743996e12 /home/tracey/src/got
blob - b6c5784556b7f6d287d651006dc0ccee50de3901
file + regress/cmdline/checkout.sh
--- regress/cmdline/checkout.sh
+++ regress/cmdline/checkout.sh
@@ -23,7 +23,9 @@ test_checkout_basic() {
 	echo "A  $testroot/wt/beta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/gamma/delta" >> $testroot/stdout.expected
-	echo "Now shut up and hack" >> $testroot/stdout.expected
+	echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
 
 	got checkout $testroot/repo $testroot/wt > $testroot/stdout
 	ret="$?"
@@ -62,7 +64,9 @@ test_checkout_dir_exists() {
 	echo "A  $testroot/wt/beta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/gamma/delta" >> $testroot/stdout.expected
-	echo "Now shut up and hack" >> $testroot/stdout.expected
+	echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
 
 	mkdir $testroot/wt
 
@@ -103,7 +107,9 @@ test_checkout_dir_not_empty() {
 	echo "A  $testroot/wt/beta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/gamma/delta" >> $testroot/stdout.expected
-	echo "Now shut up and hack" >> $testroot/stdout.expected
+	echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
 
 	mkdir $testroot/wt
 	touch $testroot/wt/foo
@@ -146,7 +152,9 @@ test_checkout_sets_xbit() {
 	git_commit $testroot/repo -m "adding executable file"
 
 	echo "A  $testroot/wt/xfile" > $testroot/stdout.expected
-	echo "Now shut up and hack" >> $testroot/stdout.expected
+	echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
 
 	got checkout $testroot/repo $testroot/wt > $testroot/stdout
 	ret="$?"
@@ -226,7 +234,9 @@ test_checkout_tag() {
 	echo "A  $testroot/wt/beta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/gamma/delta" >> $testroot/stdout.expected
-	echo "Now shut up and hack" >> $testroot/stdout.expected
+	echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
 
 	got checkout -c $tag $testroot/repo $testroot/wt > $testroot/stdout
 	ret="$?"
@@ -271,7 +281,9 @@ test_checkout_ignores_submodules() {
 	echo "A  $testroot/wt/beta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/gamma/delta" >> $testroot/stdout.expected
-	echo "Now shut up and hack" >> $testroot/stdout.expected
+	echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
 
 	got checkout $testroot/repo $testroot/wt > $testroot/stdout
 	ret="$?"
@@ -313,7 +325,9 @@ test_checkout_read_only() {
 	echo "A  $testroot/wt/beta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/gamma/delta" >> $testroot/stdout.expected
-	echo "Now shut up and hack" >> $testroot/stdout.expected
+	echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
 
 	got checkout $testroot/repo $testroot/wt \
 		> $testroot/stdout 2> $testroot/stderr
@@ -402,7 +416,9 @@ test_checkout_into_nonempty_dir() {
 	echo "?  $testroot/wt/beta" >> $testroot/stdout.expected
 	echo "?  $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
 	echo "?  $testroot/wt/gamma/delta" >> $testroot/stdout.expected
-	echo "Now shut up and hack" >> $testroot/stdout.expected
+	echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
 
 	got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
 	ret="$?"
@@ -423,7 +439,9 @@ test_checkout_into_nonempty_dir() {
 	echo "E  $testroot/wt/beta" >> $testroot/stdout.expected
 	echo "E  $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
 	echo "E  $testroot/wt/gamma/delta" >> $testroot/stdout.expected
-	echo "Now shut up and hack" >> $testroot/stdout.expected
+	echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
 
 	got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
 	ret="$?"
@@ -461,7 +479,9 @@ test_checkout_into_nonempty_dir() {
 	echo "E  $testroot/wt/beta" >> $testroot/stdout.expected
 	echo "E  $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
 	echo "E  $testroot/wt/gamma/delta" >> $testroot/stdout.expected
-	echo "Now shut up and hack" >> $testroot/stdout.expected
+	echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
 
 	got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
 	ret="$?"
@@ -536,7 +556,9 @@ test_checkout_symlink() {
 	echo "A  $testroot/wt/nonexistent.link" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/passwd.link" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/passwd2.link" >> $testroot/stdout.expected
-	echo "Now shut up and hack" >> $testroot/stdout.expected
+	echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
 
 	cmp -s $testroot/stdout.expected $testroot/stdout
 	ret="$?"
@@ -785,6 +807,43 @@ test_checkout_repo_with_unknown_extension() {
 	test_done "$testroot" "$ret"
 }
 
+test_checkout_quiet() {
+	local testroot=`test_init checkout_quiet`
+
+	echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
+
+	got checkout -q $testroot/repo $testroot/wt > $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo "alpha" > $testroot/content.expected
+	echo "beta" >> $testroot/content.expected
+	echo "zeta" >> $testroot/content.expected
+	echo "delta" >> $testroot/content.expected
+	cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
+	    $testroot/wt/gamma/delta > $testroot/content
+
+	cmp -s $testroot/content.expected $testroot/content
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/content.expected $testroot/content
+	fi
+	test_done "$testroot" "$ret"
+}
+
 test_parseargs "$@"
 run_test test_checkout_basic
 run_test test_checkout_dir_exists
@@ -798,3 +857,4 @@ run_test test_checkout_into_nonempty_dir
 run_test test_checkout_symlink
 run_test test_checkout_symlink_relative_wtpath
 run_test test_checkout_repo_with_unknown_extension
+run_test test_checkout_quiet
blob - 487d5e7d9c6ed6c9c2532b3a7fc2dd808e7f3284
file + regress/cmdline/import.sh
--- regress/cmdline/import.sh
+++ regress/cmdline/import.sh
@@ -104,7 +104,9 @@ test_import_basic() {
 	echo "A  $testroot/wt/beta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
 	echo "A  $testroot/wt/gamma/delta" >> $testroot/stdout.expected
-	echo "Now shut up and hack" >> $testroot/stdout.expected
+	echo -n "Checked out refs/heads/main: " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo "\nNow shut up and hack" >> $testroot/stdout.expected
 
 	got checkout $testroot/repo $testroot/wt > $testroot/stdout
 	ret="$?"
blob - 8c6c24e701901e9c2ad8922e593794b9365ff248
file + regress/cmdline/status.sh
--- regress/cmdline/status.sh
+++ regress/cmdline/status.sh
@@ -803,6 +803,133 @@ test_status_status_code() {
 	test_done "$testroot" "$ret"
 }
 
+test_status_no_status_code() {
+	local testroot=`test_init status_no_status_code`
+
+	got checkout $testroot/repo $testroot/wt > /dev/null
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo "modified alpha" > $testroot/wt/alpha
+	(cd $testroot/wt && got rm beta >/dev/null)
+	echo "unversioned file" > $testroot/wt/foo
+	rm $testroot/wt/epsilon/zeta
+	touch $testroot/wt/beta
+	echo "new file" > $testroot/wt/new
+	(cd $testroot/wt && got add new >/dev/null)
+
+	(cd $testroot/wt && got status -S xDM \
+		> $testroot/stdout 2> $testroot/stderr)
+	ret="$?"
+	if [ "$ret" = "0" ]; then
+		echo "status succeeded unexpectedly" >&2
+		test_done "$testroot" "1"
+		return 1
+	fi
+
+	echo "got: invalid status code 'x'" > $testroot/stderr.expected
+	cmp -s $testroot/stderr.expected $testroot/stderr
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stderr.expected $testroot/stderr
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo 'M  alpha' > $testroot/stdout.expected
+	(cd $testroot/wt && got status -S D?A\! > $testroot/stdout)
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo 'D  beta' > $testroot/stdout.expected
+	(cd $testroot/wt && got status -S M?A\! > $testroot/stdout)
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo '!  epsilon/zeta' > $testroot/stdout.expected
+	echo '?  foo' >> $testroot/stdout.expected
+	(cd $testroot/wt && got status -S MDA > $testroot/stdout)
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo 'A  new' > $testroot/stdout.expected
+	(cd $testroot/wt && got status -S MD?\! > $testroot/stdout)
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	(cd $testroot/wt && got stage new > $testroot/stdout)
+
+	echo ' A new' > $testroot/stdout.expected
+	(cd $testroot/wt && got status -S MD?\! > $testroot/stdout)
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo 'changed file new' > $testroot/wt/new
+
+	echo 'M  alpha' > $testroot/stdout.expected
+	echo 'MA new' >> $testroot/stdout.expected
+	(cd $testroot/wt && got status -S D?\! > $testroot/stdout)
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo 'M  alpha' > $testroot/stdout.expected
+	(cd $testroot/wt && got status -S AD?\! > $testroot/stdout)
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	rm $testroot/stdout.expected
+	touch $testroot/stdout.expected
+
+	(cd $testroot/wt && got status -S MD?\! > $testroot/stdout)
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	test_done "$testroot" "$ret"
+}
+
 test_status_empty_file() {
 	local testroot=`test_init status_empty_file`
 
@@ -873,4 +1000,5 @@ run_test test_status_many_paths
 run_test test_status_cvsignore
 run_test test_status_gitignore
 run_test test_status_status_code
+run_test test_status_no_status_code
 run_test test_status_empty_file
blob - b75e01faf9766a5bd715ecc25bc1373dc6f135a1
file + regress/cmdline/update.sh
--- regress/cmdline/update.sh
+++ regress/cmdline/update.sh
@@ -2679,7 +2679,44 @@ test_update_file_skipped_due_to_obstruction() {
 	test_done "$testroot" "$ret"
 }
 
+test_update_quiet() {
+	local testroot=`test_init update_quiet`
 
+	got checkout $testroot/repo $testroot/wt > /dev/null
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo "modified alpha" > $testroot/repo/alpha
+	git_commit $testroot/repo -m "modified alpha"
+
+	echo -n "Updated to commit " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo >> $testroot/stdout.expected
+
+	(cd $testroot/wt && got update -q > $testroot/stdout)
+
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo "modified alpha" > $testroot/content.expected
+	cat $testroot/wt/alpha > $testroot/content
+
+	cmp -s $testroot/content.expected $testroot/content
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/content.expected $testroot/content
+	fi
+	test_done "$testroot" "$ret"
+}
+
 test_parseargs "$@"
 run_test test_update_basic
 run_test test_update_adds_file
@@ -2722,3 +2759,4 @@ run_test test_update_symlink_conflicts
 run_test test_update_single_file
 run_test test_update_file_skipped_due_to_conflict
 run_test test_update_file_skipped_due_to_obstruction
+run_test test_update_quiet