From 83cc290601d420cf55814021ff5ff102fc7acb5a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
Date: Mon, 7 Dec 2020 20:15:42 -0300
Subject: [PATCH] xbps-src: add -K option for running the full testsuite.

Some packages have rather long test suites, with an option for a shorter
one. With this option, one can choose between shorter tests (-Q) or the
complete longer ones (-K).

This also allows CI to run only the shorter testsuites.

Make the appropriate changes to etc/default.conf and Manual.md as well.
---
 Manual.md         | 3 +++
 etc/defaults.conf | 2 ++
 xbps-src          | 7 +++++--
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Manual.md b/Manual.md
index 0a3c759f59b..aa7a196d4f4 100644
--- a/Manual.md
+++ b/Manual.md
@@ -364,6 +364,9 @@ rather than additional binary package names.
 
 - `CROSS_BUILD` Set if `xbps-src` is cross compiling a package.
 
+- `XBPS_CHECK_PKGS` Set if `xbps-src` is going to run tests for a package.
+Longer testsuites should only be run in `do_check()` if it is set to `full`.
+
 - `DESTDIR` Full path to the fake destdir used by the source pkg, set to
 `<masterdir>/destdir/${sourcepkg}-${version}`.
 
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 6e297903fbd..88286deaa6f 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -71,8 +71,10 @@ XBPS_SUCMD="sudo /bin/sh -c"
 
 # [OPTIONAL]
 # Enable running the (optional) do_check() function of a package.
+# When set to 'full', will enable further testing for some packages.
 #
 #XBPS_CHECK_PKGS=yes
+#XBPS_CHECK_PKGS=full
 
 # [OPTIONAL]
 # Enable building -dbg subpackages with debugging symbols. Please note
diff --git a/xbps-src b/xbps-src
index 08da501f219..54016874010 100755
--- a/xbps-src
+++ b/xbps-src
@@ -205,6 +205,8 @@ $(print_cross_targets)
 
 -Q  Enable running the check stage.
 
+-K  Enable running the check stage with longer tests.
+
 -q  Suppress informational output of xbps-src (build output is still printed).
 
 -r  <repo>
@@ -381,7 +383,8 @@ while getopts "$XBPS_OPTSTRING" opt; do
         o) XBPS_ARG_PKG_OPTIONS="$OPTARG"; XBPS_OPTIONS+=" -o $OPTARG";;
         p) XBPS_ARG_PRINT_VARIABLES="$OPTARG"; XBPS_OPTIONS+=" -p $OPTARG";;
         q) XBPS_ARG_QUIET=1; XBPS_OPTIONS+=" -q";;
-        Q) XBPS_ARG_CHECK_PKGS=1; XBPS_OPTIONS+=" -Q";;
+        Q) XBPS_ARG_CHECK_PKGS=yes; XBPS_OPTIONS+=" -Q";;
+        K) XBPS_ARG_CHECK_PKGS=full; XBPS_OPTIONS+=" -K";;
         r) XBPS_ARG_ALT_REPOSITORY="$OPTARG"; XBPS_OPTIONS+=" -r $OPTARG";;
         t) XBPS_ARG_TEMP_MASTERDIR=1; XBPS_OPTIONS+=" -t -C";;
         V) echo "xbps-src-$XBPS_SRC_VERSION $(xbps-uhelper -V)" && exit 0;;
@@ -459,7 +462,6 @@ fi
 [ -n "$XBPS_ARG_TEMP_MASTERDIR" ] && XBPS_TEMP_MASTERDIR=1
 [ -n "$XBPS_ARG_BINPKG_EXISTS" ] && XBPS_BINPKG_EXISTS=1
 [ -n "$XBPS_ARG_USE_GIT_REVS" ] && XBPS_USE_GIT_REVS=1
-[ -n "$XBPS_ARG_CHECK_PKGS" ] && XBPS_CHECK_PKGS=1
 [ -n "$XBPS_ARG_DEBUG_PKGS" ] && XBPS_DEBUG_PKGS=1
 [ -n "$XBPS_ARG_SKIP_DEPS" ] && XBPS_SKIP_DEPS=1
 [ -n "$XBPS_ARG_KEEP_ALL" ] && XBPS_KEEP_ALL=1
@@ -467,6 +469,7 @@ fi
 [ -n "$XBPS_ARG_PRINT_VARIABLES" ] && XBPS_PRINT_VARIABLES="$XBPS_ARG_PRINT_VARIABLES"
 [ -n "$XBPS_ARG_ALT_REPOSITORY" ] && XBPS_ALT_REPOSITORY="$XBPS_ARG_ALT_REPOSITORY"
 [ -n "$XBPS_ARG_CROSS_BUILD" ] && XBPS_CROSS_BUILD="$XBPS_ARG_CROSS_BUILD"
+[ -n "$XBPS_ARG_CHECK_PKGS" ] && XBPS_CHECK_PKGS="$XBPS_ARG_CHECK_PKGS"
 [ -n "$XBPS_ARG_MAKEJOBS" ] && XBPS_MAKEJOBS="$XBPS_ARG_MAKEJOBS"
 
 export XBPS_BUILD_ONLY_ONE_PKG XBPS_SKIP_REMOTEREPOS XBPS_BUILD_FORCEMODE \