{"thread":{"id":"598","subject":"[PATCH 2/2] Test recent additions to core GIT.","startedAt":"2005-05-13T00:22:02Z","lastAt":"2005-05-13T00:22:02Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"3219","messageId":"7vbr7gasb9.fsf@assigned-by-dhcp.cox.net","threadId":"598","inReplyTo":null,"subject":"[PATCH 2/2] Test recent additions to core GIT.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-13T00:22:02Z","receivedAt":"2005-05-13T00:22:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This is a set of tests I used to verify recently made changes.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n*** Note: Please do not forget chmod +x t/t*.sh after applying\n*** before committing.\n\nt/t0100-environment-names.sh |   84 +++++++++++++++++++++++++++++++++++++++++++\nt/t0200-update-cache.sh      |   47 ++++++++++++++++++++++++\nt/t0400-ls-files.sh          |   29 ++++++++++++++\nt/t0500-ls-files.sh          |   55 ++++++++++++++++++++++++++++\nt/t1000-checkout-cache.sh    |   54 +++++++++++++++++++++++++++\nt/t1001-checkout-cache.sh    |   76 ++++++++++++++++++++++++++++++++++++++\n6 files changed, 345 insertions(+)\nt/t0100-environment-names.sh (. --> 100755)\nt/t0200-update-cache.sh (. --> 100755)\nt/t0400-ls-files.sh (. --> 100755)\nt/t0500-ls-files.sh (. --> 100755)\nt/t1000-checkout-cache.sh (. --> 100755)\nt/t1001-checkout-cache.sh (. --> 100755)\n\n--- a/t/t0100-environment-names.sh\n+++ b/t/t0100-environment-names.sh\n@@ -0,0 +1,84 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+\n+test_description='general environment name warning test.\n+\n+This test makes sure that use of deprecated environment variables\n+trigger the warnings from gitenv().'\n+\n+env_vars='GIT_AUTHOR_DATE:AUTHOR_DATE\n+GIT_AUTHOR_EMAIL:AUTHOR_EMAIL\n+GIT_AUTHOR_NAME:AUTHOR_NAME\n+GIT_COMMITTER_EMAIL:COMMIT_AUTHOR_EMAIL\n+GIT_COMMITTER_NAME:COMMIT_AUTHOR_NAME\n+GIT_ALTERNATE_OBJECT_DIRECTORIES:SHA1_FILE_DIRECTORIES\n+GIT_OBJECT_DIRECTORY:SHA1_FILE_DIRECTORY\n+'\n+\n+. ./test-lib.sh\n+\n+export_them () {\n+\tfor ev in $env_vars\n+\tdo\n+\t\tnew=$(expr \"$ev\" : '\\(.*\\):')\n+\t\told=$(expr \"$ev\" : '.*:\\(.*\\)')\n+\t\t# Build and eval the following:\n+\t\t# case \"${VAR+set}\" in set) export VAR;; esac\n+\t\tevstr='case \"${'$new'+set}\" in set) export '$new';; esac'\n+\t\teval \"$evstr\"\n+\t\tevstr='case \"${'$old'+set}\" in set) export '$old';; esac'\n+\t\teval \"$evstr\"\n+\tdone\n+}\n+\n+date >path0\n+git-update-cache --add path0\n+tree=$(git-write-tree)\n+\n+AUTHOR_DATE='Wed May 11 23:55:18 2005'\n+AUTHOR_EMAIL='author@example.xz'\n+AUTHOR_NAME='A U Thor'\n+COMMIT_AUTHOR_EMAIL='author@example.xz'\n+COMMIT_AUTHOR_NAME='A U Thor'\n+SHA1_FILE_DIRECTORY=.git/objects\n+\n+export_them\n+\n+test_debug 'echo with only old variables exported.'\n+\n+echo 'foo' | git-commit-tree $tree >/dev/null 2>errmsg\n+cat >expected-err <<\\EOF\n+warning: Attempting to use SHA1_FILE_DIRECTORY\n+warning: GIT environment variables have been renamed.\n+warning: Please adjust your scripts and environment.\n+warning: old AUTHOR_DATE => new GIT_AUTHOR_DATE\n+warning: old AUTHOR_EMAIL => new GIT_AUTHOR_EMAIL\n+warning: old AUTHOR_NAME => new GIT_AUTHOR_NAME\n+warning: old COMMIT_AUTHOR_EMAIL => new GIT_COMMITTER_EMAIL\n+warning: old COMMIT_AUTHOR_NAME => new GIT_COMMITTER_NAME\n+warning: old SHA1_FILE_DIRECTORY => new GIT_OBJECT_DIRECTORY\n+EOF\n+sed -ne '/^warning: /p' <errmsg >generated-err\n+test_debug 'cat errmsg'\n+test_expect_success 'cmp generated-err expected-err'\n+\n+test_debug 'echo with new variables exported.'\n+\n+for ev in $env_vars\n+do\n+\tnew=$(expr \"$ev\" : '\\(.*\\):')\n+\told=$(expr \"$ev\" : '.*:\\(.*\\)')\n+\t# Build and eval the following:\n+\t# NEWENV=$OLDENV\n+\tevstr=\"$new=\\$$old\"\n+\teval \"$evstr\"\n+done\n+export_them\n+echo 'foo' | git-commit-tree $tree >/dev/null 2>errmsg\n+sed -ne '/^warning: /p' <errmsg >generated-err\n+test_debug 'cat errmsg'\n+test_expect_success 'cmp generated-err /dev/null'\n+\n+test_done\n--- a/t/t0200-update-cache.sh\n+++ b/t/t0200-update-cache.sh\n@@ -0,0 +1,47 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+\n+test_description='git-update-cache nonsense-path test.\n+\n+This test creates the following structure in the cache:\n+\n+    path0       - a file\n+    path1       - a symlink\n+    path2/file2 - a file in a directory\n+    path3/file3 - a file in a directory\n+\n+and tries to git-update-cache --add the following:\n+\n+    path0/file0 - a file in a directory\n+    path1/file1 - a file in a directory\n+    path2       - a file\n+    path3       - a symlink\n+\n+All of the attempts should fail.\n+'\n+\n+. ./test-lib.sh\n+\n+mkdir path2 path3\n+date >path0\n+ln -s xyzzy path1\n+date >path2/file2\n+date >path3/file3\n+\n+git-update-cache --add -- path0 path1 path2/file2 path3/file3\n+\n+rm -fr path?\n+\n+mkdir path0 path1\n+date >path2\n+ln -s frotz path3\n+date >path0/file0\n+date >path1/file1\n+\n+for p in path0/file0 path1/file1 path2 path3\n+do\n+\ttest_expect_failure \"git-update-cache --add -- $p\"\n+done\n+test_done\n--- a/t/t0400-ls-files.sh\n+++ b/t/t0400-ls-files.sh\n@@ -0,0 +1,29 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+\n+test_description='git-ls-files test (--others should pick up symlinks).\n+\n+This test runs git-ls-files --others with the following on the\n+filesystem.\n+\n+    path0       - a file\n+    path1\t- a symlink\n+    path2/file2 - a file in a directory\n+'\n+. ./test-lib.sh\n+\n+date >path0\n+ln -s xyzzy path1\n+mkdir path2\n+date >path2/file2\n+git-ls-files --others >.output\n+cat >.expected <<EOF\n+path0\n+path1\n+path2/file2\n+EOF\n+\n+test_expect_success 'diff .output .expected'\n+test_done\n--- a/t/t0500-ls-files.sh\n+++ b/t/t0500-ls-files.sh\n@@ -0,0 +1,55 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+\n+test_description='git-ls-files -k flag test.\n+\n+This test prepares the following in the cache:\n+\n+    path0       - a file\n+    path1       - a symlink\n+    path2/file2 - a file in a directory\n+    path3/file3 - a file in a directory\n+\n+and the following on the filesystem:\n+\n+    path0/file0 - a file in a directory\n+    path1/file1 - a file in a directory\n+    path2       - a file\n+    path3       - a symlink\n+    path4\t- a file\n+    path5\t- a symlink\n+    path6/file6 - a file in a directory\n+\n+git-ls-files -k should report that existing filesystem\n+objects except path4, path5 and path6/file6 to be killed.\n+'\n+. ./test-lib.sh\n+\n+date >path0\n+ln -s xyzzy path1\n+mkdir path2 path3\n+date >path2/file2\n+date >path3/file3\n+git-update-cache --add -- path0 path1 path?/file?\n+\n+rm -fr path?\n+date >path2\n+ln -s frotz path3\n+ln -s nitfol path5\n+mkdir path0 path1 path6\n+date >path0/file0\n+date >path1/file1\n+date >path6/file6\n+\n+git-ls-files -k >.output\n+cat >.expected <<EOF\n+path0/file0\n+path1/file1\n+path2\n+path3\n+EOF\n+\n+test_expect_success 'diff .output .expected'\n+test_done\n--- a/t/t1000-checkout-cache.sh\n+++ b/t/t1000-checkout-cache.sh\n@@ -0,0 +1,54 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+\n+test_description='git-checkout-cache test.\n+\n+This test registers the following filesystem structure in the\n+cache:\n+\n+    path0       - a file\n+    path1/file1 - a file in a directory\n+\n+And then tries to checkout in a work tree that has the following:\n+\n+    path0/file0 - a file in a directory\n+    path1       - a file\n+\n+The git-checkout-cache command should fail when attempting to checkout\n+path0, finding it is occupied by a directory, and path1/file1, finding\n+path1 is occupied by a non-directory.  With \"-f\" flag, it should remove\n+the conflicting paths and succeed.\n+'\n+. ./test-lib.sh\n+\n+date >path0\n+mkdir path1\n+date >path1/file1\n+git-update-cache --add path0 path1/file1\n+test_debug 'git-ls-files --stage'\n+\n+rm -fr path0 path1\n+mkdir path0\n+date >path0/file0\n+date >path1\n+test_debug 'git-ls-files --stage'\n+test_debug 'find path*'\n+\n+test_expect_failure 'git-checkout-cache -a'\n+test_debug 'find path*'\n+\n+test_expect_success 'git-checkout-cache -f -a'\n+test_debug 'find path*'\n+\n+if test -f path0 && test -d path1 && test -f path1/file1\n+then\n+\ttest_ok \"checkout successful\"\n+else\n+\ttest_failure \"checkout failed\"\n+fi\n+\n+test_done\n+\n+\n--- a/t/t1001-checkout-cache.sh\n+++ b/t/t1001-checkout-cache.sh\n@@ -0,0 +1,76 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+\n+test_description='git-checkout-cache test.\n+\n+This test registers the following filesystem structure in the cache:\n+\n+    path0/file0\t- a file in a directory\n+    path1/file1 - a file in a directory\n+\n+and attempts to check it out when the work tree has:\n+\n+    path0/file0 - a file in a directory\n+    path1       - a symlink pointing at \"path0\"\n+\n+Checkout cache should fail to extract path1/file1 because the leading\n+path path1 is occupied by a non-directory.  With \"-f\" it should remove\n+the symlink path1 and create directory path1 and file path1/file1.\n+'\n+. ./test-lib.sh\n+\n+show_files() {\n+\t# show filesystem files, just [-dl] for type and name\n+\tfind path? -ls |\n+\tsed -e 's/^[0-9]* * [0-9]* * \\([-bcdl]\\)[^ ]* *[0-9]* *[^ ]* *[^ ]* *[0-9]* [A-Z][a-z][a-z] [0-9][0-9] [^ ]* /fs: \\1 /'\n+\t# what's in the cache, just mode and name\n+\tgit-ls-files --stage |\n+\tsed -e 's/^\\([0-9]*\\) [0-9a-f]* [0-3] /ca: \\1 /'\n+\t# what's in the tree, just mode and name.\n+\tgit-ls-tree -r \"$1\" |\n+\tsed -e 's/^\\([0-9]*\\)\t[^ ]*\t[0-9a-f]*\t/tr: \\1 /'\n+}\n+\n+mkdir path0\n+date >path0/file0\n+git-update-cache --add path0/file0\n+tree1=$(git-write-tree)\n+test_debug 'show_files $tree1'\n+\n+mkdir path1\n+date >path1/file1\n+git-update-cache --add path1/file1\n+tree2=$(git-write-tree)\n+test_debug 'show_files $tree2'\n+\n+rm -fr path1\n+git-read-tree -m $tree1\n+git-checkout-cache -f -a\n+test_debug 'show_files $tree1'\n+\n+ln -s path0 path1\n+git-update-cache --add path1\n+tree3=$(git-write-tree)\n+test_debug 'show_files $tree3'\n+\n+# Morten says \"Got that?\" here.\n+# Test begins.\n+\n+git-read-tree $tree2\n+test_expect_success 'git-checkout-cache -f -a'\n+test_debug show_files $tree2\n+\n+if test ! -h path0 && test -d path0 &&\n+   test ! -h path1 && test -d path1 &&\n+   test ! -h path0/file0 && test -f path0/file0 &&\n+   test ! -h path1/file1 && test -f path1/file1\n+then\n+    test_ok \"checked out correctly.\"\n+else\n+    test_failure \"did not check out correctly.\"\n+fi\n+\n+test_done\n+\n------------------------------------------------\n\n"}]}