Code

git submodule: Add test cases for git submodule add
authorMichael J Gruber <git@drmicha.warpmail.net>
Tue, 3 Mar 2009 15:08:20 +0000 (16:08 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Mar 2009 05:46:09 +0000 (21:46 -0800)
Add simple test cases for adding and initialising submodules. The
init step is necessary in order to verify the added information.

The second test exposes a known breakage due to './' in the path: git
ls-files simplifies the path but git add does not, which leads to git
init looking for different lines in .gitmodules than git add adds.

The other tests add test cases for '//' and '..' in the path which
currently fail for the same reason.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7400-submodule-basic.sh

index 2ec7ac6a510c5b83bc1ee6ce428379beb7a8b5ef..132d0b996375ed4b884df36b98a4460d7cc42c58 100755 (executable)
@@ -47,6 +47,55 @@ test_expect_success 'Prepare submodule testing' '
        GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
 '
 
+test_expect_success 'Prepare submodule add testing' '
+       submodurl=$(pwd)
+       (
+               mkdir addtest &&
+               cd addtest &&
+               git init
+       )
+'
+
+test_expect_success 'submodule add' '
+       (
+               cd addtest &&
+               git submodule add "$submodurl" submod &&
+               git submodule init
+       )
+'
+
+test_expect_failure 'submodule add with ./ in path' '
+       (
+               cd addtest &&
+               git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
+               git submodule init
+       )
+'
+
+test_expect_failure 'submodule add with // in path' '
+       (
+               cd addtest &&
+               git submodule add "$submodurl" slashslashsubmod///frotz// &&
+               git submodule init
+       )
+'
+
+test_expect_failure 'submodule add with /.. in path' '
+       (
+               cd addtest &&
+               git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
+               git submodule init
+       )
+'
+
+test_expect_failure 'submodule add with ./, /.. and // in path' '
+       (
+               cd addtest &&
+               git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. &&
+               git submodule init
+       )
+'
+
 test_expect_success 'status should fail for unmapped paths' '
        if git submodule status
        then