github.com/zxy12/go_duplicate_112_new@v0.0.0-20200807091221-747231827200/src/cmd/go/help_test.go (about)

     1  // Copyright 2018 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  // +build !nacl
     6  
     7  package main_test
     8  
     9  import (
    10  	"bytes"
    11  	"io/ioutil"
    12  	"testing"
    13  
    14  	"cmd/go/internal/help"
    15  )
    16  
    17  func TestDocsUpToDate(t *testing.T) {
    18  	buf := new(bytes.Buffer)
    19  	// Match the command in mkalldocs.sh that generates alldocs.go.
    20  	help.Help(buf, []string{"documentation"})
    21  	data, err := ioutil.ReadFile("alldocs.go")
    22  	if err != nil {
    23  		t.Fatalf("error reading alldocs.go: %v", err)
    24  	}
    25  	if !bytes.Equal(data, buf.Bytes()) {
    26  		t.Errorf("alldocs.go is not up to date; run mkalldocs.sh to regenerate it")
    27  	}
    28  }