go-hep.org/x/hep@v0.38.1/hep_test.go (about)

     1  // Copyright ©2017 The go-hep 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 hep
     6  
     7  import (
     8  	"bytes"
     9  	"os/exec"
    10  	"testing"
    11  )
    12  
    13  func TestGofmt(t *testing.T) {
    14  	cmd := exec.Command("go", "tool", "golang.org/x/tools/cmd/goimports", "-d", ".")
    15  	buf := new(bytes.Buffer)
    16  	cmd.Stdout = buf
    17  	cmd.Stderr = buf
    18  
    19  	err := cmd.Run()
    20  	if err != nil {
    21  		t.Fatalf("error running goimports:\n%s\n%v", buf.String(), err)
    22  	}
    23  
    24  	if len(buf.Bytes()) != 0 {
    25  		t.Fatalf("some files were not gofmt'ed:\n%s\n", buf.String())
    26  	}
    27  }