[meta-lts-mixins][scarthgap/go][PATCH 5/7] go: ptest: fix GOROOT detection and improve cleanup/exit handling
Peter Marko <[email protected]>
| Newsgroups | org.yoctoproject.lists.yocto-patches |
|---|---|
| Message-ID | <[email protected]> |
From: Pratik Farkase <[email protected]> Changes: - Derive GOROOT dynamically from PTEST_DIR instead of hardcoding /usr/lib/go, which breaks on distros using lib64. - Track and clean up VERSION and pkg/include files that were copied into GOROOT, preventing stale artifacts after ptest runs. - Track failures with RC variable and exit non-zero when tests fail, consistent with other ptest scripts. Signed-off-by: Pratik Farkase <[email protected]> Signed-off-by: Mathieu Dubois-Briand <[email protected]> Signed-off-by: Richard Purdie <[email protected]> (From OE-Core rev: a912153baed08d8d1d563341e29a2d596546bdb4) Signed-off-by: Peter Marko <[email protected]> --- recipes-devtools/go/go/run-ptest | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/recipes-devtools/go/go/run-ptest b/recipes-devtools/go/go/run-ptest index b8a0805..5fc9367 100755 --- a/recipes-devtools/go/go/run-ptest +++ b/recipes-devtools/go/go/run-ptest @@ -2,7 +2,7 @@ # SPDX-License-Identifier: MIT PTEST_DIR=$(cd "$(dirname "$0")" && pwd) -GOROOT=/usr/lib/go +GOROOT=$(dirname "$PTEST_DIR") export GOROOT export PATH=$GOROOT/bin:$PATH @@ -16,11 +16,18 @@ if [ -d "$GOROOT/src" ] && [ ! -L "$GOROOT/src" ]; then fi ln -sf "$PTEST_DIR/src" "$GOROOT/src" -if [ -f "$PTEST_DIR/VERSION" ]; then +CLEANUP_VERSION=0 +if [ -f "$PTEST_DIR/VERSION" ] && [ ! -f "$GOROOT/VERSION" ]; then cp "$PTEST_DIR/VERSION" "$GOROOT/VERSION" + CLEANUP_VERSION=1 fi + +CLEANUP_INCLUDE=0 if ls "$PTEST_DIR/pkg/include/"* >/dev/null 2>&1; then - mkdir -p "$GOROOT/pkg/include" + if [ ! -d "$GOROOT/pkg/include" ]; then + mkdir -p "$GOROOT/pkg/include" + CLEANUP_INCLUDE=1 + fi cp "$PTEST_DIR/pkg/include/"* "$GOROOT/pkg/include/" fi @@ -38,6 +45,7 @@ SKIP_PKGS="debug/dwarf debug/elf debug/pe debug/plan9obj go/types internal/xcoff SKIP_REGEX=$(echo "$SKIP_PKGS" | sed 's/ /|/g') +RC=0 for pkg in $(go list std); do # Skip package and all its subpackages if echo "$pkg" | grep -qE "^($SKIP_REGEX)(/|$)"; then @@ -52,6 +60,7 @@ for pkg in $(go list std); do else echo "FAIL: $pkg" echo "$output" + RC=1 fi done @@ -60,4 +69,12 @@ rm -f "$GOROOT/src" if [ -d "$GOROOT/src.orig" ]; then mv "$GOROOT/src.orig" "$GOROOT/src" fi +if [ $CLEANUP_VERSION -eq 1 ]; then + rm -f "$GOROOT/VERSION" +fi +if [ $CLEANUP_INCLUDE -eq 1 ]; then + rm -rf "$GOROOT/pkg/include" +fi rm -rf "$GOCACHE" + +exit $RC