{"thread":{"id":"10115","subject":"[PATCH] Add a test script for for-each-ref, including test of date formatting Signed-off-by: Andy Parkins <andyparkins@gmail.com>","startedAt":"2007-10-02T11:02:57Z","lastAt":"2007-10-02T11:02:57Z","messageCount":1,"participants":["Andy Parkins"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"54553","messageId":"200710021202.57134.andyparkins@gmail.com","threadId":"10115","inReplyTo":null,"subject":"[PATCH] Add a test script for for-each-ref, including test of date formatting Signed-off-by: Andy Parkins <andyparkins@gmail.com>","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2007-10-02T11:02:57Z","receivedAt":"2007-10-02T11:02:57Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"---\n t/t6300-for-each-ref.sh |  164 +++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 164 insertions(+), 0 deletions(-)\n create mode 100644 t/t6300-for-each-ref.sh\n\ndiff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh\nnew file mode 100644\nindex 0000000..b07f157\n--- /dev/null\n+++ b/t/t6300-for-each-ref.sh\n@@ -0,0 +1,164 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Andy Parkins\n+#\n+\n+test_description='for-each-ref test'\n+\n+. ./test-lib.sh\n+\n+# Mon Jul 3 15:18:43 2006 +0000\n+datestamp=1151939923\n+setdate_and_increment () {\n+    GIT_COMMITTER_DATE=\"$datestamp +0200\"\n+    datestamp=$(expr \"$datestamp\" + 1)\n+    GIT_AUTHOR_DATE=\"$datestamp +0200\"\n+    datestamp=$(expr \"$datestamp\" + 1)\n+    export GIT_COMMITTER_DATE GIT_AUTHOR_DATE\n+}\n+\n+test_expect_success 'Create sample commit with known timestamp' '\n+\tsetdate_and_increment &&\n+\techo \"Using $datestamp\" > one &&\n+\tgit add one &&\n+\tgit commit -m \"Initial\" &&\n+\tsetdate_and_increment &&\n+\tgit tag -a -m \"Tagging at $datestamp\" testtag\n+'\n+\n+test_expect_success 'Check atom names are valid' '\n+\tgit for-each-ref --format=\"refname=%(refname)\" refs/heads &&\n+\tgit for-each-ref --format=\"objecttype=%(objecttype)\" refs/heads &&\n+\tgit for-each-ref --format=\"objectsize=%(objectsize)\" refs/heads &&\n+\tgit for-each-ref --format=\"objectname=%(objectname)\" refs/heads &&\n+\tgit for-each-ref --format=\"tree=%(tree)\" refs/heads &&\n+\tgit for-each-ref --format=\"parent=%(parent)\" refs/heads &&\n+\tgit for-each-ref --format=\"numparent=%(numparent)\" refs/heads &&\n+\tgit for-each-ref --format=\"object=%(object)\" refs/heads &&\n+\tgit for-each-ref --format=\"type=%(type)\" refs/heads &&\n+\tgit for-each-ref --format=\"author=%(author)\" refs/heads &&\n+\tgit for-each-ref --format=\"authorname=%(authorname)\" refs/heads &&\n+\tgit for-each-ref --format=\"authoremail=%(authoremail)\" refs/heads &&\n+\tgit for-each-ref --format=\"authordate=%(authordate)\" refs/heads &&\n+\tgit for-each-ref --format=\"committer=%(committer)\" refs/heads &&\n+\tgit for-each-ref --format=\"committername=%(committername)\" refs/heads &&\n+\tgit for-each-ref --format=\"committeremail=%(committeremail)\" refs/heads &&\n+\tgit for-each-ref --format=\"committerdate=%(committerdate)\" refs/heads &&\n+\tgit for-each-ref --format=\"tag=%(tag)\" refs/tags &&\n+\tgit for-each-ref --format=\"tagger=%(tagger)\" refs/tags &&\n+\tgit for-each-ref --format=\"taggername=%(taggername)\" refs/tags &&\n+\tgit for-each-ref --format=\"taggeremail=%(taggeremail)\" refs/tags &&\n+\tgit for-each-ref --format=\"taggerdate=%(taggerdate)\" refs/tags &&\n+\tgit for-each-ref --format=\"creator=%(creator)\" refs/tags &&\n+\tgit for-each-ref --format=\"creatordate=%(creatordate)\" refs/tags &&\n+\tgit for-each-ref --format=\"subject=%(subject)\" refs/heads &&\n+\tgit for-each-ref --format=\"body=%(body)\" refs/heads &&\n+\tgit for-each-ref --format=\"contents=%(contents)\" refs/heads\n+'\n+\n+test_expect_failure 'Check invalid atoms names are errors' '\n+\tgit-for-each-ref --format=\"%(INVALID)\" refs/heads\n+'\n+\n+test_expect_success 'Check format specifiers are ignored in naming date atoms' '\n+\tgit-for-each-ref --format=\"%(authordate)\" refs/heads &&\n+\tgit-for-each-ref --format=\"%(authordate:default) %(authordate)\" refs/heads &&\n+\tgit-for-each-ref --format=\"%(authordate) %(authordate:default)\" refs/heads &&\n+\tgit-for-each-ref --format=\"%(authordate:default) %(authordate:default)\" refs/heads\n+'\n+\n+test_expect_success 'Check valid format specifiers for date fields' '\n+\tgit-for-each-ref --format=\"%(authordate:default)\" refs/heads &&\n+\tgit-for-each-ref --format=\"%(authordate:relative)\" refs/heads &&\n+\tgit-for-each-ref --format=\"%(authordate:short)\" refs/heads &&\n+\tgit-for-each-ref --format=\"%(authordate:local)\" refs/heads &&\n+\tgit-for-each-ref --format=\"%(authordate:iso8601)\" refs/heads &&\n+\tgit-for-each-ref --format=\"%(authordate:rfc2822)\" refs/heads\n+'\n+\n+test_expect_failure 'Check invalid format specifiers are errors' '\n+\tgit-for-each-ref --format=\"%(authordate:INVALID)\" refs/heads\n+'\n+\n+cat >expected <<\\EOF\n+'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'\n+'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'\n+EOF\n+\n+test_expect_success 'Check unformatted date fields output' '\n+\t(git for-each-ref --shell --format=\"%(refname) %(committerdate) %(authordate)\" refs/heads &&\n+\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate)\" refs/tags) >actual &&\n+\tgit diff expected actual\n+'\n+\n+test_expect_success 'Check format \"default\" formatted date fields output' '\n+\tf=default &&\n+\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n+\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n+\tgit diff expected actual\n+'\n+\n+# Don't know how to do relative check because I can't know when this script\n+# is going to be run and can't fake the current time to git, and hence can't\n+# provide expected output.  Instead, I'll just make sure that \"relative\"\n+# doesn't exit in error\n+#\n+#cat >expected <<\\EOF\n+#\n+#EOF\n+#\n+test_expect_success 'Check format \"relative\" date fields output' '\n+\tf=relative &&\n+\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n+\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual\n+'\n+\n+cat >expected <<\\EOF\n+'refs/heads/master' '2006-07-03' '2006-07-03'\n+'refs/tags/testtag' '2006-07-03'\n+EOF\n+\n+test_expect_success 'Check format \"short\" date fields output' '\n+\tf=short &&\n+\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n+\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n+\tgit diff expected actual\n+'\n+\n+cat >expected <<\\EOF\n+'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'\n+'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'\n+EOF\n+\n+test_expect_success 'Check format \"local\" date fields output' '\n+\tf=local &&\n+\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n+\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n+\tgit diff expected actual\n+'\n+\n+cat >expected <<\\EOF\n+'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'\n+'refs/tags/testtag' '2006-07-03 17:18:45 +0200'\n+EOF\n+\n+test_expect_success 'Check format \"iso8601\" date fields output' '\n+\tf=iso8601 &&\n+\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n+\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n+\tgit diff expected actual\n+'\n+\n+cat >expected <<\\EOF\n+'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'\n+'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'\n+EOF\n+\n+test_expect_success 'Check format \"rfc2822\" date fields output' '\n+\tf=rfc2822 &&\n+\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n+\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n+\tgit diff expected actual\n+'\n+\n+test_done\n-- \n1.5.3.2.105.gf47f2-dirty\n"}]}