I did a little more experimentation, and it looks like this is definitely 
the case on Go 1.7.3 on OSX:

With this file system layout:

$ tree
.
├── package1
│   └── package1_test.go
└── package2
    └── package2_test.go

2 directories, 2 files


And this test (and a similar test in package2_test.go that sleeps for 2 
seconds)

$ cat package1/package1_test.go
package package1

import (
"log"
"testing"
"time"
)

func TestPackage1(t *testing.T) {

log.Printf("TestPackage1 sleeping")
time.Sleep(time.Second * 10)
log.Printf("/TestPackage1 sleeping")

}

I'm getting this output:

$ go test -v ./...
=== RUN   TestPackage1
2017/10/16 15:37:21 TestPackage1 sleeping
2017/10/16 15:37:31 /TestPackage1 sleeping
--- PASS: TestPackage1 (10.00s)
PASS
ok  github.com/tleyden/go-tests-parallel/package1 10.007s
=== RUN   TestPackage2
2017/10/16 15:37:21 TestPackage2 sleeping
2017/10/16 15:37:23 /TestPackage2 sleeping
--- PASS: TestPackage2 (2.00s)
PASS
ok  github.com/tleyden/go-tests-parallel/package2 2.010s


I was expecting that TestPackage2 would start after TestPackage1 and all 
tests in package1 completed.


I tried adding "-parallel 1" to the args, but it didn't make any 
difference.  Is there any way to serialize the execution of tests when 
using "..." to expand packages?


On Monday, October 16, 2017 at 3:21:49 PM UTC-7, Traun Leyden wrote:
>
>
> If tests are run via:
>
> go test -v  github.com/org/repo/...
>
> will there be any additional parallelism compared to running:
>
> go test -v  github.com/org/repo/package1 
> go test -v  github.com/org/repo/package2 
>
> ?
>
> I'm asking because I'm seeing cases in the log output where the timestamp 
> on later test appears earlier than timestamp on previous test in another 
> package:
>
> --- PASS: TestInPackage1 (1.31s)
> 2017-10-16 14:57:54.351853 ....
> PASS
> ok    github.com/org/repo/package1    174.584s
>
> === RUN   TestInPackage2
> 2017-10-16T14:55:00.824-07:00 ....
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to