From owner-svn-ports-all@freebsd.org Sun Nov 17 16:19:38 2019 Return-Path: Delivered-To: svn-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EA5C11C3BD8; Sun, 17 Nov 2019 16:19:38 +0000 (UTC) (envelope-from dmgk@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47GHNV1LYBz3x6j; Sun, 17 Nov 2019 16:19:38 +0000 (UTC) (envelope-from dmgk@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 84BDA1C595; Sun, 17 Nov 2019 16:19:37 +0000 (UTC) (envelope-from dmgk@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAHGJbSP014850; Sun, 17 Nov 2019 16:19:37 GMT (envelope-from dmgk@FreeBSD.org) Received: (from dmgk@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAHGJbrU014849; Sun, 17 Nov 2019 16:19:37 GMT (envelope-from dmgk@FreeBSD.org) Message-Id: <201911171619.xAHGJbrU014849@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dmgk set sender to dmgk@FreeBSD.org using -f From: Dmitri Goutnik Date: Sun, 17 Nov 2019 16:19:37 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r517831 - head/Mk/Uses X-SVN-Group: ports-head X-SVN-Commit-Author: dmgk X-SVN-Commit-Paths: head/Mk/Uses X-SVN-Commit-Revision: 517831 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Nov 2019 16:19:39 -0000 Author: dmgk Date: Sun Nov 17 16:19:36 2019 New Revision: 517831 URL: https://svnweb.freebsd.org/changeset/ports/517831 Log: Mk/Uses/go.mk: Add GO_TEST_TARGET and provide default do-test Add GO_TEST_TARGET defaulting to `./...` (the current package and all subpackages) and create do-test target unless already provided by port's Makefile. In many cases this would allow us to remove explicit do-test and rely on defaults provided by ports framework for testing. Also, while here - remove GO_WRKDIR_SRC - it is not used anywhere anymore - sync GO_PKGNAME and GO_TARGET descriptions with Porter's Handbook Reviewed by: tobik Approved by: tz (mentor, implicit) Differential Revision: https://reviews.freebsd.org/D22412 Modified: head/Mk/Uses/go.mk Modified: head/Mk/Uses/go.mk ============================================================================== --- head/Mk/Uses/go.mk Sun Nov 17 15:56:03 2019 (r517830) +++ head/Mk/Uses/go.mk Sun Nov 17 16:19:36 2019 (r517831) @@ -12,8 +12,8 @@ # in modules-aware mode. # no_targets Indicates that Go is needed at build time as a part of # make/CMake build. This will setup build environment like -# GO_ENV, GO_BUILDFLAGS but will not create post-extract, do-build -# and do-install targets. +# GO_ENV, GO_BUILDFLAGS but will not create post-extract and +# do-{build,install,test} targets. # run Indicates that Go is needed at run time and adds it to # RUN_DEPENDS. # @@ -21,20 +21,20 @@ # # GO_PKGNAME # The name of the package when building in GOPATH mode. This -# is the directory that will be created in GOPATH/src and seen -# by the `go` command. If not set explicitly and GH_SUBDIR or -# GL_SUBDIR is present, GO_PKGNAME will be inferred from it. +# is the directory that will be created in ${GOPATH}/src. If not set +# explicitly and GH_SUBDIR or GL_SUBDIR is present, GO_PKGNAME will +# be inferred from it. # It is not needed when building in modules-aware mode. # # GO_TARGET -# The packages to build. If not set explicitly, defaults to -# GO_PKGNAME. GO_TARGET can also be a tuple in the form -# package:path where path can be either a simple filename or a -# full path starting with ${PREFIX}. Specifying a full path -# like ${PREFIX}/sbin/binary will install the resulting binary -# as ${PREFIX}/sbin/binary. Using just simple filename is a -# shortcut to installing it as ${PREFIX}/bin/filename. +# The packages to build. The default value is ${GO_PKGNAME}. +# GO_TARGET can also be a tuple in the form package:path where path can be +# either a simple filename or a full path starting with ${PREFIX}. # +# GO_TEST_TARGET +# The packages to test. The default value is `./...` (the current package +# and all subpackages). +# # CGO_CFLAGS # Additional CFLAGS variables to be passed to the C compiler by the `go` # command @@ -72,7 +72,9 @@ GO_PKGNAME= ${GL_SUBDIR:S|^src/||} GO_PKGNAME= ${PORTNAME} . endif .endif + GO_TARGET?= ${GO_PKGNAME} +GO_TEST_TARGET?= ./... GO_BUILDFLAGS+= -v -buildmode=exe .if !defined(WITH_DEBUG) && empty(GO_BUILDFLAGS:M-ldflags*) @@ -102,8 +104,7 @@ GO_WRKSRC= ${WRKSRC} GO_ENV+= GOPATH="" \ GOBIN="${GO_WRKDIR_BIN}" .else -GO_WRKDIR_SRC= ${WRKDIR}/src -GO_WRKSRC= ${GO_WRKDIR_SRC}/${GO_PKGNAME} +GO_WRKSRC= ${WRKDIR}/src/${GO_PKGNAME} GO_ENV+= GOPATH="${WRKDIR}" \ GOBIN="" .endif @@ -158,6 +159,15 @@ do-install: ${ECHO_MSG} "===> Installing $${src} as $${dst}"; \ ${INSTALL_PROGRAM} ${GO_WRKDIR_BIN}/$${src} $${dst}; \ done +.endif + +.if !target(do-test) && empty(go_ARGS:Mno_targets) +do-test: + (cd ${GO_WRKSRC}; \ + for t in ${GO_TEST_TARGET}; do \ + ${ECHO_MSG} "===> Testing $${t}"; \ + ${SETENV} ${MAKE_ENV} ${GO_ENV} ${GO_CMD} test ${GO_BUILDFLAGS} $${t}; \ + done) .endif # Helper targets for port maintainers