From: Junio C Hamano Date: Tue, 24 Jul 2012 14:47:59 GMT Subject: Re: [PATCH] test: some testcases failed if cwd is on a symlink Message-ID: <7vboj5gqqo.fsf@alter.siamese.dyndns.org> In-Reply-To: <001c60538df409d94618e80cc3faaae586ccf053.1343116581.git.worldhello.net@gmail.com> Jiang Xin writes: > Run command 'git rev-parse --git-dir' under subdir will return realpath > of '.git' directory. Some test scripts compare this realpath against > "$TRASH_DIRECTORY", they are not equal if current working directory is > on a symlink. > > In this fix, get realpath of "$TRASH_DIRECTORY", store it in > "$TRASH_REALPATH" variable, and use it when necessary. I wonder if running test in a real directory (in other words, "fix" your cwd) may be a simpler, more robust and generally a better solution, e.g. something silly like... diff --git a/t/test-lib.sh b/t/test-lib.sh index acda33d..7f6fb0a 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/ . +cd "$(pwd -P)" + # if --tee was passed, write the output not only to the terminal, but # additionally to the file test-results/$BASENAME.out, too. case "$GIT_TEST_TEE_STARTED, $* " in