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

     1  // +build !nacl
     2  // run
     3  
     4  // Copyright 2010 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  package main
     9  
    10  import (
    11  	"fmt"
    12  	"os"
    13  	"os/exec"
    14  	"path/filepath"
    15  )
    16  
    17  func main() {
    18  	run("go", "tool", "compile", filepath.Join("fixedbugs", "bug302.dir", "p.go"))
    19  	run("go", "tool", "pack", "grc", "pp.a", "p.o")
    20  	run("go", "tool", "compile", "-I", ".", filepath.Join("fixedbugs", "bug302.dir", "main.go"))
    21  	os.Remove("p.o")
    22  	os.Remove("pp.a")
    23  	os.Remove("main.o")
    24  }
    25  
    26  func run(cmd string, args ...string) {
    27  	out, err := exec.Command(cmd, args...).CombinedOutput()
    28  	if err != nil {
    29  		fmt.Println(string(out))
    30  		fmt.Println(err)
    31  		os.Exit(1)
    32  	}
    33  }