...

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

Documentation: cmd/go/testdata/script

     1[short] skip 'links test binaries'
     2
     3# Verify test -c can output multiple executables to a directory.
     4
     5# This test also serves as a regression test for https://go.dev/issue/62221:
     6# prior to the fix for that issue, it occasionally failed with ETXTBSY when
     7# run on Unix platforms.
     8
     9go test -c -o $WORK/some/nonexisting/directory/ ./pkg/...
    10exists -exec $WORK/some/nonexisting/directory/pkg1.test$GOEXE
    11exists -exec $WORK/some/nonexisting/directory/pkg2.test$GOEXE
    12
    13go test -c ./pkg/...
    14exists -exec pkg1.test$GOEXE
    15exists -exec pkg2.test$GOEXE
    16
    17! go test -c -o $WORK/bin/test/bin.test.exe ./pkg/...
    18stderr '^with multiple packages, -o must refer to a directory or '$devnull
    19
    20! go test -c ./...
    21stderr '^cannot write test binary pkg1.test for multiple packages:\nexample/anotherpkg/pkg1\nexample/pkg/pkg1'
    22
    23! go test -c -o $WORK/bin/test/ ./...
    24stderr '^cannot write test binary pkg1.test for multiple packages:\nexample/anotherpkg/pkg1\nexample/pkg/pkg1'
    25
    26! go test -o $WORK/bin/filename.exe ./pkg/...
    27stderr '^with multiple packages, -o must refer to a directory or '$devnull
    28
    29! go test -o $WORK/bin/ ./...
    30stderr '^cannot write test binary pkg1.test for multiple packages:\nexample/anotherpkg/pkg1\nexample/pkg/pkg1'
    31
    32go test -c -o $devnull ./...
    33
    34rm pkg1.test$GOEXE
    35rm pkg2.test$GOEXE
    36go test -o . ./pkg/...
    37exists -exec pkg1.test$GOEXE
    38exists -exec pkg2.test$GOEXE
    39
    40-- go.mod --
    41module example
    42
    43-- pkg/pkg1/pkg1_test.go --
    44package pkg1
    45
    46-- pkg/pkg2/pkg2_test.go --
    47package pkg2
    48
    49-- anotherpkg/pkg1/pkg1_test.go --
    50package pkg1

View as plain text