Text file src/cmd/compile/internal/ssa/_gen/cover.bash

     1  #!/usr/bin/env bash
     2  # Copyright 2020 The Go Authors. All rights reserved.
     3  # Use of this source code is governed by a BSD-style
     4  # license that can be found in the LICENSE file.
     5  
     6  # A quick and dirty way to obtain code coverage from rulegen's main func. For
     7  # example:
     8  #
     9  #     ./cover.bash && go tool cover -html=cover.out
    10  #
    11  # This script is needed to set up a temporary test file, so that we don't break
    12  # regular 'go run .' usage to run the generator.
    13  
    14  cat >main_test.go <<-EOF
    15  	//go:build ignore
    16  
    17  	package main
    18  
    19  	import "testing"
    20  
    21  	func TestCoverage(t *testing.T) { main() }
    22  EOF
    23  
    24  go test -run='^TestCoverage$' -coverprofile=cover.out "$@" *.go
    25  
    26  rm -f main_test.go
    27  

View as plain text