github.com/gopherjs/gopherjs@v1.19.0-beta1.0.20240506212314-27071a8796e4/tests/syscall_legacy_test.go (about) 1 package tests 2 3 import ( 4 "os/exec" 5 "runtime" 6 "testing" 7 ) 8 9 // TestLegacySyscall tests raw syscall invocation using node_syscall extension. 10 // 11 // This mode is largely deprecated (e.g. we build standard library with GOOS=js), 12 // but we support using the extension when "legacy_syscall" build tag is set. 13 // This test can be removed after we stop supporting node_syscall extension. 14 func TestLegacySyscall(t *testing.T) { 15 if runtime.GOOS != "linux" { 16 t.Skip("This test is supported only under Linux") 17 } 18 cmd := exec.Command("gopherjs", "run", "--tags=legacy_syscall", "./testdata/legacy_syscall/main.go") 19 out, err := cmd.CombinedOutput() 20 got := string(out) 21 if err != nil { 22 t.Log(got) 23 t.Fatalf("Failed to run test code under gopherjs: %s", err) 24 } 25 if want := "Hello, world!\n"; got != want { 26 t.Errorf("Got wrong output: %q. Want: %q.", got, want) 27 } 28 }