gotest.tools/gotestsum@v1.11.0/cmd/testdata/postrunhook/main.go (about)

     1  package main
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  	"os"
     7  	"sort"
     8  	"strings"
     9  )
    10  
    11  func main() {
    12  	if err := run(); err != nil {
    13  		fmt.Fprintln(os.Stderr, err.Error())
    14  		os.Exit(1)
    15  	}
    16  }
    17  
    18  func run() error {
    19  	environ := os.Environ()
    20  	sort.Strings(environ)
    21  	for _, v := range environ {
    22  		for _, prefix := range []string{"TESTS_", "GOTESTSUM_"} {
    23  			if strings.HasPrefix(v, prefix) {
    24  				fmt.Println(v)
    25  			}
    26  		}
    27  	}
    28  
    29  	err := os.Getenv("TEST_STUB_ERROR")
    30  	if err != "" {
    31  		return errors.New(err)
    32  	}
    33  	return nil
    34  }