Re: [PATCH 1/2] git submodule: Add test cases for git submodule add

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx> writes:

> diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
> index b8cb2df..b154050 100755
> --- a/t/t7400-submodule-basic.sh
> +++ b/t/t7400-submodule-basic.sh
> @@ -47,6 +47,25 @@ test_expect_success 'Prepare submodule testing' '
>  	GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
>  '

Please don't chdir around in individual tests.  Instead have each test
begin and end in the original directory given.  Like:

> +test_expect_success 'Prepare submodule add testing' '
> +	submodurl=$(pwd)
> +	mkdir addtest &&
> +	pushd addtest &&
> +	git init
> +'

	(
        	mkdir addtest &&
                cd addtest &&
                git init
	)

> +test_expect_success 'submodule add' '
> +	git submodule add "$submodurl" submod &&
> +	git submodule init
> +'

	(
        	cd addtest &&
                git submodule add ...
	)                

> +test_expect_failure 'submodule add with ./ in path' '
> +	git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
> +	git submodule init
> +'
> +# end of submodule add testing
> +popd >/dev/null

The rule of thumb is minimize things done outside of tests, like this
popd.

This is to prevent mistaken test sequence to go up too many levels.  E.g.
an earlier test that is supposed to chdir down and make the subsequent
tests begin at one level deeper than the original could fail, but when
tests are run without the "-i" option, the failed test would not abort the
whole sequence.  The subsequent tests run in a wrong place, and one of
them would try to chdir up to come back to the original directory, but
their "cd .." will go up too high, because the first chdir that tried to
go down failed.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux