...

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

Documentation: cmd/compile/internal/ssa/_gen

     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
    14cat >main_test.go <<-EOF
    15	//go:build ignore
    16
    17	package main
    18
    19	import "testing"
    20
    21	func TestCoverage(t *testing.T) { main() }
    22EOF
    23
    24go test -run='^TestCoverage$' -coverprofile=cover.out "$@" *.go
    25
    26rm -f main_test.go

View as plain text