{"thread":{"id":"1160","subject":"[PATCH] Prevent t6000 series from dropping useless sed.script in t/","startedAt":"2005-07-07T18:39:10Z","lastAt":"2005-07-07T22:40:33Z","messageCount":2,"participants":["Junio C Hamano","Jon Seymour"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"5769","messageId":"7vd5pusbox.fsf@assigned-by-dhcp.cox.net","threadId":"1160","inReplyTo":null,"subject":"[PATCH] Prevent t6000 series from dropping useless sed.script in t/","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-07T18:39:10Z","receivedAt":"2005-07-07T18:39:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The Makefile in the test suite directory considers any file\nmatching t[0-9][0-9][0-9][0-9]-*.sh as the top-level test script\nto be executed.  Unfortunately this was not documented, and the\ncommon test library, t6000-lib.sh was named to match that\npattern.  This caused t6000-lib.sh to be called from Makefile as\nthe top-level program, causing it to leave t/sed.script file\nbehind.  Rename it to t6000lib.sh to prevent this, and document\nthe naming convention a bit more clearly.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n t/README                        |    8 +++\n t/t6000-lib.sh                  |  109 ---------------------------------------\n t/t6000lib.sh                   |  109 +++++++++++++++++++++++++++++++++++++++\n t/t6001-rev-list-merge-order.sh |    2 -\n t/t6002-rev-list-bisect.sh      |    2 -\n t/t6003-rev-list-topo-order.sh  |    2 -\n 6 files changed, 120 insertions(+), 112 deletions(-)\n delete mode 100644 t/t6000-lib.sh\n create mode 100644 t/t6000lib.sh\n\n02e754c481bc5656ccb9b6159c78001d6cf5f552\ndiff --git a/t/README b/t/README\n--- a/t/README\n+++ b/t/README\n@@ -79,6 +79,14 @@ Second digit tells the particular comman\n Third digit (optionally) tells the particular switch or group of switches\n we are testing.\n \n+If you create files under t/ directory (i.e. here) that is not\n+the top-level test script, never name the file to match the above\n+pattern.  The Makefile here considers all such files as the\n+top-level test script and tries to run all of them.  A care is\n+especially needed if you are creating a common test library\n+file, similar to test-lib.sh, because such a library file may\n+not be suitable for standalone execution.\n+\n \n Writing Tests\n -------------\ndiff --git a/t/t6000-lib.sh b/t/t6000-lib.sh\ndeleted file mode 100644\n--- a/t/t6000-lib.sh\n+++ /dev/null\n@@ -1,109 +0,0 @@\n-[ -d .git/refs/tags ] || mkdir -p .git/refs/tags\n-\n-:> sed.script\n-\n-# Answer the sha1 has associated with the tag. The tag must exist in .git or .git/refs/tags\n-tag()\n-{\n-\t_tag=$1\n-\t[ -f .git/refs/tags/$_tag ] || error \"tag: \\\"$_tag\\\" does not exist\"\n-\tcat .git/refs/tags/$_tag\n-}\n-\n-# Generate a commit using the text specified to make it unique and the tree\n-# named by the tag specified.\n-unique_commit()\n-{\n-\t_text=$1\n-        _tree=$2\n-\tshift 2\n-    \techo $_text | git-commit-tree $(tag $_tree) \"$@\"\n-}\n-\n-# Save the output of a command into the tag specified. Prepend\n-# a substitution script for the tag onto the front of sed.script\n-save_tag()\n-{\n-\t_tag=$1\t\n-\t[ -n \"$_tag\" ] || error \"usage: save_tag tag commit-args ...\"\n-\tshift 1\n-    \t\"$@\" >.git/refs/tags/$_tag\n-\n-        echo \"s/$(tag $_tag)/$_tag/g\" > sed.script.tmp\n-\tcat sed.script >> sed.script.tmp\n-\trm sed.script\n-\tmv sed.script.tmp sed.script\n-}\n-\n-# Replace unhelpful sha1 hashses with their symbolic equivalents \n-entag()\n-{\n-\tsed -f sed.script\n-}\n-\n-# Execute a command after first saving, then setting the GIT_AUTHOR_EMAIL\n-# tag to a specified value. Restore the original value on return.\n-as_author()\n-{\n-\t_author=$1\n-\tshift 1\n-        _save=$GIT_AUTHOR_EMAIL\n-\n-\texport GIT_AUTHOR_EMAIL=\"$_author\"\n-\t\"$@\"\n-        export GIT_AUTHOR_EMAIL=\"$_save\"\n-}\n-\n-commit_date()\n-{\n-        _commit=$1\n-\tgit-cat-file commit $_commit | sed -n \"s/^committer .*> \\([0-9]*\\) .*/\\1/p\" \n-}\n-\n-on_committer_date()\n-{\n-    _date=$1\n-    shift 1\n-    GIT_COMMITTER_DATE=$_date \"$@\"\n-}\n-\n-# Execute a command and suppress any error output.\n-hide_error()\n-{\n-\t\"$@\" 2>/dev/null\n-}\n-\n-check_output()\n-{\n-\t_name=$1\n-\tshift 1\n-\tif eval \"$*\" | entag > $_name.actual\n-\tthen\n-\t\tdiff $_name.expected $_name.actual\n-\telse\n-\t\treturn 1;\n-\tfi\n-}\n-\n-# Turn a reasonable test description into a reasonable test name.\n-# All alphanums translated into -'s which are then compressed and stripped\n-# from front and back.\n-name_from_description()\n-{\n-        tr \"'\" '-' | tr '~`!@#$%^&*()_+={}[]|\\;:\"<>,/? ' '-' | tr -s '-' | tr '[A-Z]' '[a-z]' | sed \"s/^-*//;s/-*\\$//\"\n-}\n-\n-\n-# Execute the test described by the first argument, by eval'ing\n-# command line specified in the 2nd argument. Check the status code\n-# is zero and that the output matches the stream read from \n-# stdin.\n-test_output_expect_success()\n-{\t\n-\t_description=$1\n-        _test=$2\n-        [ $# -eq 2 ] || error \"usage: test_output_expect_success description test <<EOF ... EOF\"\n-        _name=$(echo $_description | name_from_description)\n-\tcat > $_name.expected\n-\ttest_expect_success \"$_description\" \"check_output $_name \\\"$_test\\\"\" \n-}\ndiff --git a/t/t6000lib.sh b/t/t6000lib.sh\nnew file mode 100644\n--- /dev/null\n+++ b/t/t6000lib.sh\n@@ -0,0 +1,109 @@\n+[ -d .git/refs/tags ] || mkdir -p .git/refs/tags\n+\n+:> sed.script\n+\n+# Answer the sha1 has associated with the tag. The tag must exist in .git or .git/refs/tags\n+tag()\n+{\n+\t_tag=$1\n+\t[ -f .git/refs/tags/$_tag ] || error \"tag: \\\"$_tag\\\" does not exist\"\n+\tcat .git/refs/tags/$_tag\n+}\n+\n+# Generate a commit using the text specified to make it unique and the tree\n+# named by the tag specified.\n+unique_commit()\n+{\n+\t_text=$1\n+        _tree=$2\n+\tshift 2\n+    \techo $_text | git-commit-tree $(tag $_tree) \"$@\"\n+}\n+\n+# Save the output of a command into the tag specified. Prepend\n+# a substitution script for the tag onto the front of sed.script\n+save_tag()\n+{\n+\t_tag=$1\t\n+\t[ -n \"$_tag\" ] || error \"usage: save_tag tag commit-args ...\"\n+\tshift 1\n+    \t\"$@\" >.git/refs/tags/$_tag\n+\n+        echo \"s/$(tag $_tag)/$_tag/g\" > sed.script.tmp\n+\tcat sed.script >> sed.script.tmp\n+\trm sed.script\n+\tmv sed.script.tmp sed.script\n+}\n+\n+# Replace unhelpful sha1 hashses with their symbolic equivalents \n+entag()\n+{\n+\tsed -f sed.script\n+}\n+\n+# Execute a command after first saving, then setting the GIT_AUTHOR_EMAIL\n+# tag to a specified value. Restore the original value on return.\n+as_author()\n+{\n+\t_author=$1\n+\tshift 1\n+        _save=$GIT_AUTHOR_EMAIL\n+\n+\texport GIT_AUTHOR_EMAIL=\"$_author\"\n+\t\"$@\"\n+        export GIT_AUTHOR_EMAIL=\"$_save\"\n+}\n+\n+commit_date()\n+{\n+        _commit=$1\n+\tgit-cat-file commit $_commit | sed -n \"s/^committer .*> \\([0-9]*\\) .*/\\1/p\" \n+}\n+\n+on_committer_date()\n+{\n+    _date=$1\n+    shift 1\n+    GIT_COMMITTER_DATE=$_date \"$@\"\n+}\n+\n+# Execute a command and suppress any error output.\n+hide_error()\n+{\n+\t\"$@\" 2>/dev/null\n+}\n+\n+check_output()\n+{\n+\t_name=$1\n+\tshift 1\n+\tif eval \"$*\" | entag > $_name.actual\n+\tthen\n+\t\tdiff $_name.expected $_name.actual\n+\telse\n+\t\treturn 1;\n+\tfi\n+}\n+\n+# Turn a reasonable test description into a reasonable test name.\n+# All alphanums translated into -'s which are then compressed and stripped\n+# from front and back.\n+name_from_description()\n+{\n+        tr \"'\" '-' | tr '~`!@#$%^&*()_+={}[]|\\;:\"<>,/? ' '-' | tr -s '-' | tr '[A-Z]' '[a-z]' | sed \"s/^-*//;s/-*\\$//\"\n+}\n+\n+\n+# Execute the test described by the first argument, by eval'ing\n+# command line specified in the 2nd argument. Check the status code\n+# is zero and that the output matches the stream read from \n+# stdin.\n+test_output_expect_success()\n+{\t\n+\t_description=$1\n+        _test=$2\n+        [ $# -eq 2 ] || error \"usage: test_output_expect_success description test <<EOF ... EOF\"\n+        _name=$(echo $_description | name_from_description)\n+\tcat > $_name.expected\n+\ttest_expect_success \"$_description\" \"check_output $_name \\\"$_test\\\"\" \n+}\ndiff --git a/t/t6001-rev-list-merge-order.sh b/t/t6001-rev-list-merge-order.sh\n--- a/t/t6001-rev-list-merge-order.sh\n+++ b/t/t6001-rev-list-merge-order.sh\n@@ -6,7 +6,7 @@\n test_description='Tests git-rev-list --merge-order functionality'\n \n . ./test-lib.sh\n-. ../t6000-lib.sh # t6xxx specific functions\n+. ../t6000lib.sh # t6xxx specific functions\n \n # test-case specific test function\n check_adjacency()\ndiff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh\n--- a/t/t6002-rev-list-bisect.sh\n+++ b/t/t6002-rev-list-bisect.sh\n@@ -5,7 +5,7 @@\n test_description='Tests git-rev-list --bisect functionality'\n \n . ./test-lib.sh\n-. ../t6000-lib.sh\n+. ../t6000lib.sh # t6xxx specific functions\n \n bc_expr()\n {\ndiff --git a/t/t6003-rev-list-topo-order.sh b/t/t6003-rev-list-topo-order.sh\n--- a/t/t6003-rev-list-topo-order.sh\n+++ b/t/t6003-rev-list-topo-order.sh\n@@ -6,7 +6,7 @@\n test_description='Tests git-rev-list --topo-order functionality'\n \n . ./test-lib.sh\n-. ../t6000-lib.sh # t6xxx specific functions\n+. ../t6000lib.sh # t6xxx specific functions\n \n list_duplicates()\n {\n------------\n"},{"id":"5783","messageId":"2cfc4032050707154014f30774@mail.gmail.com","threadId":"1160","inReplyTo":"7vd5pusbox.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Prevent t6000 series from dropping useless sed.script in t/","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2005-07-07T22:40:33Z","receivedAt":"2005-07-07T22:40:33Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Ack - sorry I didn't notice that side effect.\n\njon.\n"}]}