I have the following directory layout:

├── bar
│   └── bar_test.go
├── foo
│   └── foo_test.go
├── go.mod
└── go.sum


foo_test.go:
package main

import (
    "fmt"
    "testing"
)

func TestHelloWorld(t *testing.T) {
    fmt.Println("hello, foo")
    t.Log("hi, foo")
}

bar_test.go:
package bar

import (
    "fmt"
    "testing"
)

func TestGreeting(t *testing.T) {
    fmt.Println("hello, bar")
    t.Log("hi, bar")
}


$ go test -count=1 -v ./...
=== RUN   TestGreeting
hello, bar
    bar_test.go:10: hi, bar
--- PASS: TestGreeting (0.00s)
PASS
ok      yao.org/lang/bar    0.814s
=== RUN   TestHelloWorld
hello, foo
    foo_test.go:10: hi, foo
--- PASS: TestHelloWorld (0.00s)
PASS
ok      yao.org/lang/foo    0.518s

$ go test -count=1  ./...
ok      yao.org/lang/bar    0.115s
ok      yao.org/lang/foo    0.210s

foo$ go test -v -count=1
=== RUN   TestHelloWorld
hello, foo
    foo_test.go:10: hi, foo
--- PASS: TestHelloWorld (0.00s)
PASS
ok      yao.org/lang/foo    0.271s

foo$ go test -count=1
hello, foo
PASS
ok      yao.org/lang/foo    0.105s

I found the following different effects on two test modes by -v flag.

1. -v enables the output of fmt.Println and T.Log statements in package 
list mode.
2. -v enables the output of T.Log statements in local directory mode.

I browsed https://pkg.go.dev/cmd/go. But I failed to find a description of
this difference. Does this difference work as designed? If yes, can we 
document
it explicitly?

I am using go version go1.19.1 darwin/amd64.

Jingguo

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/08c254c2-fcd9-4449-8625-cbf912f12f73n%40googlegroups.com.

Reply via email to