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  	out, err := testenv.Command(t, testenv.GoToolPath(t), "list", "std").CombinedOutput()
    17  	if err != nil {
    18  		t.Fatalf("%v\n%s", err, out)
    19  	}
    20  
    21  	var list []string
    22  	for _, pkg := range strings.Fields(string(out)) {
    23  		if !strings.Contains(pkg, "/") {
    24  			list = append(list, pkg)
    25  		}
    26  	}
    27  	slices.Sort(list)
    28  
    29  	have := strings.Join(stdPkgs, "\n") + "\n"
    30  	want := strings.Join(list, "\n") + "\n"
    31  	if have != want {
    32  		t.Errorf("stdPkgs is out of date: regenerate with 'go generate'\n%s", diff.Diff("stdPkgs", []byte(have), "want", []byte(want)))
    33  	}
    34  }
    35  

View as plain text