From: Petr Baudis Date: Sat, 14 May 2005 23:34:22 +0000 (+0200) Subject: Rename some test scripts and describe the naming convention X-Git-Tag: v0.99~574 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=f50c9f76ca516051e9f7e7ef68d6a4d0f5830dda;p=git.git Rename some test scripts and describe the naming convention First digit: "family", e.g. the absolute basics and global stuff (0), the basic db-side commands (read-tree, write-tree, commit-tree), the basic working-tree-side commands (checkout-cache, update-cache), the other basic commands (ls-files), the diff commands, the pull commands, exporting commands, revision tree commands... Second digit: the particular command we are testing Third digit: (optionally) the particular switch or group of switches we are testing Freeform part: commandname-details Described in the README. mv t1000-checkout-cache.sh t2000-checkout-cache-clash.sh mv t1001-checkout-cache.sh t2001-checkout-cache-clash.sh mv t0200-update-cache.sh t2010-update-cache-badpath.sh mv t0400-ls-files.sh t3000-ls-files-others.sh mv t0500-ls-files.sh t3010-ls-files-killed.sh --- diff --git a/t/README b/t/README index fce19e7f..146e2619 100644 --- a/t/README +++ b/t/README @@ -55,6 +55,31 @@ You can pass --verbose (or -v), --debug (or -d), and --immediate failed test. +Naming Tests +------------ + +The test files are named as: + + tNNNN-commandname-details.sh + +where N is a decimal digit. + +First digit tells the family: + + 0 - the absolute basics and global stuff + 1 - the basic commands concerning database + 2 - the basic commands concerning the working tree + 3 - the other basic commands (e.g. ls-files) + 4 - the diff commands + 5 - the pull and exporting commands + 6 - the revision tree commands (even e.g. merge-base) + +Second digit tells the particular command we are testing. + +Third digit (optionally) tells the particular switch or group of switches +we are testing. + + Writing Tests ------------- @@ -72,6 +97,7 @@ assignment to variable 'test_description', like this: This test registers the following structure in the cache and tries to run git-ls-files with option --frotz.' + Source 'test-lib.sh' -------------------- @@ -94,7 +120,6 @@ This test harness library does the following things: consistently when command line arguments --verbose (or -v), --debug (or -d), and --immediate (or -i) is given. - End with test_done ------------------ diff --git a/t/t0200-update-cache.sh b/t/t0200-update-cache.sh deleted file mode 100755 index 86b7375c..00000000 --- a/t/t0200-update-cache.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2005 Junio C Hamano -# - -test_description='git-update-cache nonsense-path test. - -This test creates the following structure in the cache: - - path0 - a file - path1 - a symlink - path2/file2 - a file in a directory - path3/file3 - a file in a directory - -and tries to git-update-cache --add the following: - - path0/file0 - a file in a directory - path1/file1 - a file in a directory - path2 - a file - path3 - a symlink - -All of the attempts should fail. -' - -. ./test-lib.sh - -mkdir path2 path3 -date >path0 -ln -s xyzzy path1 -date >path2/file2 -date >path3/file3 - -test_expect_success \ - 'git-update-cache --add to add various paths.' \ - 'git-update-cache --add -- path0 path1 path2/file2 path3/file3' - -rm -fr path? - -mkdir path0 path1 -date >path2 -ln -s frotz path3 -date >path0/file0 -date >path1/file1 - -for p in path0/file0 path1/file1 path2 path3 -do - test_expect_failure \ - "git-update-cache to add conflicting path $p should fail." \ - "git-update-cache --add -- $p" -done -test_done diff --git a/t/t0400-ls-files.sh b/t/t0400-ls-files.sh deleted file mode 100755 index 7f93e1cc..00000000 --- a/t/t0400-ls-files.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2005 Junio C Hamano -# - -test_description='git-ls-files test (--others should pick up symlinks). - -This test runs git-ls-files --others with the following on the -filesystem. - - path0 - a file - path1 - a symlink - path2/file2 - a file in a directory -' -. ./test-lib.sh - -date >path0 -ln -s xyzzy path1 -mkdir path2 -date >path2/file2 -test_expect_success \ - 'git-ls-files --others to show output.' \ - 'git-ls-files --others >.output' -cat >.expected <path0 -ln -s xyzzy path1 -mkdir path2 path3 -date >path2/file2 -date >path3/file3 -test_expect_success \ - 'git-update-cache --add to add various paths.' \ - "git-update-cache --add -- path0 path1 path?/file?" - -rm -fr path? -date >path2 -ln -s frotz path3 -ln -s nitfol path5 -mkdir path0 path1 path6 -date >path0/file0 -date >path1/file1 -date >path6/file6 - -test_expect_success \ - 'git-ls-files -k to show killed files.' \ - 'git-ls-files -k >.output' -cat >.expected <path0 -mkdir path1 -date >path1/file1 - -test_expect_success \ - 'git-update-cache --add various paths.' \ - 'git-update-cache --add path0 path1/file1' - -rm -fr path0 path1 -mkdir path0 -date >path0/file0 -date >path1 - -test_expect_failure \ - 'git-checkout-cache without -f should fail on conflicting work tree.' \ - 'git-checkout-cache -a' - -test_expect_success \ - 'git-checkout-cache with -f should succeed.' \ - 'git-checkout-cache -f -a' - -test_expect_success \ - 'git-checkout-cache conflicting paths.' \ - 'test -f path0 && test -d path1 && test -f path1/file1' - -test_done - - diff --git a/t/t1001-checkout-cache.sh b/t/t1001-checkout-cache.sh deleted file mode 100755 index f0e3d1d8..00000000 --- a/t/t1001-checkout-cache.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2005 Junio C Hamano -# - -test_description='git-checkout-cache test. - -This test registers the following filesystem structure in the cache: - - path0/file0 - a file in a directory - path1/file1 - a file in a directory - -and attempts to check it out when the work tree has: - - path0/file0 - a file in a directory - path1 - a symlink pointing at "path0" - -Checkout cache should fail to extract path1/file1 because the leading -path path1 is occupied by a non-directory. With "-f" it should remove -the symlink path1 and create directory path1 and file path1/file1. -' -. ./test-lib.sh - -show_files() { - # show filesystem files, just [-dl] for type and name - find path? -ls | - sed -e 's/^[0-9]* * [0-9]* * \([-bcdl]\)[^ ]* *[0-9]* *[^ ]* *[^ ]* *[0-9]* [A-Z][a-z][a-z] [0-9][0-9] [^ ]* /fs: \1 /' - # what's in the cache, just mode and name - git-ls-files --stage | - sed -e 's/^\([0-9]*\) [0-9a-f]* [0-3] /ca: \1 /' - # what's in the tree, just mode and name. - git-ls-tree -r "$1" | - sed -e 's/^\([0-9]*\) [^ ]* [0-9a-f]* /tr: \1 /' -} - -mkdir path0 -date >path0/file0 -test_expect_success \ - 'git-update-cache --add path0/file0' \ - 'git-update-cache --add path0/file0' -test_expect_success \ - 'writing tree out with git-write-tree' \ - 'tree1=$(git-write-tree)' -test_debug 'show_files $tree1' - -mkdir path1 -date >path1/file1 -test_expect_success \ - 'git-update-cache --add path1/file1' \ - 'git-update-cache --add path1/file1' -test_expect_success \ - 'writing tree out with git-write-tree' \ - 'tree2=$(git-write-tree)' -test_debug 'show_files $tree2' - -rm -fr path1 -test_expect_success \ - 'read previously written tree and checkout.' \ - 'git-read-tree -m $tree1 && git-checkout-cache -f -a' -test_debug 'show_files $tree1' - -ln -s path0 path1 -test_expect_success \ - 'git-update-cache --add a symlink.' \ - 'git-update-cache --add path1' -test_expect_success \ - 'writing tree out with git-write-tree' \ - 'tree3=$(git-write-tree)' -test_debug 'show_files $tree3' - -# Morten says "Got that?" here. -# Test begins. - -test_expect_success \ - 'read previously written tree and checkout.' \ - 'git-read-tree $tree2 && git-checkout-cache -f -a' -test_debug show_files $tree2 - -test_expect_success \ - 'checking out conflicting path with -f' \ - 'test ! -h path0 && test -d path0 && - test ! -h path1 && test -d path1 && - test ! -h path0/file0 && test -f path0/file0 && - test ! -h path1/file1 && test -f path1/file1' - -test_done - diff --git a/t/t2000-checkout-cache-clash.sh b/t/t2000-checkout-cache-clash.sh new file mode 100755 index 00000000..a2c42602 --- /dev/null +++ b/t/t2000-checkout-cache-clash.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# +# Copyright (c) 2005 Junio C Hamano +# + +test_description='git-checkout-cache test. + +This test registers the following filesystem structure in the +cache: + + path0 - a file + path1/file1 - a file in a directory + +And then tries to checkout in a work tree that has the following: + + path0/file0 - a file in a directory + path1 - a file + +The git-checkout-cache command should fail when attempting to checkout +path0, finding it is occupied by a directory, and path1/file1, finding +path1 is occupied by a non-directory. With "-f" flag, it should remove +the conflicting paths and succeed. +' +. ./test-lib.sh + +date >path0 +mkdir path1 +date >path1/file1 + +test_expect_success \ + 'git-update-cache --add various paths.' \ + 'git-update-cache --add path0 path1/file1' + +rm -fr path0 path1 +mkdir path0 +date >path0/file0 +date >path1 + +test_expect_failure \ + 'git-checkout-cache without -f should fail on conflicting work tree.' \ + 'git-checkout-cache -a' + +test_expect_success \ + 'git-checkout-cache with -f should succeed.' \ + 'git-checkout-cache -f -a' + +test_expect_success \ + 'git-checkout-cache conflicting paths.' \ + 'test -f path0 && test -d path1 && test -f path1/file1' + +test_done + + diff --git a/t/t2001-checkout-cache-clash.sh b/t/t2001-checkout-cache-clash.sh new file mode 100755 index 00000000..f0e3d1d8 --- /dev/null +++ b/t/t2001-checkout-cache-clash.sh @@ -0,0 +1,87 @@ +#!/bin/sh +# +# Copyright (c) 2005 Junio C Hamano +# + +test_description='git-checkout-cache test. + +This test registers the following filesystem structure in the cache: + + path0/file0 - a file in a directory + path1/file1 - a file in a directory + +and attempts to check it out when the work tree has: + + path0/file0 - a file in a directory + path1 - a symlink pointing at "path0" + +Checkout cache should fail to extract path1/file1 because the leading +path path1 is occupied by a non-directory. With "-f" it should remove +the symlink path1 and create directory path1 and file path1/file1. +' +. ./test-lib.sh + +show_files() { + # show filesystem files, just [-dl] for type and name + find path? -ls | + sed -e 's/^[0-9]* * [0-9]* * \([-bcdl]\)[^ ]* *[0-9]* *[^ ]* *[^ ]* *[0-9]* [A-Z][a-z][a-z] [0-9][0-9] [^ ]* /fs: \1 /' + # what's in the cache, just mode and name + git-ls-files --stage | + sed -e 's/^\([0-9]*\) [0-9a-f]* [0-3] /ca: \1 /' + # what's in the tree, just mode and name. + git-ls-tree -r "$1" | + sed -e 's/^\([0-9]*\) [^ ]* [0-9a-f]* /tr: \1 /' +} + +mkdir path0 +date >path0/file0 +test_expect_success \ + 'git-update-cache --add path0/file0' \ + 'git-update-cache --add path0/file0' +test_expect_success \ + 'writing tree out with git-write-tree' \ + 'tree1=$(git-write-tree)' +test_debug 'show_files $tree1' + +mkdir path1 +date >path1/file1 +test_expect_success \ + 'git-update-cache --add path1/file1' \ + 'git-update-cache --add path1/file1' +test_expect_success \ + 'writing tree out with git-write-tree' \ + 'tree2=$(git-write-tree)' +test_debug 'show_files $tree2' + +rm -fr path1 +test_expect_success \ + 'read previously written tree and checkout.' \ + 'git-read-tree -m $tree1 && git-checkout-cache -f -a' +test_debug 'show_files $tree1' + +ln -s path0 path1 +test_expect_success \ + 'git-update-cache --add a symlink.' \ + 'git-update-cache --add path1' +test_expect_success \ + 'writing tree out with git-write-tree' \ + 'tree3=$(git-write-tree)' +test_debug 'show_files $tree3' + +# Morten says "Got that?" here. +# Test begins. + +test_expect_success \ + 'read previously written tree and checkout.' \ + 'git-read-tree $tree2 && git-checkout-cache -f -a' +test_debug show_files $tree2 + +test_expect_success \ + 'checking out conflicting path with -f' \ + 'test ! -h path0 && test -d path0 && + test ! -h path1 && test -d path1 && + test ! -h path0/file0 && test -f path0/file0 && + test ! -h path1/file1 && test -f path1/file1' + +test_done + diff --git a/t/t2010-update-cache-badpath.sh b/t/t2010-update-cache-badpath.sh new file mode 100755 index 00000000..86b7375c --- /dev/null +++ b/t/t2010-update-cache-badpath.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# +# Copyright (c) 2005 Junio C Hamano +# + +test_description='git-update-cache nonsense-path test. + +This test creates the following structure in the cache: + + path0 - a file + path1 - a symlink + path2/file2 - a file in a directory + path3/file3 - a file in a directory + +and tries to git-update-cache --add the following: + + path0/file0 - a file in a directory + path1/file1 - a file in a directory + path2 - a file + path3 - a symlink + +All of the attempts should fail. +' + +. ./test-lib.sh + +mkdir path2 path3 +date >path0 +ln -s xyzzy path1 +date >path2/file2 +date >path3/file3 + +test_expect_success \ + 'git-update-cache --add to add various paths.' \ + 'git-update-cache --add -- path0 path1 path2/file2 path3/file3' + +rm -fr path? + +mkdir path0 path1 +date >path2 +ln -s frotz path3 +date >path0/file0 +date >path1/file1 + +for p in path0/file0 path1/file1 path2 path3 +do + test_expect_failure \ + "git-update-cache to add conflicting path $p should fail." \ + "git-update-cache --add -- $p" +done +test_done diff --git a/t/t3000-ls-files-others.sh b/t/t3000-ls-files-others.sh new file mode 100755 index 00000000..7f93e1cc --- /dev/null +++ b/t/t3000-ls-files-others.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Copyright (c) 2005 Junio C Hamano +# + +test_description='git-ls-files test (--others should pick up symlinks). + +This test runs git-ls-files --others with the following on the +filesystem. + + path0 - a file + path1 - a symlink + path2/file2 - a file in a directory +' +. ./test-lib.sh + +date >path0 +ln -s xyzzy path1 +mkdir path2 +date >path2/file2 +test_expect_success \ + 'git-ls-files --others to show output.' \ + 'git-ls-files --others >.output' +cat >.expected <path0 +ln -s xyzzy path1 +mkdir path2 path3 +date >path2/file2 +date >path3/file3 +test_expect_success \ + 'git-update-cache --add to add various paths.' \ + "git-update-cache --add -- path0 path1 path?/file?" + +rm -fr path? +date >path2 +ln -s frotz path3 +ln -s nitfol path5 +mkdir path0 path1 path6 +date >path0/file0 +date >path1/file1 +date >path6/file6 + +test_expect_success \ + 'git-ls-files -k to show killed files.' \ + 'git-ls-files -k >.output' +cat >.expected <