Source file src/go/doc/comment/std_test.go

     1  // Copyright 2022 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  
     5  package comment
     6  
     7  import (
     8  	"internal/diff"
     9  	"internal/testenv"
    10  	"slices"
    11  	"strings"
    12  	"testing"
    13  )
    14  
    15  func TestStd(t *testing.T) {
    16  	cmd := testenv.Command(t, testenv.GoToolPath(t), "list", "std")
    17  	cmd.Env = append(cmd.Environ(), "GOEXPERIMENT=none")
    18  	out, err := cmd.CombinedOutput()
    19  	if err != nil {
    20  		t.Fatalf("%v\n%s", err, out)
    21  	}
    22  
    23  	var list []string
    24  	for _, pkg := range strings.Fields(string(out)) {
    25  		if !strings.Contains(pkg, "/") {
    26  			list = append(list, pkg)
    27  		}
    28  	}
    29  	slices.Sort(list)
    30  
    31  	have := strings.Join(stdPkgs, "\n") + "\n"
    32  	want := strings.Join(list, "\n") + "\n"
    33  	if have != want {
    34  		t.Errorf("stdPkgs is out of date: regenerate with 'go generate'\n%s", diff.Diff("stdPkgs", []byte(have), "want", []byte(want)))
    35  	}
    36  }
    37  

View as plain text