Source file src/cmd/internal/stdcheck/main_test.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  package main
     5  
     6  import (
     7  	"bytes"
     8  	"internal/testenv"
     9  	"os"
    10  	"os/exec"
    11  	"testing"
    12  )
    13  
    14  func TestMain(m *testing.M) {
    15  	if os.Getenv("GO_STDCHECKTEST_IS_STDCHECK") != "" {
    16  		main()
    17  		os.Exit(0)
    18  	}
    19  
    20  	os.Exit(m.Run())
    21  }
    22  
    23  func TestRunAnalyzers(t *testing.T) {
    24  	if testing.Short() {
    25  		t.Skip("skipping in short mode")
    26  	}
    27  	cmd := exec.Command(testenv.GoToolPath(t), "vet", "-vettool", testenv.Executable(t), "std")
    28  	cmd.Env = append(os.Environ(), "GO_STDCHECKTEST_IS_STDCHECK=1")
    29  	stderr := new(bytes.Buffer)
    30  	cmd.Stderr = stderr
    31  	if err := cmd.Run(); err != nil {
    32  		// TODO: we could probably do a better job of parsing and presenting the
    33  		// output here (e.g. one subtest per analyzer?)
    34  		t.Error(stderr.String())
    35  	}
    36  }
    37  

View as plain text