github.com/gopherjs/gopherjs@v1.19.0-beta1.0.20240506212314-27071a8796e4/tests/gorepo/gorepo_test.go (about)

     1  package gorepo_test
     2  
     3  import (
     4  	"os"
     5  	"os/exec"
     6  	"runtime"
     7  	"testing"
     8  )
     9  
    10  // Go repository basic compiler tests, and regression tests for fixed compiler bugs.
    11  func TestGoRepositoryCompilerTests(t *testing.T) {
    12  	if testing.Short() {
    13  		t.Skip("skipping Go repository tests in the short mode")
    14  	}
    15  	if runtime.GOOS == "js" {
    16  		t.Skip("test meant to be run using normal Go compiler (needs os/exec)")
    17  	}
    18  
    19  	args := []string{"go", "run", "run.go", "-summary"}
    20  	if testing.Verbose() {
    21  		args = append(args, "-v")
    22  	}
    23  
    24  	shards := os.Getenv("CIRCLE_NODE_TOTAL")
    25  	shard := os.Getenv("CIRCLE_NODE_INDEX")
    26  	if shards != "" && shard != "" {
    27  		// We are running under CircleCI parallel test job, so we need to shard execution.
    28  		args = append(args, "-shard="+shard, "-shards="+shards)
    29  		// CircleCI reports a lot more cores than we can actually use, so we have to limit concurrency.
    30  		args = append(args, "-n=2", "-l=2")
    31  	}
    32  
    33  	cmd := exec.Command(args[0], args[1:]...)
    34  	cmd.Stdout = os.Stdout
    35  	cmd.Stderr = os.Stdout
    36  	err := cmd.Run()
    37  	if err != nil {
    38  		t.Fatal(err)
    39  	}
    40  }