modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/bug429_run.go (about)

     1  // +build !nacl
     2  // run
     3  
     4  // Copyright 2014 The Go Authors. All rights reserved.
     5  // Use of this source code is governed by a BSD-style
     6  // license that can be found in the LICENSE file.
     7  
     8  // Run the bug429.go test.
     9  
    10  package main
    11  
    12  import (
    13  	"fmt"
    14  	"os"
    15  	"os/exec"
    16  	"path/filepath"
    17  	"strings"
    18  )
    19  
    20  func main() {
    21  	cmd := exec.Command("go", "run", filepath.Join("fixedbugs", "bug429.go"))
    22  	out, err := cmd.CombinedOutput()
    23  	if err == nil {
    24  		fmt.Println("expected deadlock")
    25  		os.Exit(1)
    26  	}
    27  
    28  	want := "fatal error: all goroutines are asleep - deadlock!"
    29  	got := string(out)
    30  	if !strings.Contains(got, want) {
    31  		fmt.Printf("got:\n%q\nshould contain:\n%q\n", got, want)
    32  		os.Exit(1)
    33  	}
    34  }