{"thread":{"id":"3855","subject":"[PATCH 0/3] Add a testsuite to stgit","startedAt":"2006-04-12T21:16:33Z","lastAt":"2006-04-12T21:21:15Z","messageCount":4,"participants":["Yann Dirson"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"18590","messageId":"20060412211633.14579.98008.stgit@gandelf.nowhere.earth","threadId":"3855","inReplyTo":null,"subject":"[PATCH 0/3] Add a testsuite to stgit","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-04-12T21:16:33Z","receivedAt":"2006-04-12T21:16:33Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"The following steals the testsuite system from git-core and adapts it to stgit,\nadds a couple of items to the TODO file, and adds a first testsuite to\ndemonstrate a problem with branch renaming, to serve as a non-reg test.\n\nTo run the testsuite, just \"make -C t\", there is no integration in the python-generated\ntoplevel Makefile.\n\n--\nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"18593","messageId":"20060412212110.14579.45807.stgit@gandelf.nowhere.earth","threadId":"3855","inReplyTo":"20060412211633.14579.98008.stgit@gandelf.nowhere.earth","subject":"[PATCH 1/3] Add a testsuite framework copied from git-core","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-04-12T21:21:10Z","receivedAt":"2006-04-12T21:21:10Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"From:  <>\n\n\n---\n\n t/Makefile       |   25 ++++++\n t/t0000-dummy.sh |   17 ++++\n t/test-lib.sh    |  209 ++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 251 insertions(+), 0 deletions(-)\n\ndiff --git a/t/Makefile b/t/Makefile\nnew file mode 100644\nindex 0000000..d5d7b6f\n--- /dev/null\n+++ b/t/Makefile\n@@ -0,0 +1,25 @@\n+# Run tests\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+\n+#GIT_TEST_OPTS=--verbose --debug\n+SHELL_PATH ?= $(SHELL)\n+TAR ?= $(TAR)\n+\n+# Shell quote;\n+SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n+\n+T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)\n+\n+all: $(T) clean\n+\n+$(T):\n+\t@echo \"*** $@ ***\"; '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)\n+\n+clean:\n+\trm -fr trash\n+\n+.PHONY: $(T) clean\n+.NOPARALLEL:\n+\ndiff --git a/t/t0000-dummy.sh b/t/t0000-dummy.sh\nnew file mode 100755\nindex 0000000..ae4f838\n--- /dev/null\n+++ b/t/t0000-dummy.sh\n@@ -0,0 +1,17 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2006 Yann Dirson\n+#\n+\n+test_description='dummy test.\n+\n+Only to test the testing environment.\n+'\n+\n+. ./test-lib.sh\n+\n+test_expect_success \\\n+    'check stgit can be run' \\\n+    'stg version'\n+\n+test_done\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nnew file mode 100755\nindex 0000000..b1ac350\n--- /dev/null\n+++ b/t/test-lib.sh\n@@ -0,0 +1,209 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+# Copyright (c) 2006 Yann Dirson\n+#\n+\n+# For repeatability, reset the environment to known value.\n+LANG=C\n+LC_ALL=C\n+PAGER=cat\n+TZ=UTC\n+export LANG LC_ALL PAGER TZ\n+unset AUTHOR_DATE\n+unset AUTHOR_EMAIL\n+unset AUTHOR_NAME\n+unset COMMIT_AUTHOR_EMAIL\n+unset COMMIT_AUTHOR_NAME\n+unset GIT_ALTERNATE_OBJECT_DIRECTORIES\n+unset GIT_AUTHOR_DATE\n+GIT_AUTHOR_EMAIL=author@example.com\n+GIT_AUTHOR_NAME='A U Thor'\n+unset GIT_COMMITTER_DATE\n+GIT_COMMITTER_EMAIL=committer@example.com\n+GIT_COMMITTER_NAME='C O Mitter'\n+unset GIT_DIFF_OPTS\n+unset GIT_DIR\n+unset GIT_EXTERNAL_DIFF\n+unset GIT_INDEX_FILE\n+unset GIT_OBJECT_DIRECTORY\n+unset SHA1_FILE_DIRECTORIES\n+unset SHA1_FILE_DIRECTORY\n+export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME\n+export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME\n+\n+# Each test should start with something like this, after copyright notices:\n+#\n+# test_description='Description of this test...\n+# This test checks if command xyzzy does the right thing...\n+# '\n+# . ./test-lib.sh\n+\n+error () {\n+\techo \"* error: $*\"\n+\ttrap - exit\n+\texit 1\n+}\n+\n+say () {\n+\techo \"* $*\"\n+}\n+\n+test \"${test_description}\" != \"\" ||\n+error \"Test script did not set test_description.\"\n+\n+while test \"$#\" -ne 0\n+do\n+\tcase \"$1\" in\n+\t-d|--d|--de|--deb|--debu|--debug)\n+\t\tdebug=t; shift ;;\n+\t-i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)\n+\t\timmediate=t; shift ;;\n+\t-h|--h|--he|--hel|--help)\n+\t\techo \"$test_description\"\n+\t\texit 0 ;;\n+\t-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)\n+\t\tverbose=t; shift ;;\n+\t*)\n+\t\tbreak ;;\n+\tesac\n+done\n+\n+exec 5>&1\n+if test \"$verbose\" = \"t\"\n+then\n+\texec 4>&2 3>&1\n+else\n+\texec 4>/dev/null 3>/dev/null\n+fi\n+\n+test_failure=0\n+test_count=0\n+\n+trap 'echo >&5 \"FATAL: Unexpected exit with code $?\"; exit 1' exit\n+\n+\n+# You are not expected to call test_ok_ and test_failure_ directly, use\n+# the text_expect_* functions instead.\n+\n+test_ok_ () {\n+\ttest_count=$(expr \"$test_count\" + 1)\n+\tsay \"  ok $test_count: $@\"\n+}\n+\n+test_failure_ () {\n+\ttest_count=$(expr \"$test_count\" + 1)\n+\ttest_failure=$(expr \"$test_failure\" + 1);\n+\tsay \"FAIL $test_count: $1\"\n+\tshift\n+\techo \"$@\" | sed -e 's/^/\t/'\n+\ttest \"$immediate\" = \"\" || { trap - exit; exit 1; }\n+}\n+\n+\n+test_debug () {\n+\ttest \"$debug\" = \"\" || eval \"$1\"\n+}\n+\n+test_run_ () {\n+\teval >&3 2>&4 \"$1\"\n+\teval_ret=\"$?\"\n+\treturn 0\n+}\n+\n+test_expect_failure () {\n+\ttest \"$#\" = 2 ||\n+\terror \"bug in the test script: not 2 parameters to test-expect-failure\"\n+\tsay >&3 \"expecting failure: $2\"\n+\ttest_run_ \"$2\"\n+\tif [ \"$?\" = 0 -a \"$eval_ret\" != 0 ]\n+\tthen\n+\t\ttest_ok_ \"$1\"\n+\telse\n+\t\ttest_failure_ \"$@\"\n+\tfi\n+}\n+\n+test_expect_success () {\n+\ttest \"$#\" = 2 ||\n+\terror \"bug in the test script: not 2 parameters to test-expect-success\"\n+\tsay >&3 \"expecting success: $2\"\n+\ttest_run_ \"$2\"\n+\tif [ \"$?\" = 0 -a \"$eval_ret\" = 0 ]\n+\tthen\n+\t\ttest_ok_ \"$1\"\n+\telse\n+\t\ttest_failure_ \"$@\"\n+\tfi\n+}\n+\n+test_expect_code () {\n+\ttest \"$#\" = 3 ||\n+\terror \"bug in the test script: not 3 parameters to test-expect-code\"\n+\tsay >&3 \"expecting exit code $1: $3\"\n+\ttest_run_ \"$3\"\n+\tif [ \"$?\" = 0 -a \"$eval_ret\" = \"$1\" ]\n+\tthen\n+\t\ttest_ok_ \"$2\"\n+\telse\n+\t\ttest_failure_ \"$@\"\n+\tfi\n+}\n+\n+# Most tests can use the created repository, but some amy need to create more.\n+# Usage: test_create_repo <directory>\n+test_create_repo () {\n+\ttest \"$#\" = 1 ||\n+\terror \"bug in the test script: not 1 parameter to test-create-repo\"\n+\towd=`pwd`\n+\trepo=\"$1\"\n+\tmkdir \"$repo\"\n+\tcd \"$repo\" || error \"Cannot setup test environment\"\n+\tgit-init-db 2>/dev/null ||\n+\terror \"cannot run git-init-db -- have you installed git-core?\"\n+\tmv .git/hooks .git/hooks-disabled\n+\tcd \"$owd\"\n+}\n+\n+test_stg_init () {\n+\ttouch .empty\n+\tgit-update-index --add .empty\n+\tgit-commit -m \"nearly empty start\" 2>/dev/null ||\n+\terror \"cannot run git-commit -- is your git-core funtionning?\"\n+\tstg init ||\n+\terror \"cannot run stg init -- have you built things yet?\"\n+}\n+\n+test_done () {\n+\ttrap - exit\n+\tcase \"$test_failure\" in\n+\t0)\n+\t\t# We could:\n+\t\t# cd .. && rm -fr trash\n+\t\t# but that means we forbid any tests that use their own\n+\t\t# subdirectory from calling test_done without coming back\n+\t\t# to where they started from.\n+\t\t# The Makefile provided will clean this test area so\n+\t\t# we will leave things as they are.\n+\n+\t\tsay \"passed all $test_count test(s)\"\n+\t\texit 0 ;;\n+\n+\t*)\n+\t\tsay \"failed $test_failure among $test_count test(s)\"\n+\t\texit 1 ;;\n+\n+\tesac\n+}\n+\n+# Test the binaries we have just built.  The tests are kept in\n+# t/ subdirectory and are run in trash subdirectory.\n+PATH=$(pwd)/..:$PATH\n+export PATH\n+\n+\n+# Test repository\n+test=trash\n+rm -fr \"$test\"\n+test_create_repo $test\n+cd \"$test\"\n"},{"id":"18592","messageId":"20060412212113.14579.86918.stgit@gandelf.nowhere.earth","threadId":"3855","inReplyTo":"20060412211633.14579.98008.stgit@gandelf.nowhere.earth","subject":"[PATCH 2/3] Add list of bugs to TODO","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-04-12T21:21:13Z","receivedAt":"2006-04-12T21:21:13Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"From:  <>\n\n\n---\n\n TODO |    9 +++++++++\n 1 files changed, 9 insertions(+), 0 deletions(-)\n\ndiff --git a/TODO b/TODO\nindex e5affe0..a9a8b1f 100644\n--- a/TODO\n+++ b/TODO\n@@ -17,3 +17,12 @@ The future, when time allows or if someo\n   synchronising with other patches (diff format or in other\n   repositories)\n - write bash-completion script for the StGIT commands\n+- support for branches with / in names\n+  (ml: \"Handle branch names with slashes\")\n+- \"pull\" argument should default to a sane value, \"origin\" is wrong in\n+  many cases\n+\n+Bugs:\n+\n+- the following commands break in subdirs:\n+  - refresh (ml: \"Running StGIT in subdirectories\")\n"},{"id":"18591","messageId":"20060412212115.14579.89747.stgit@gandelf.nowhere.earth","threadId":"3855","inReplyTo":"20060412211633.14579.98008.stgit@gandelf.nowhere.earth","subject":"[PATCH 3/3] Add testcase for branch -r problem","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-04-12T21:21:15Z","receivedAt":"2006-04-12T21:21:15Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"From:  <>\n\n\n---\n\n TODO              |    1 +\n t/t1000-branch.sh |   33 +++++++++++++++++++++++++++++++++\n 2 files changed, 34 insertions(+), 0 deletions(-)\n\ndiff --git a/TODO b/TODO\nindex a9a8b1f..365ecd4 100644\n--- a/TODO\n+++ b/TODO\n@@ -26,3 +26,4 @@ Bugs:\n \n - the following commands break in subdirs:\n   - refresh (ml: \"Running StGIT in subdirectories\")\n+- branch renaming leaves junk behind\ndiff --git a/t/t1000-branch.sh b/t/t1000-branch.sh\nnew file mode 100755\nindex 0000000..4c790f5\n--- /dev/null\n+++ b/t/t1000-branch.sh\n@@ -0,0 +1,33 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2006 Yann Dirson\n+#\n+\n+test_description='dummy test.\n+\n+Only to test the testing environment.\n+'\n+\n+. ./test-lib.sh\n+\n+test_stg_init\n+\n+test_expect_success \\\n+    'Create an stgit branch from scratch' \\\n+    'stg branch -c foo &&\n+     stg new p1 -m \"p1\"\n+'\n+\n+test_expect_failure \\\n+    'Rename the current stgit branch' \\\n+    'stg branch -r foo bar\n+'\n+\n+test_expect_success \\\n+    'Rename an stgit branch' \\\n+    'stg branch -c buz &&\n+     stg branch -r foo bar &&\n+     test -z `find .git -name foo`\n+'\n+\n+test_done\n"}]}