github.com/goplusjs/gopherjs@v1.2.6-0.20211206034512-f187917453b8/tests/gorepo_test.go (about)

     1  package tests_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 runtime.GOARCH == "js" {
    13  		t.Skip("test meant to be run using normal Go compiler (needs os/exec)")
    14  	}
    15  
    16  	args := []string{"go", "run", "run.go", "-summary"}
    17  	if testing.Verbose() {
    18  		args = append(args, "-v")
    19  	}
    20  	cmd := exec.Command(args[0], args[1:]...)
    21  	cmd.Stdout = os.Stdout
    22  	cmd.Stderr = os.Stdout
    23  	err := cmd.Run()
    24  	if err != nil {
    25  		t.Fatal(err)
    26  	}
    27  }
    28  
    29  // Test that GopherJS can be vendored into a project, and then used to build Go programs.
    30  // See issue https://github.com/gopherjs/gopherjs/issues/415.
    31  func TestGopherJSCanBeVendored(t *testing.T) {
    32  	if runtime.GOARCH == "js" {
    33  		t.Skip("test meant to be run using normal Go compiler (needs os/exec)")
    34  	}
    35  	if runtime.GOOS == "windows" {
    36  		t.Skip("todo, skip vendor test on windows")
    37  	}
    38  
    39  	cmd := exec.Command("sh", "gopherjsvendored_test.sh")
    40  	cmd.Stderr = os.Stdout
    41  	got, err := cmd.Output()
    42  	if err != nil {
    43  		t.Fatal(err)
    44  	}
    45  	if want := "hello using js pkg\n"; string(got) != want {
    46  		t.Errorf("unexpected stdout from gopherjsvendored_test.sh:\ngot:\n%s\nwant:\n%s", got, want)
    47  	}
    48  }