...

Text file src/cmd/go/testdata/script/test_goroot_PATH.txt

Documentation: cmd/go/testdata/script

     1# https://go.dev/issue/51473: to avoid the need for tests to rely on
     2# runtime.GOROOT, 'go test' should run the test with its own GOROOT/bin
     3# at the beginning of $PATH.
     4
     5[short] skip
     6
     7[!GOOS:plan9] env PATH=
     8[GOOS:plan9] env path=
     9go test .
    10
    11[!GOOS:plan9] env PATH=$WORK${/}bin
    12[GOOS:plan9] env path=$WORK${/}bin
    13go test .
    14
    15-- go.mod --
    16module example
    17
    18go 1.19
    19-- example_test.go --
    20package example
    21
    22import (
    23	"os"
    24	"os/exec"
    25	"path/filepath"
    26	"testing"
    27)
    28
    29func TestGoCommandExists(t *testing.T) {
    30	got, err := exec.LookPath("go")
    31	if err != nil {
    32		t.Fatal(err)
    33	}
    34
    35	want := filepath.Join(os.Getenv("GOROOT"), "bin", "go" + os.Getenv("GOEXE"))
    36	if got != want {
    37		t.Fatalf(`exec.LookPath("go") = %q; want %q`, got, want)
    38	}
    39}
    40-- $WORK/bin/README.txt --
    41This directory contains no executables.

View as plain text