git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[GUILT PATCH 5/5] Guards test suite

From
ELEric Lesh <eclesh@ucla.edu>
Date
Jul 31, 2007, 03:11 UTC
Message-ID
<11858514811776-git-send-email-eclesh@ucla.edu>
In-Reply-To
<1185851481190-git-send-email-eclesh@ucla.edu>

The guards patches touch a lot of guilt, so make sure they don't muck anything up.

Signed-off-by: Eric Lesh <eclesh@ucla.edu>
---
 regression/070-guards.sh |  184 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 184 insertions(+), 0 deletions(-)
 create mode 100755 regression/070-guards.sh
diff --git a/regression/070-guards.sh b/regression/070-guards.sh
new file mode 100755
index 0000000..d6917f2
--- /dev/null
+++ b/regression/070-guards.sh
@@ -0,0 +1,184 @@
+#!/bin/bash
+#
+# Test the commands that use get_*_series, while applying guards
+#
+
+source scaffold
+source generic_test_data
+
+function prepare_for_tests
+{
+	# generic_test_data's patches all depend on each other
+	# that's no good for guards testing
+
+	echo "abc" > def
+	git-add def
+	git-commit -s -m "initial" 2> /dev/null > /dev/null
+
+	cat << DONE > .git/patches/master/first
+diff --git a/first b/first
+new file mode 100644
+index 0000000..9c59e24
+--- /dev/null
++++ b/first
+@@ -0,0 +1 @@
++first
+DONE
+
+	cat << DONE > .git/patches/master/second
+diff --git a/second b/second
+new file mode 100644
+index 0000000..e019be0
+--- /dev/null
++++ b/second
+@@ -0,0 +1 @@
++second
+DONE
+
+	cat << DONE > .git/patches/master/third
+diff --git a/third b/third
+new file mode 100644
+index 0000000..234496b
+--- /dev/null
++++ b/third
+@@ -0,0 +1 @@
++third
+DONE
+
+	cat << DONE > .git/patches/master/fourth
+diff --git a/fourth b/fourth
+new file mode 100644
+index 0000000..285a4e6
+--- /dev/null
++++ b/fourth
+@@ -0,0 +1 @@
++fourth
+DONE
+
+	cat << DONE > .git/patches/master/series
+first
+second
+third
+fourth
+DONE
+
+	touch -d "$GIT_COMMITTER_DATE" .git/patches/master/first
+	touch -d "$GIT_COMMITTER_DATE" .git/patches/master/second
+	touch -d "$GIT_COMMITTER_DATE" .git/patches/master/third
+	touch -d "$GIT_COMMITTER_DATE" .git/patches/master/fourth
+}
+
+function expected_applied_none
+{
+	echo "first"
+	echo "second"
+	echo "third"
+	echo "fourth"
+}
+
+function expected_applied_positive
+{
+	echo "second"
+	echo "third"
+	echo "fourth"
+}
+
+function expected_applied_positive_selected
+{
+	echo "first"
+	echo "second"
+	echo "third"
+	echo "fourth"
+}
+
+function expected_applied_negative
+{
+	echo "first"
+	echo "second"
+	echo "third"
+	echo "fourth"
+}
+
+function expected_applied_negative_selected
+{
+	echo "second"
+	echo "third"
+	echo "fourth"
+}
+
+function expected_next
+{
+	echo "second"
+}
+
+function expected_unapplied
+{
+	echo "second"
+	echo "third"
+	echo "fourth"
+}
+
+empty_repo
+cd $REPODIR
+guilt-init
+
+prepare_for_tests
+
+# test with no guarded patches and no guards selected
+guilt-push -a > /dev/null
+guilt-applied > /tmp/reg.$$
+expected_applied_none | diff -u - /tmp/reg.$$
+echo -n "[none] "
+
+# test with one positive guarded patch and no guards selected
+guilt-pop -a > /dev/null
+guilt-guard first +foo
+guilt-push -a > /dev/null
+guilt-applied > /tmp/reg.$$
+expected_applied_positive | diff -u - /tmp/reg.$$
+echo -n "[positive] "
+
+# test with one positive guarded patch with that guard selected
+guilt-pop -a > /dev/null
+guilt-select foo
+guilt-push -a > /dev/null
+guilt-applied > /tmp/reg.$$
+expected_applied_positive_selected | diff -u - /tmp/reg.$$
+echo -n "[positive selected] "
+
+# test with one negative guarded patch and no guards selected
+guilt pop -a > /dev/null
+guilt-select -n
+guilt-guard first -foo
+guilt-push -a > /dev/null
+guilt-applied > /tmp/reg.$$
+expected_applied_negative | diff -u - /tmp/reg.$$
+echo -n "[negative] "
+
+# test with one negative guarded patch with that guard selected
+guilt pop -a > /dev/null
+guilt-select foo
+guilt-push -a > /dev/null
+guilt-applied > /tmp/reg.$$
+expected_applied_negative_selected | diff -u - /tmp/reg.$$
+echo -n "[negative selected] "
+
+# test that guilt-next works
+guilt-pop -a > /dev/null
+guilt-select -n
+guilt-guard first +foo
+guilt-next > /tmp/reg.$$
+expected_next | diff -u - /tmp/reg.$$
+echo -n "[next] "
+
+# test that guilt-unapplied works
+guilt-pop -a > /dev/null
+guilt-select -n
+guilt-guard first +foo
+guilt-unapplied > /tmp/reg.$$
+expected_unapplied | diff -u - /tmp/reg.$$
+echo -n "[unapplied] "
+
+rm -f /tmp/reg.$$
+
+complete_test
-- 
1.5.2
Previous: Eric LeshNext: Josef Sipek
Message 15 of 16 in “Add guards to guilt”
  1. 0/5 Add guards to guiltEric Lesh, Jul 31, 2007
  2. 1/5 get_series: Remove comments from end of series linesEric Lesh, Jul 31, 2007
  3. Josef SipekJul 31, 2007
  4. 2/5 guilt-guard: Assign guards to patches in seriesEric Lesh, Jul 31, 2007
  5. Josef SipekJul 31, 2007
  6. Eric LeshAug 9, 2007
  7. David KastrupAug 9, 2007
  8. Thomas AdamAug 9, 2007
  9. David KastrupAug 9, 2007
  10. Eric LeshAug 9, 2007
  11. Eric LeshAug 9, 2007
  12. Josef SipekAug 9, 2007
  13. 3/5 guilt-select: Select guards to apply when pushing patchesEric Lesh, Jul 31, 2007
  14. 4/5 get_series: return guarded patches onlyEric Lesh, Jul 31, 2007
  15. 5/5 Guards test suiteEric Lesh, Jul 31, 2007
  16. Josef SipekJul 31, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.