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

     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  
     9  go test -c -o $WORK/some/nonexisting/directory/ ./pkg/...
    10  exists -exec $WORK/some/nonexisting/directory/pkg1.test$GOEXE
    11  exists -exec $WORK/some/nonexisting/directory/pkg2.test$GOEXE
    12  
    13  go test -c ./pkg/...
    14  exists -exec pkg1.test$GOEXE
    15  exists -exec pkg2.test$GOEXE
    16  
    17  ! go test -c -o $WORK/bin/test/bin.test.exe ./pkg/...
    18  stderr '^with multiple packages, -o must refer to a directory or '$devnull
    19  
    20  ! go test -c ./...
    21  stderr '^cannot write test binary pkg1.test for multiple packages:\nexample/anotherpkg/pkg1\nexample/pkg/pkg1'
    22  
    23  ! go test -c -o $WORK/bin/test/ ./...
    24  stderr '^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/...
    27  stderr '^with multiple packages, -o must refer to a directory or '$devnull
    28  
    29  ! go test -o $WORK/bin/ ./...
    30  stderr '^cannot write test binary pkg1.test for multiple packages:\nexample/anotherpkg/pkg1\nexample/pkg/pkg1'
    31  
    32  go test -c -o $devnull ./...
    33  
    34  rm pkg1.test$GOEXE
    35  rm pkg2.test$GOEXE
    36  go test -o . ./pkg/...
    37  exists -exec pkg1.test$GOEXE
    38  exists -exec pkg2.test$GOEXE
    39  
    40  -- go.mod --
    41  module example
    42  
    43  -- pkg/pkg1/pkg1_test.go --
    44  package pkg1
    45  
    46  -- pkg/pkg2/pkg2_test.go --
    47  package pkg2
    48  
    49  -- anotherpkg/pkg1/pkg1_test.go --
    50  package pkg1
    51  

View as plain text