pkgsrc-Changes archive

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

CVS commit: pkgsrc/regress/tools-platform



Module Name:    pkgsrc
Committed By:   rillig
Date:           Fri May  1 18:37:59 UTC 2020

Added Files:
        pkgsrc/regress/tools-platform: sh.test spec zzz-prepare-tools.mk

Log Message:
regress: add tools-platform/ for testing the platform tools

Right now, the tests in regress/tools are a mixture of testing the pkgsrc
infrastructure in mk/tools and the tools provided by the platforms.
These don't go well together, therefore the tests for the platform tools
will be migrated here.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 pkgsrc/regress/tools-platform/sh.test \
    pkgsrc/regress/tools-platform/spec \
    pkgsrc/regress/tools-platform/zzz-prepare-tools.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: pkgsrc/regress/tools-platform/sh.test
diff -u /dev/null pkgsrc/regress/tools-platform/sh.test:1.1
--- /dev/null   Fri May  1 18:37:59 2020
+++ pkgsrc/regress/tools-platform/sh.test       Fri May  1 18:37:59 2020
@@ -0,0 +1,41 @@
+#! /bin/sh
+# $NetBSD: sh.test,v 1.1 2020/05/01 18:37:59 rillig Exp $
+#
+# Tests for the shell that is available as ${SH} in Makefiles.
+#
+# Having a feature tested in this file does not mean it is available in
+# Makefiles since devel/bmake may use a completely different shell for
+# running its commands.  For example on SunOS, devel/bmake typically
+# uses /usr/xpg4/bin/sh while TOOLS_PLATFORM.sh is /bin/ksh.
+
+set -eu
+
+dief() {
+       printf 'error: [sh.test] ' 1>&2
+       printf "$@" 1>&2
+       printf '\n' 1>&2
+       exit 1
+}
+
+assert_that() {
+       case $2 in
+       (--equals)
+               [ "x$1" = "x$3" ] \
+               || dief 'assertion failed: expected "%s", got "%s"' "$3" "$1"
+               ;;
+       (*)     dief 'wrong assert_that call: %s' "$*"
+               ;;
+       esac
+}
+
+pathname="first/second/third/fourth"
+
+# Make sure that the usual word expansions work.
+assert_that "##: ${pathname##*/}"      --equals "##: fourth"
+assert_that "#: ${pathname#*/}"                --equals "#: second/third/fourth"
+assert_that "%%: ${pathname%%/*}"      --equals "%%: first"
+assert_that "%: ${pathname%/*}"                --equals "%: first/second/third"
+
+# Make sure that $(...) subshells work.
+assert_that "subshell: $(echo world | tr 'world' 'hello')" \
+       --equals "subshell: hello"
Index: pkgsrc/regress/tools-platform/spec
diff -u /dev/null pkgsrc/regress/tools-platform/spec:1.1
--- /dev/null   Fri May  1 18:37:59 2020
+++ pkgsrc/regress/tools-platform/spec  Fri May  1 18:37:59 2020
@@ -0,0 +1,39 @@
+# $NetBSD: spec,v 1.1 2020/05/01 18:37:59 rillig Exp $
+#
+# Tests for the platform-provided tools.
+#
+# The individual *.test files are run in a minimal environment.
+# In that environment, only the PATH is set, and it points to a
+# directory containing only the tools from mk/tools/tools.${OPSYS}.mk.
+#
+# The individual tests may create arbitrary files in their current
+# working directory.
+#
+
+do_test() {
+       regressdir="$PWD"
+       tmpdir="$(mktemp -d)" || { TEST_EXITSTATUS=$?; return; }
+       bindir="$tmpdir/bin"
+       mkdir "$bindir"
+       (
+               cd ../../pkgtools/digest \
+               && $TEST_MAKE \
+                       BINDIR="$bindir" \
+                       -f "$regressdir/zzz-prepare-tools.mk" \
+                       "prepare-platform-tools"
+       )
+
+       for testfile in *.test; do
+               mkdir "$tmpdir/work"
+               (cd "$tmpdir/work" && "$bindir/env" -i PATH="$bindir" \
+                       "sh" "$regressdir/$testfile") \
+               || TEST_EXITSTATUS=$?
+               rm -rf "$tmpdir/work"
+       done
+
+       rm -rf "$tmpdir"
+}
+
+check_result() {
+       exit_status 0
+}
Index: pkgsrc/regress/tools-platform/zzz-prepare-tools.mk
diff -u /dev/null pkgsrc/regress/tools-platform/zzz-prepare-tools.mk:1.1
--- /dev/null   Fri May  1 18:37:59 2020
+++ pkgsrc/regress/tools-platform/zzz-prepare-tools.mk  Fri May  1 18:37:59 2020
@@ -0,0 +1,40 @@
+# $NetBSD: zzz-prepare-tools.mk,v 1.1 2020/05/01 18:37:59 rillig Exp $
+#
+# This "package" creates wrappers for the platform tools in a temporary
+# directory.
+#
+
+PKGNAME=       tools-platform-2020.05.01
+CATEGORIES=    pkgtools
+
+USE_TOOLS=     chmod sed sh tr
+
+.include "../../mk/bsd.prefs.mk"
+
+PLATFORM_TOOLS!= \
+       ${SED} -n \
+               's,^TOOLS_PLATFORM\.\([^[:space:]]*\)[?]=.*,\1,p' \
+               ../../mk/tools/tools.*.mk
+
+prepare-platform-tools:
+.for tool in ${PLATFORM_TOOLS:O:u}
+.  if ${TOOLS_PLATFORM.${tool}:U} && ${TOOLS_PLATFORM.${tool}:[#]} == 1
+.    for cmd in ${TOOLS_PLATFORM.${tool}}
+.      if ${cmd:M/*}
+       @ln -s ${cmd:Q} ${BINDIR:Q}/${tool:Q}
+.      elif ${cmd} == "[" || ${cmd:Necho:Nfalse:Ntest:Ntrue} != ${cmd}
+# ignore these shell builtins
+.      else
+       @${ECHO} "Skipping single-word tool "${tool:Q}": "${cmd:Q}
+.      endif
+.    endfor
+.  elif ${TOOLS_PLATFORM.${tool}:U}
+       @{ \
+               ${ECHO} '#! '${SH:Q};                                   \
+               ${ECHO} 'exec '${TOOLS_PLATFORM.${tool}:Q}' "$$@"';     \
+       } > ${BINDIR:Q}/${tool:Q}
+       @${CHMOD} +x ${BINDIR:Q}/${tool:Q}
+.  endif
+.endfor
+
+.include "../../mk/bsd.pkg.mk"



Home | Main Index | Thread Index | Old Index