Help us shape the future of Go! Take the 2026 Go Developer Survey

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

     1  # Check for data races when concurrently building test variants of a cgo package.
     2  
     3  [short] skip
     4  [!cgo] skip
     5  
     6  env GOCACHE=$WORK/gocache
     7  env GOTMPDIR=$WORK/tmp
     8  mkdir $WORK/tmp
     9  go test -run=^$ ./...
    10  go run ./checkwork $GOCACHE $GOTMPDIR
    11  
    12  -- go.mod --
    13  module example.com/m
    14  
    15  go 1.27
    16  -- checkwork/main.go --
    17  // checkwork reports files in a directory tree that mention a string.
    18  package main
    19  
    20  import (
    21  	"bytes"
    22  	"fmt"
    23  	"io/fs"
    24  	"os"
    25  	"path/filepath"
    26  )
    27  
    28  func main() {
    29  	root, s := os.Args[1], os.Args[2]
    30  	bad := false
    31  	err := filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {
    32  		if err != nil || d.IsDir() {
    33  			return err
    34  		}
    35  		data, err := os.ReadFile(path)
    36  		if err != nil {
    37  			return err
    38  		}
    39  		if bytes.Contains(data, []byte(s)) {
    40  			fmt.Printf("%s mentions %s\n", path, s)
    41  			bad = true
    42  		}
    43  		return nil
    44  	})
    45  	if err != nil {
    46  		fmt.Println(err)
    47  		os.Exit(1)
    48  	}
    49  	if bad {
    50  		os.Exit(1)
    51  	}
    52  }
    53  -- c/c.go --
    54  package c
    55  
    56  // int add(int a, int b) { return a + b; }
    57  import "C"
    58  
    59  import (
    60  	_ "example.com/m/x1"
    61  	_ "example.com/m/x2"
    62  	_ "example.com/m/x3"
    63  	_ "example.com/m/x4"
    64  	_ "example.com/m/x5"
    65  	_ "example.com/m/x6"
    66  	_ "example.com/m/x7"
    67  	_ "example.com/m/x8"
    68  )
    69  
    70  func Add(a, b int) int { return int(C.add(C.int(a), C.int(b))) }
    71  -- c/f1.go --
    72  package c
    73  -- c/f2.go --
    74  package c
    75  -- c/f3.go --
    76  package c
    77  -- c/f4.go --
    78  package c
    79  -- c/f5.go --
    80  package c
    81  -- x1/x.go --
    82  package x1
    83  -- x1/export_test.go --
    84  package x1
    85  -- x1/x_test.go --
    86  package x1_test
    87  
    88  import (
    89  	"testing"
    90  
    91  	"example.com/m/c"
    92  )
    93  
    94  func Test(t *testing.T) { c.Add(1, 2) }
    95  -- x2/x.go --
    96  package x2
    97  -- x2/export_test.go --
    98  package x2
    99  -- x2/x_test.go --
   100  package x2_test
   101  
   102  import (
   103  	"testing"
   104  
   105  	"example.com/m/c"
   106  )
   107  
   108  func Test(t *testing.T) { c.Add(1, 2) }
   109  -- x3/x.go --
   110  package x3
   111  -- x3/export_test.go --
   112  package x3
   113  -- x3/x_test.go --
   114  package x3_test
   115  
   116  import (
   117  	"testing"
   118  
   119  	"example.com/m/c"
   120  )
   121  
   122  func Test(t *testing.T) { c.Add(1, 2) }
   123  -- x4/x.go --
   124  package x4
   125  -- x4/export_test.go --
   126  package x4
   127  -- x4/x_test.go --
   128  package x4_test
   129  
   130  import (
   131  	"testing"
   132  
   133  	"example.com/m/c"
   134  )
   135  
   136  func Test(t *testing.T) { c.Add(1, 2) }
   137  -- x5/x.go --
   138  package x5
   139  -- x5/export_test.go --
   140  package x5
   141  -- x5/x_test.go --
   142  package x5_test
   143  
   144  import (
   145  	"testing"
   146  
   147  	"example.com/m/c"
   148  )
   149  
   150  func Test(t *testing.T) { c.Add(1, 2) }
   151  -- x6/x.go --
   152  package x6
   153  -- x6/export_test.go --
   154  package x6
   155  -- x6/x_test.go --
   156  package x6_test
   157  
   158  import (
   159  	"testing"
   160  
   161  	"example.com/m/c"
   162  )
   163  
   164  func Test(t *testing.T) { c.Add(1, 2) }
   165  -- x7/x.go --
   166  package x7
   167  -- x7/export_test.go --
   168  package x7
   169  -- x7/x_test.go --
   170  package x7_test
   171  
   172  import (
   173  	"testing"
   174  
   175  	"example.com/m/c"
   176  )
   177  
   178  func Test(t *testing.T) { c.Add(1, 2) }
   179  -- x8/x.go --
   180  package x8
   181  -- x8/export_test.go --
   182  package x8
   183  -- x8/x_test.go --
   184  package x8_test
   185  
   186  import (
   187  	"testing"
   188  
   189  	"example.com/m/c"
   190  )
   191  
   192  func Test(t *testing.T) { c.Add(1, 2) }
   193  

View as plain text