blob: 173b46fd83d14869af2a7eb18d1638415e1b92cb [file] [log] [blame]
David du Colombierfbdf59a2014-12-23 09:05:28 +01001// +build !nacl,!plan9,!windows
Josh Bleecher Snydere7173df2014-12-18 10:34:12 -08002// run
Russ Coxcd22afa2012-09-23 13:16:14 -04003
Russ Cox191263202010-01-25 18:23:20 -08004// Copyright 2009 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
Josh Bleecher Snydere7173df2014-12-18 10:34:12 -08008package main
9
10import (
11 "fmt"
Josh Bleecher Snydere7173df2014-12-18 10:34:12 -080012 "os"
13 "os/exec"
14 "path/filepath"
15)
16
17func main() {
Josh Bleecher Snyder209dd4c2014-12-22 15:26:21 -080018 // TODO: If we get rid of errchk, re-enable this test on Windows.
Josh Bleecher Snydere7173df2014-12-18 10:34:12 -080019 errchk, err := filepath.Abs("errchk")
20 check(err)
21
22 err = os.Chdir(filepath.Join("fixedbugs", "bug248.dir"))
23 check(err)
24
Russ Cox0f4132c2015-05-21 13:28:13 -040025 run("go", "tool", "compile", "bug0.go")
26 run("go", "tool", "compile", "bug1.go")
27 run("go", "tool", "compile", "bug2.go")
28 run(errchk, "go", "tool", "compile", "-e", "bug3.go")
Russ Coxcf932cd2015-05-21 13:28:17 -040029 run("go", "tool", "link", "bug2.o")
30 run(fmt.Sprintf(".%ca.out", filepath.Separator))
Josh Bleecher Snydere7173df2014-12-18 10:34:12 -080031
Russ Coxcf932cd2015-05-21 13:28:17 -040032 os.Remove("bug0.o")
33 os.Remove("bug1.o")
34 os.Remove("bug2.o")
35 os.Remove("a.out")
Josh Bleecher Snydere7173df2014-12-18 10:34:12 -080036}
37
38func run(name string, args ...string) {
39 cmd := exec.Command(name, args...)
40 out, err := cmd.CombinedOutput()
41 if err != nil {
42 fmt.Println(string(out))
43 fmt.Println(err)
44 os.Exit(1)
45 }
46}
47
48func check(err error) {
49 if err != nil {
50 fmt.Println(err)
51 os.Exit(1)
52 }
53}