From cb1570e14f5e021ccd6580f207fdc6297611fc49 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Thu, 24 Jul 2008 03:05:29 +0200 Subject: [PATCH] Test operations on hidden patches MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Organization: Straylight/Edgeware From: Karl Hasselström Previously, we didn't test this at all. Now we have some tests at least; and, not surprisingly, a few of them fail. The expected result of the tests are based on the following idea of how hidden patches should work: They should behave just like unapplied patches when named explicitly; but if not named explicitly, they should behave as if they didn't exist. So for example, a push without arguments should never push a hidden patch, but it should be possible to push a hidden patch if it is named explicitly. Signed-off-by: Karl Hasselström --- t/t1206-push-hidden.sh | 28 ++++++++++++++++++++++++++++ t/t1701-goto-hidden.sh | 23 +++++++++++++++++++++++ t/t2900-rename.sh | 7 +++++++ t/t3300-edit.sh | 16 +++++++++++++--- 4 files changed, 71 insertions(+), 3 deletions(-) create mode 100755 t/t1206-push-hidden.sh create mode 100755 t/t1701-goto-hidden.sh diff --git a/t/t1206-push-hidden.sh b/t/t1206-push-hidden.sh new file mode 100755 index 0000000..20aa306 --- /dev/null +++ b/t/t1206-push-hidden.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +test_description='Test "stg push" with hidden patches' + +. ./test-lib.sh + +test_expect_success 'Initialize StGit stack' ' + stg init && + echo foo > foo.txt && + git add foo.txt && + stg new -m hidden-patch && + stg refresh && + stg pop && + stg hide hidden-patch && + test "$(echo $(stg series --all))" = "! hidden-patch" +' + +test_expect_success 'Push an implicitly named hidden patch (should fail)' ' + command_error stg push && + test "$(echo $(stg series --all))" = "! hidden-patch" +' + +test_expect_failure 'Push an explicitly named hidden patch (should work)' ' + stg push hidden-patch && + test "$(echo $(stg series --all))" = "> hidden-patch" +' + +test_done diff --git a/t/t1701-goto-hidden.sh b/t/t1701-goto-hidden.sh new file mode 100755 index 0000000..a3c6e62 --- /dev/null +++ b/t/t1701-goto-hidden.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +test_description='Test "stg goto" with hidden patches' + +. ./test-lib.sh + +test_expect_success 'Initialize StGit stack' ' + stg init && + echo foo > foo.txt && + git add foo.txt && + stg new -m hidden-patch && + stg refresh && + stg pop && + stg hide hidden-patch && + test "$(echo $(stg series --all))" = "! hidden-patch" +' + +test_expect_success 'Refuse to go to a hidden patch' ' + command_error stg goto hidden-patch && + test "$(echo $(stg series --all))" = "! hidden-patch" +' + +test_done diff --git a/t/t2900-rename.sh b/t/t2900-rename.sh index 0e16d6e..32900d0 100755 --- a/t/t2900-rename.sh +++ b/t/t2900-rename.sh @@ -44,4 +44,11 @@ test_expect_success 'Rename top-most when others exist' ' stg rename bar ' +test_expect_failure 'Rename hidden' ' + stg pop && + stg hide bar && + stg rename bar pub && + test "$(echo $(stg series --all))" = "> foo ! pub" +' + test_done diff --git a/t/t3300-edit.sh b/t/t3300-edit.sh index 8304d9f..5772e48 100755 --- a/t/t3300-edit.sh +++ b/t/t3300-edit.sh @@ -4,7 +4,7 @@ test_description='Test "stg edit"' . ./test-lib.sh test_expect_success 'Setup' ' - printf "000\n111\n222\n" >> foo && + printf "000\n111\n222\n333\n" >> foo && git add foo && git commit -m "Initial commit" && sed -i "s/000/000xx/" foo && @@ -13,9 +13,13 @@ test_expect_success 'Setup' ' git commit -a -m "Second change" && sed -i "s/222/222zz/" foo && git commit -a -m "Third change" && + sed -i "s/333/333zz/" foo && + git commit -a -m "Fourth change" && stg init && - stg uncommit -n 3 p && - stg pop + stg uncommit -n 4 p && + stg pop -n 2 && + stg hide p4 && + test "$(echo $(stg series --all))" = "+ p1 > p2 - p3 ! p4" ' # Commit parse functions. @@ -41,6 +45,12 @@ test_expect_success 'Edit message of unapplied patch' ' test "$(msg $(stg id p3))" = "Third change 2" ' +test_expect_success 'Edit message of hidden patch' ' + test "$(msg $(stg id p4))" = "Fourth change" && + stg edit p4 -m "Fourth change 2" && + test "$(msg $(stg id p4))" = "Fourth change 2" +' + test_expect_success 'Set patch message with --file ' ' test "$(msg HEAD)" = "Second change 2" && echo "Pride or Prejudice" > commitmsg && -- [mdw]