3 // +build !nacl,!js,!wasip1,gc
5 // Copyright 2020 The Go Authors. All rights reserved.
6 // Use of this source code is governed by a BSD-style
7 // license that can be found in the LICENSE file.
9 // Tests that when non-existent files are passed to the
10 // compiler, such as in:
11 // go tool compile foo
12 // we don't print the beginning position:
13 // foo:0: open foo: no such file or directory
14 // but instead omit it and print out:
15 // open foo: no such file or directory
28 tmpDir, err := ioutil.TempDir("", "issue36437")
32 defer os.RemoveAll(tmpDir)
34 msgOrErr := func(msg []byte, err error) string {
35 if len(msg) == 0 && err != nil {
41 filename := "non-existent.go"
42 output, err := exec.Command("go", "tool", "compile", filename).CombinedOutput()
43 got := msgOrErr(output, err)
45 regFilenamePos := regexp.MustCompile(filename + ":\\d+")
46 if regFilenamePos.MatchString(got) {
47 fmt.Printf("Error message must not contain filename:pos, but got:\n%q\n", got)