...

Source file src/cmd/relnote/relnote_test.go

Documentation: cmd/relnote

     1  // Copyright 2023 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 main
     6  
     7  import (
     8  	"flag"
     9  	"internal/testenv"
    10  	"io/fs"
    11  	"os"
    12  	"path/filepath"
    13  	"testing"
    14  
    15  	"golang.org/x/build/relnote"
    16  )
    17  
    18  var flagCheck = flag.Bool("check", false, "run API release note checks")
    19  
    20  // Check that each file in api/next has corresponding release note files in doc/next.
    21  func TestCheckAPIFragments(t *testing.T) {
    22  	if !*flagCheck {
    23  		t.Skip("-check not specified")
    24  	}
    25  	root := testenv.GOROOT(t)
    26  	rootFS := os.DirFS(root)
    27  	files, err := fs.Glob(rootFS, "api/next/*.txt")
    28  	if err != nil {
    29  		t.Fatal(err)
    30  	}
    31  	t.Logf("checking release notes for %d files in api/next", len(files))
    32  	docFS := os.DirFS(filepath.Join(root, "doc", "next"))
    33  	// Check that each api/next file has a corresponding release note fragment.
    34  	for _, apiFile := range files {
    35  		if err := relnote.CheckAPIFile(rootFS, apiFile, docFS, "doc/next"); err != nil {
    36  			t.Errorf("%s: %v", apiFile, err)
    37  		}
    38  	}
    39  }
    40  

View as plain text