| 1 |
|
| 2 |
[short] skip |
| 3 |
|
| 4 |
# collect coverage profile in text format |
| 5 |
go test -coverprofile=blah.prof prog.go prog_test.go |
| 6 |
|
| 7 |
# should not contain cmd-line pseudo-import-path |
| 8 |
grep prog.go blah.prof |
| 9 |
grep $PWD blah.prof |
| 10 |
! grep command-line-arguments blah.prof |
| 11 |
|
| 12 |
-- prog.go -- |
| 13 |
package main |
| 14 |
|
| 15 |
func Mumble(x int) int { |
| 16 |
if x < 0 { |
| 17 |
return -x |
| 18 |
} |
| 19 |
return 42 |
| 20 |
} |
| 21 |
|
| 22 |
func Grumble(y int) int { |
| 23 |
return -y |
| 24 |
} |
| 25 |
|
| 26 |
func main() { |
| 27 |
} |
| 28 |
|
| 29 |
-- prog_test.go -- |
| 30 |
package main |
| 31 |
|
| 32 |
import ( |
| 33 |
"testing" |
| 34 |
) |
| 35 |
|
| 36 |
func TestMumble(t *testing.T) { |
| 37 |
if x := Mumble(10); x != 42 { |
| 38 |
t.Errorf("Mumble(%d): got %d want %d", 10, x, 42) |
| 39 |
} |
| 40 |
} |