[pacman-dev] [PATCH] Add check() function for testsuites.
If this is an accepted feature, I can resend the patch with manpage updates. Signed-off-by: Jeff C <jeff@kcaccess.com> --- etc/makepkg.conf.in | 5 +++-- scripts/makepkg.sh.in | 24 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index f0d1c44..b3c4b4c 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -58,7 +58,7 @@ BUILDENV=(fakeroot !distcc color !ccache) # These are default values for the options=() settings ######################################################################### # -# Default: OPTIONS=(strip docs libtool emptydirs zipman purge) +# Default: OPTIONS=(strip docs libtool emptydirs zipman purge !check) # A negated option will do the opposite of the comments below. # #-- strip: Strip symbols from binaries/libraries in STRIP_DIRS @@ -67,8 +67,9 @@ BUILDENV=(fakeroot !distcc color !ccache) #-- emptydirs: Leave empty directories in packages #-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip #-- purge: Remove files specified by PURGE_TARGETS +#-- check: Run the check() function if it exists. # -OPTIONS=(strip docs libtool emptydirs zipman purge) +OPTIONS=(strip docs libtool emptydirs zipman purge !check) #-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512 INTEGRITY_CHECK=(md5) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 678359f..2a659e6 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -44,7 +44,7 @@ startdir="$PWD" srcdir="$startdir/src" pkgdir="$startdir/pkg" -packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge') +packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'check') other_options=('ccache' 'distcc' 'makeflags' 'force') splitpkg_overrides=('pkgver' 'pkgrel' 'pkgdesc' 'arch' 'license' 'groups' \ 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' \ @@ -71,6 +71,7 @@ SOURCEONLY=0 IGNOREARCH=0 HOLDVER=0 BUILDFUNC=0 +CHECKFUNC=0 PKGFUNC=0 SPLITPKG=0 PKGLIST="" @@ -143,6 +144,9 @@ clean_up() { if (( BUILDFUNC )); then rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"* fi + if (( CHECKFUNC )); then + rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-check.log"* + fi if (( PKGFUNC )); then rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package.log"* elif (( SPLITPKG )); then @@ -735,7 +739,11 @@ run_function() { fi msg "$(gettext "Starting %s()...")" "$pkgfunc" - cd "$srcdir" + if [[ -d "$srcdir"/"$pkgname"-"$pkgver" ]]; then + cd "$srcdir"/"$pkgname"-"$pkgver" + else + cd "$srcdir" + fi # ensure all necessary build variables are exported export CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST @@ -798,6 +806,10 @@ run_build() { run_function "build" } +run_check() { + [[ $(check_option check) = "y" ]] && run_function "check" +} + run_package() { if [[ -z $1 ]]; then pkgfunc="package" @@ -1772,6 +1784,9 @@ fi if [[ $(type -t build) = "function" ]]; then BUILDFUNC=1 fi +if [[ $(type -t check) = "function" ]]; then + CHECKFUNC=1 +fi if [[ $(type -t package) = "function" ]]; then PKGFUNC=1 elif [[ $SPLITPKG -eq 0 && $(type -t package_${pkgname}) = "function" ]]; then @@ -1835,6 +1850,9 @@ if (( INFAKEROOT )); then if (( ! REPKG )); then if (( BUILDFUNC )); then run_build + if (( CHECKFUNC )); then + run_check + fi tidy_install fi else @@ -1960,6 +1978,7 @@ else if (( ! REPKG )); then devel_update (( BUILDFUNC )) && run_build + (( CHECKFUNC )) && run_check fi if (( ! SPLITPKG )); then if (( PKGFUNC )); then @@ -1991,6 +2010,7 @@ else if (( ! REPKG && ( PKGFUNC || SPLITPKG ) )); then devel_update (( BUILDFUNC )) && run_build + (( CHECKFUNC )) && run_check cd "$startdir" fi -- 1.7.1
On 19/06/10 08:04, Jeff wrote:
If this is an accepted feature, I can resend the patch with manpage updates.
Signed-off-by: Jeff C<jeff@kcaccess.com>
This is a feature that is acceptable. But I do not like using an option=() value to decide whether to run it. I would prefer a "--check" option to be added. Then people can choose to run the check function or not without requiring to edit the PKGBUILD. If they always want check() to be run, an alias for makepkg can be used. Also,
@@ -735,7 +739,11 @@ run_function() { fi
msg "$(gettext "Starting %s()...")" "$pkgfunc" - cd "$srcdir" + if [[ -d "$srcdir"/"$pkgname"-"$pkgver" ]]; then + cd "$srcdir"/"$pkgname"-"$pkgver" + else + cd "$srcdir" + fi
# ensure all necessary build variables are exported export CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
That is unrelated to the patch... Allan
On Sat, Jun 19, 2010 at 02:41:02PM +1000, Allan McRae wrote:
This is a feature that is acceptable. But I do not like using an option=() value to decide whether to run it. I would prefer a "--check" option to be added. Then people can choose to run the check function or not without requiring to edit the PKGBUILD. If they always want check() to be run, an alias for makepkg can be used.
Actually, I never envisioned this to be used in the PKGBUILDs other than for a very few critical packages (toolchain) where it doesn't make sense to not test. IMO, this would better be suited as an edited value in makepkg.conf per the builders's desire the same as whether he wants the doc directory wiped. The use of an alias in this case would serve nothing more than to override a global directive, which ISTM is what ~/.makepkg.conf is for.
That is unrelated to the patch...
Oops, slipped in by accident. Thanks for the notice. -- Jeff My other computer is an abacus.
On 21/06/10 06:00, Jeff wrote:
On Sat, Jun 19, 2010 at 02:41:02PM +1000, Allan McRae wrote:
This is a feature that is acceptable. But I do not like using an option=() value to decide whether to run it. I would prefer a "--check" option to be added. Then people can choose to run the check function or not without requiring to edit the PKGBUILD. If they always want check() to be run, an alias for makepkg can be used.
Actually, I never envisioned this to be used in the PKGBUILDs other than for a very few critical packages (toolchain) where it doesn't make sense to not test. IMO, this would better be suited as an edited value in makepkg.conf per the builders's desire the same as whether he wants the doc directory wiped. The use of an alias in this case would serve nothing more than to override a global directive, which ISTM is what ~/.makepkg.conf is for.
I do not see the option as being the same as removing docs. All the values in OPTIONS affect the files in the final package. The "check" option would not. If check() is designed to be only used in cases where it is important to always run the test suite, then I suggest we make running check() to be the default and that it can only be disabled with a --nocheck command line flag. Allan
participants (2)
-
Allan McRae
-
Jeff