Skip to contentSkip to conversation

Add option --path to allow to run tests with real systems

PATCH In review Nguyễn Thái Ngọc Duy 3 participants 5 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add option --path to allow to run tests with real systems

---
As we have decided to move git-* to gitexecdir, we should make sure it works.

I'm running tests with --path now and saw some errors. Some of them could be from bugs of this patch. I haven't looked into them yet.

 t/lib-git-svn.sh          |    2 +-
 t/t0000-basic.sh          |    6 +++---
 t/t0040-parse-options.sh  |   16 ++++++++--------
 t/t4200-rerere.sh         |    8 ++++----
 t/t5301-sliding-window.sh |    2 +-
 t/t5302-pack-index.sh     |    4 ++--
 t/test-lib.sh             |   18 ++++++++++++++----
 7 files changed, 33 insertions(+), 23 deletions(-)
t/lib-git-svn.sh +1 -1
index 8d4a447..fd60ebc 100644
@@ -46,7 +46,7 @@ rawsvnrepo="$svnrepo"
 svnrepo="file://$svnrepo"
 
 poke() {
-	test-chmtime +1 "$1"
+	$GIT_TEST_PATH/test-chmtime +1 "$1"
 }
 
 SVN_HTTPD_MODULE_PATH=${SVN_HTTPD_MODULE_PATH-'/usr/lib/apache2/modules'}
t/t0000-basic.sh +3 -3
index 4e49d59..f809163 100755
@@ -289,12 +289,12 @@ test_expect_success 'absolute path works as expected' '
 	mkdir third &&
 	dir="$(cd .git; pwd -P)" &&
 	dir2=third/../second/other/.git &&
-	test "$dir" = "$(test-absolute-path $dir2)" &&
+	test "$dir" = "$($GIT_TEST_PATH/test-absolute-path $dir2)" &&
 	file="$dir"/index &&
-	test "$file" = "$(test-absolute-path $dir2/index)" &&
+	test "$file" = "$($GIT_TEST_PATH/test-absolute-path $dir2/index)" &&
 	ln -s ../first/file .git/syml &&
 	sym="$(cd first; pwd -P)"/file &&
-	test "$sym" = "$(test-absolute-path $dir2/syml)"
+	test "$sym" = "$($GIT_TEST_PATH/test-absolute-path $dir2/syml)"
 '
 
 test_done
t/t0040-parse-options.sh +8 -8
index 462fdf2..ca1cc9f 100755
@@ -23,7 +23,7 @@ string options
 EOF
 
 test_expect_success 'test help' '
-	! test-parse-options -h > output 2> output.err &&
+	! $GIT_TEST_PATH/test-parse-options -h > output 2> output.err &&
 	test ! -s output &&
 	git diff expect.err output.err
 '
@@ -35,7 +35,7 @@ string: 123
 EOF
 
 test_expect_success 'short options' '
-	test-parse-options -s123 -b -i 1729 -b > output 2> output.err &&
+	$GIT_TEST_PATH/test-parse-options -s123 -b -i 1729 -b > output 2> output.err &&
 	git diff expect output &&
 	test ! -s output.err
 '
@@ -46,7 +46,7 @@ string: 321
 EOF
 
 test_expect_success 'long options' '
-	test-parse-options --boolean --integer 1729 --boolean --string2=321 \
+	$GIT_TEST_PATH/test-parse-options --boolean --integer 1729 --boolean --string2=321 \
 		> output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
@@ -62,7 +62,7 @@ arg 02: --boolean
 EOF
 
 test_expect_success 'intermingled arguments' '
-	test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
+	$GIT_TEST_PATH/test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
 		> output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
@@ -75,19 +75,19 @@ string: (not set)
 EOF
 
 test_expect_success 'unambiguously abbreviated option' '
-	test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
+	$GIT_TEST_PATH/test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
 '
 
 test_expect_success 'unambiguously abbreviated option with "="' '
-	test-parse-options --int=2 > output 2> output.err &&
+	$GIT_TEST_PATH/test-parse-options --int=2 > output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
 '
 
 test_expect_failure 'ambiguously abbreviated option' '
-	test-parse-options --strin 123;
+	$GIT_TEST_PATH/test-parse-options --strin 123;
         test $? != 129
 '
 
@@ -98,7 +98,7 @@ string: 123
 EOF
 
 test_expect_success 'non ambiguous option (after two options it abbreviates)' '
-	test-parse-options --st 123 > output 2> output.err &&
+	$GIT_TEST_PATH/test-parse-options --st 123 > output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
 '
t/t4200-rerere.sh +4 -4
index cfcdb69..ddbae1d 100755
@@ -149,16 +149,16 @@ just_over_15_days_ago=$((-1-15*86400))
 almost_60_days_ago=$((60-60*86400))
 just_over_60_days_ago=$((-1-60*86400))
 
-test-chmtime =$almost_60_days_ago $rr/preimage
-test-chmtime =$almost_15_days_ago $rr2/preimage
+$GIT_TEST_PATH/test-chmtime =$almost_60_days_ago $rr/preimage
+$GIT_TEST_PATH/test-chmtime =$almost_15_days_ago $rr2/preimage
 
 test_expect_success 'garbage collection (part1)' 'git rerere gc'
 
 test_expect_success 'young records still live' \
 	"test -f $rr/preimage && test -f $rr2/preimage"
 
-test-chmtime =$just_over_60_days_ago $rr/preimage
-test-chmtime =$just_over_15_days_ago $rr2/preimage
+$GIT_TEST_PATH/test-chmtime =$just_over_60_days_ago $rr/preimage
+$GIT_TEST_PATH/test-chmtime =$just_over_15_days_ago $rr2/preimage
 
 test_expect_success 'garbage collection (part2)' 'git rerere gc'
 
t/t5301-sliding-window.sh +1 -1
index 073ac0c..8327051 100755
@@ -12,7 +12,7 @@ test_expect_success \
      for i in a b c
      do
          echo $i >$i &&
-         test-genrandom "$i" 32768 >>$i &&
+         $GIT_TEST_PATH/test-genrandom "$i" 32768 >>$i &&
          git update-index --add $i || return 1
      done &&
      echo d >d && cat c >>d && git update-index --add d &&
t/t5302-pack-index.sh +2 -2
index 2a2878b..0ae9cd8 100755
@@ -15,11 +15,11 @@ test_expect_success \
      do
 		 i=`printf '%03i' $i`
          echo $i >file_$i &&
-         test-genrandom "$i" 8192 >>file_$i &&
+         $GIT_TEST_PATH/test-genrandom "$i" 8192 >>file_$i &&
          git update-index --add file_$i &&
 		 i=`expr $i + 1` || return 1
      done &&
-     { echo 101 && test-genrandom 100 8192; } >file_101 &&
+     { echo 101 && $GIT_TEST_PATH/test-genrandom 100 8192; } >file_101 &&
      git update-index --add file_101 &&
      tree=`git write-tree` &&
      commit=`git commit-tree $tree </dev/null` && {
t/test-lib.sh +14 -4
index 90b6844..50a3551 100644
@@ -84,6 +84,8 @@ do
 	--no-python)
 		# noop now...
 		shift ;;
+	--path=*)
+		path="${1#*=}"; shift ;;
 	*)
 		break ;;
 	esac
@@ -296,11 +298,19 @@ test_done () {
 
 # Test the binaries we have just built.  The tests are kept in
 # t/ subdirectory and are run in trash subdirectory.
-PATH=$(pwd)/..:$PATH
-GIT_EXEC_PATH=$(pwd)/..
+if [ -n "$path" ]; then
+	[ -x "$path/git" ] || error "git not found in $path"
+	PATH="$path":$PATH
+	export PATH
+	GIT_EXEC_PATH="$(git --exec-path)"
+else
+	PATH=$(pwd)/..:$PATH
+	GIT_EXEC_PATH=$(pwd)/..
+fi
+GIT_TEST_PATH=$(pwd)/..
 GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
 GIT_CONFIG=.git/config
-export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG
+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG GIT_TEST_PATH
 
 GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
 export GITPERLLIB
@@ -308,7 +318,7 @@ test -d ../templates/blt || {
 	error "You haven't built things yet, have you?"
 }
 
-if ! test -x ../test-chmtime; then
+if ! test -x $GIT_TEST_PATH/test-chmtime; then
 	echo >&2 'You need to build test-chmtime:'
 	echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
 	exit 1
Signature · 1 line
1.5.3.6.2040.gcdff-dirty
#1 lore raw
Quoted 14 lines · Nguyễn Thái Ngọc Duy
t/test-lib.sh +2 -0
index 90b6844..50a3551 100644
@@ -84,6 +84,8 @@ do
 	--no-python)
 		# noop now...
 		shift ;;
+	--path=*)
+		path="${1#*=}"; shift ;;
 	*)
 		break ;;
 	esac

t/test-lib.sh test_done () { · line 305

Quoted 10 lines
t/test-lib.sh +5 -2
@@ -296,11 +298,19 @@ test_done () {
 
 # Test the binaries we have just built.  The tests are kept in
 # t/ subdirectory and are run in trash subdirectory.
-PATH=$(pwd)/..:$PATH
-GIT_EXEC_PATH=$(pwd)/..
+if [ -n "$path" ]; then
+	[ -x "$path/git" ] || error "git not found in $path"
+	PATH="$path":$PATH
+	export PATH
+	GIT_EXEC_PATH="$(git --exec-path)"

This is wrong, isn't it? $path may point at the freshly built but not installed git executable, but it reports --exec-path the location that git-foo and friends are to be _eventually_ installed, not the location they are sitting after built, being tested, waiting to be installed.

#2 lore raw

PATCH 1/1 Add option --path to allow to run tests with real systems. You must install git before running this test.

---

Quoted 8 lines · Nguyen Thai Ngoc Duy
Quoted 5 lines · Junio C Hamano

This is wrong, isn't it? $path may point at the freshly built but not installed git executable, but it reports --exec-path the location that git-foo and friends are to be _eventually_ installed, not the location they are sitting after built, being tested, waiting to be installed.

Yes, forgot to mention you must do "make install" first :)

Perhaps a check to remind people to 'make install' like this?

 t/lib-git-svn.sh          |    2 +-
 t/t0000-basic.sh          |    6 +++---
 t/t0040-parse-options.sh  |   16 ++++++++--------
 t/t4200-rerere.sh         |    8 ++++----
 t/t5301-sliding-window.sh |    2 +-
 t/t5302-pack-index.sh     |    4 ++--
 t/test-lib.sh             |   19 +++++++++++++++----
 7 files changed, 34 insertions(+), 23 deletions(-)
t/lib-git-svn.sh +1 -1
index 8d4a447..fd60ebc 100644
@@ -46,7 +46,7 @@ rawsvnrepo="$svnrepo"
 svnrepo="file://$svnrepo"
 
 poke() {
-	test-chmtime +1 "$1"
+	$GIT_TEST_PATH/test-chmtime +1 "$1"
 }
 
 SVN_HTTPD_MODULE_PATH=${SVN_HTTPD_MODULE_PATH-'/usr/lib/apache2/modules'}
t/t0000-basic.sh +3 -3
index 4e49d59..f809163 100755
@@ -289,12 +289,12 @@ test_expect_success 'absolute path works as expected' '
 	mkdir third &&
 	dir="$(cd .git; pwd -P)" &&
 	dir2=third/../second/other/.git &&
-	test "$dir" = "$(test-absolute-path $dir2)" &&
+	test "$dir" = "$($GIT_TEST_PATH/test-absolute-path $dir2)" &&
 	file="$dir"/index &&
-	test "$file" = "$(test-absolute-path $dir2/index)" &&
+	test "$file" = "$($GIT_TEST_PATH/test-absolute-path $dir2/index)" &&
 	ln -s ../first/file .git/syml &&
 	sym="$(cd first; pwd -P)"/file &&
-	test "$sym" = "$(test-absolute-path $dir2/syml)"
+	test "$sym" = "$($GIT_TEST_PATH/test-absolute-path $dir2/syml)"
 '
 
 test_done
t/t0040-parse-options.sh +8 -8
index 462fdf2..ca1cc9f 100755
@@ -23,7 +23,7 @@ string options
 EOF
 
 test_expect_success 'test help' '
-	! test-parse-options -h > output 2> output.err &&
+	! $GIT_TEST_PATH/test-parse-options -h > output 2> output.err &&
 	test ! -s output &&
 	git diff expect.err output.err
 '
@@ -35,7 +35,7 @@ string: 123
 EOF
 
 test_expect_success 'short options' '
-	test-parse-options -s123 -b -i 1729 -b > output 2> output.err &&
+	$GIT_TEST_PATH/test-parse-options -s123 -b -i 1729 -b > output 2> output.err &&
 	git diff expect output &&
 	test ! -s output.err
 '
@@ -46,7 +46,7 @@ string: 321
 EOF
 
 test_expect_success 'long options' '
-	test-parse-options --boolean --integer 1729 --boolean --string2=321 \
+	$GIT_TEST_PATH/test-parse-options --boolean --integer 1729 --boolean --string2=321 \
 		> output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
@@ -62,7 +62,7 @@ arg 02: --boolean
 EOF
 
 test_expect_success 'intermingled arguments' '
-	test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
+	$GIT_TEST_PATH/test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
 		> output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
@@ -75,19 +75,19 @@ string: (not set)
 EOF
 
 test_expect_success 'unambiguously abbreviated option' '
-	test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
+	$GIT_TEST_PATH/test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
 '
 
 test_expect_success 'unambiguously abbreviated option with "="' '
-	test-parse-options --int=2 > output 2> output.err &&
+	$GIT_TEST_PATH/test-parse-options --int=2 > output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
 '
 
 test_expect_failure 'ambiguously abbreviated option' '
-	test-parse-options --strin 123;
+	$GIT_TEST_PATH/test-parse-options --strin 123;
         test $? != 129
 '
 
@@ -98,7 +98,7 @@ string: 123
 EOF
 
 test_expect_success 'non ambiguous option (after two options it abbreviates)' '
-	test-parse-options --st 123 > output 2> output.err &&
+	$GIT_TEST_PATH/test-parse-options --st 123 > output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
 '
t/t4200-rerere.sh +4 -4
index cfcdb69..ddbae1d 100755
@@ -149,16 +149,16 @@ just_over_15_days_ago=$((-1-15*86400))
 almost_60_days_ago=$((60-60*86400))
 just_over_60_days_ago=$((-1-60*86400))
 
-test-chmtime =$almost_60_days_ago $rr/preimage
-test-chmtime =$almost_15_days_ago $rr2/preimage
+$GIT_TEST_PATH/test-chmtime =$almost_60_days_ago $rr/preimage
+$GIT_TEST_PATH/test-chmtime =$almost_15_days_ago $rr2/preimage
 
 test_expect_success 'garbage collection (part1)' 'git rerere gc'
 
 test_expect_success 'young records still live' \
 	"test -f $rr/preimage && test -f $rr2/preimage"
 
-test-chmtime =$just_over_60_days_ago $rr/preimage
-test-chmtime =$just_over_15_days_ago $rr2/preimage
+$GIT_TEST_PATH/test-chmtime =$just_over_60_days_ago $rr/preimage
+$GIT_TEST_PATH/test-chmtime =$just_over_15_days_ago $rr2/preimage
 
 test_expect_success 'garbage collection (part2)' 'git rerere gc'
 
t/t5301-sliding-window.sh +1 -1
index 073ac0c..8327051 100755
@@ -12,7 +12,7 @@ test_expect_success \
      for i in a b c
      do
          echo $i >$i &&
-         test-genrandom "$i" 32768 >>$i &&
+         $GIT_TEST_PATH/test-genrandom "$i" 32768 >>$i &&
          git update-index --add $i || return 1
      done &&
      echo d >d && cat c >>d && git update-index --add d &&
t/t5302-pack-index.sh +2 -2
index 2a2878b..0ae9cd8 100755
@@ -15,11 +15,11 @@ test_expect_success \
      do
 		 i=`printf '%03i' $i`
          echo $i >file_$i &&
-         test-genrandom "$i" 8192 >>file_$i &&
+         $GIT_TEST_PATH/test-genrandom "$i" 8192 >>file_$i &&
          git update-index --add file_$i &&
 		 i=`expr $i + 1` || return 1
      done &&
-     { echo 101 && test-genrandom 100 8192; } >file_101 &&
+     { echo 101 && $GIT_TEST_PATH/test-genrandom 100 8192; } >file_101 &&
      git update-index --add file_101 &&
      tree=`git write-tree` &&
      commit=`git commit-tree $tree </dev/null` && {
t/test-lib.sh +15 -4
index 90b6844..97c0f4d 100644
@@ -84,6 +84,8 @@ do
 	--no-python)
 		# noop now...
 		shift ;;
+	--path=*)
+		path="${1#*=}"; shift ;;
 	*)
 		break ;;
 	esac
@@ -296,11 +298,20 @@ test_done () {
 
 # Test the binaries we have just built.  The tests are kept in
 # t/ subdirectory and are run in trash subdirectory.
-PATH=$(pwd)/..:$PATH
-GIT_EXEC_PATH=$(pwd)/..
+if [ -n "$path" ]; then
+	[ -x "$path/git" ] || error "git not found in $path"
+	[ "$($path/git --version)" = "$(../git --version)" ] ||
+		error "Version mismatch. Did you forget to 'make install'?"
+	PATH="$path":$PATH
+	GIT_EXEC_PATH="$($path/git --exec-path)"
+else
+	PATH=$(pwd)/..:$PATH
+	GIT_EXEC_PATH=$(pwd)/..
+fi
+GIT_TEST_PATH=$(pwd)/..
 GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
 GIT_CONFIG=.git/config
-export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG
+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG GIT_TEST_PATH
 
 GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
 export GITPERLLIB
@@ -308,7 +319,7 @@ test -d ../templates/blt || {
 	error "You haven't built things yet, have you?"
 }
 
-if ! test -x ../test-chmtime; then
+if ! test -x $GIT_TEST_PATH/test-chmtime; then
 	echo >&2 'You need to build test-chmtime:'
 	echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
 	exit 1
Signature · 1 line
1.5.3.6.2040.gfc2f-dirty
#3 lore raw

Re: [PATCH] Add option --path to allow to run tests with real systems. You must install git before running this test.

Hi,

Quoted 9 lines · Nguyễn Thái Ngọc Duy

---

Quoted 6 lines · Nguyen Thai Ngoc Duy
Quoted 5 lines · Junio C Hamano

This is wrong, isn't it? $path may point at the freshly built but not installed git executable, but it reports --exec-path the location that git-foo and friends are to be _eventually_ installed, not the location they are sitting after built, being tested, waiting to be installed.

Quoted 4 lines
Quoted 2 lines

Yes, forgot to mention you must do "make install" first :)

Perhaps a check to remind people to 'make install' like this?

Well, the whole point of "make test" is to be sure that it works before installing it.

How about something completely different?

-- snipsnap --

 t/test-lib.sh |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
t/test-lib.sh +12 -1
index 90b6844..ee87b83 100644
@@ -296,7 +296,18 @@ test_done () {
 
 # Test the binaries we have just built.  The tests are kept in
 # t/ subdirectory and are run in trash subdirectory.
-PATH=$(pwd)/..:$PATH
+
+# Test libexec, while we are at it
+
+test -d test-bin || mkdir test-bin || error "t/test-bin/ could not be created"
+for file in ../git ../git-sh-setup ../test-*
+do
+	target=test-bin/"$(basename "$filename")"
+	test -x "$file" && test ! -x "$target" &&
+		ln -s ../"$file" test-bin/
+done
+
+PATH=$(pwd)/test-bin:$PATH
 GIT_EXEC_PATH=$(pwd)/..
 GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
 GIT_CONFIG=.git/config

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Re: [PATCH] Add option --path to allow to run tests with real systems. You must install git before running this test.

Hi,

Quoted 19 lines · Nguyen Thai Ngoc Duy
Quoted 18 lines · Johannes Schindelin

Hi,

Quoted 13 lines · Nguyễn Thái Ngọc Duy

---

Quoted 8 lines · Nguyen Thai Ngoc Duy
Quoted 5 lines · Junio C Hamano

This is wrong, isn't it? $path may point at the freshly built but not installed git executable, but it reports --exec-path the location that git-foo and friends are to be _eventually_ installed, not the location they are sitting after built, being tested, waiting to be installed.

Yes, forgot to mention you must do "make install" first :)

Perhaps a check to remind people to 'make install' like this?

Quoted 8 lines
Quoted 4 lines

Well, the whole point of "make test" is to be sure that it works before installing it.

How about something completely different?

I still think testing another round after installing is good. But that's not my aim. So Ack on your patch (at least the idea because I have not used it yet).

No, I think that testing after installing is way too late.

BTW there was no sign-off on my patch (as well as no commit message), because it does not work on symbolic-link-challenged systems. So it was purely meant as inspiration.

Ciao,
Dscho