Re: [PATCH] Move test-* to t/helper/ subdirectory

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

 



On Sun, May 01, 2016 at 07:28:52AM +0700, Duy Nguyen wrote:
> On Wed, Apr 27, 2016 at 09:15:41AM -0700, Junio C Hamano wrote:
> > Duy Nguyen <pclouds@xxxxxxxxx> writes:
> > 
> > > This patch forces bin-wrappers regeneration every time a test program
> > > is updated. A bit wasteful, but I don't see a better option (which is
> > > also why I limit this to test programs only).
> > 
> > In other words, when we update the location where the programs that
> > would be eventually installed are created, we'd see the same
> > problem.
> > 
> > I actually wonder if it is a better overall structure to move
> > t/helper/test-foo back to test-foo, while keeping the source file
> > that contains main() for test-foo at t/helper/test-foo.c.  Then we
> > do not have to have many copies that are slightly different in
> > bin-wrappers, but they can all be
> > 
> > 	exec "${GIT_EXEC_PATH}/$0" "$@"
> > 
> > instead of "bin-wrappers/git-bar" being
> > 
> > 	exec "${GIT_EXEC_PATH}/git-bar" "$@"
> > 
> > and "bin-wrappers/test-foo" being
> > 
> > 	exec "${GIT_EXEC_PATH}/t/helper/test-foo" "$@"
> > 
> 
> It's not a perfect solution (rebuild bin-wrappers when the real binary
> moves) but I think it's the best option so far.

I may have rushed to judgement. wrap-for-bin.sh has always been the
dependency for bin-wrappers/*. If we force that file to change, then
bin-wrappers/* will be recreated when switching branches. So how about
this?

-- 8< --
Subject: [PATCH] wrap-for-bin.sh: handle t/helper/ paths internally

Commit e6e7530 (test helpers: move test-* to t/helper/ subdirectory -
2016-04-13) moves test-* to t/helper. However because bin-wrappers/*
only depend on wrap-for-bin.sh, when switching between a branch that has
this commit and one that does not, bin-wrappers/* may not be regenerated
and point to the old/outdated test programs. Fix it by force updating
wrap-for-bin.sh so that it will be regenerated anyway.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 Makefile        |  2 +-
 wrap-for-bin.sh | 12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index dd178ee..38dcdf7 100644
--- a/Makefile
+++ b/Makefile
@@ -2204,7 +2204,7 @@ bin-wrappers/%: wrap-for-bin.sh
 	@mkdir -p bin-wrappers
 	$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 	     -e 's|@@BUILD_DIR@@|$(shell pwd)|' \
-	     -e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))|' < $< > $@ && \
+	     -e 's|@@PROG@@|$(@F)|' < $< > $@ && \
 	chmod +x $@
 
 # GNU make supports exporting all variables by "export" without parameters.
diff --git a/wrap-for-bin.sh b/wrap-for-bin.sh
index db0ec6a..bb334ed 100644
--- a/wrap-for-bin.sh
+++ b/wrap-for-bin.sh
@@ -18,11 +18,19 @@ GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'"${GITPERLLIB:+:$GITPERLLIB}"
 GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'
 PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
 export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
+case "@@PATH@@" in
+    test-*)
+	PROG="${GIT_EXEC_PATH}/t/helper/@@PROG@@"
+	;;
+    *)
+	PROG="${GIT_EXEC_PATH}/@@PROG@@"
+	;;
+esac
 
 if test -n "$GIT_TEST_GDB"
 then
 	unset GIT_TEST_GDB
-	exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec gdb --args "$PROG" "$@"
 else
-	exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+	exec "$PROG" "$@"
 fi
-- 
2.8.0.rc0.210.gd302cd2
-- 8< --
--
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]