Permalink
Browse files

compiler/natives/src/internal/testenv: Override HasExec to say no for…

… GOARCH=js.

We cannot run tests that do exec.Command when GOARCH=js. Instead of
disabling individual tests, update testenv.HasExec to say no.

TestMutexMisuse in sync package was one such test. It begins with:

	func TestMutexMisuse(t *testing.T) {
		testenv.MustHaveExec(t)

As a result of this change, it no longer runs and fixes the following
issue:

	$ gopherjs test sync
	--- FAIL: TestMutexMisuse (0.01s)

/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/
test.017024481:1414
	          throw new Error(msg);
	                ^
	Error: runtime error: native function not implemented:
syscall.runtime_BeforeFork
	    at $callDeferred
(/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs
/test.017024481:1414:17)
	    at $panic
(/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs
/test.017024481:1453:3)
	    at $b (/testing/testing.go:644:5)
	    at $callDeferred
(/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs
/test.017024481:1426:23)
	    at $panic
(/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs
/test.017024481:1453:3)
	    at $throwRuntimeError
(/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs
/runtime.go:31:4)
	    at $packages.syscall.runtime_BeforeFork
(/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs
/test.017024481:4084:3)
	    at $packages.syscall.forkAndExecInChild (/syscall/exec_bsd.go:68:3)
	    at $packages.syscall.forkExec (/syscall/exec_unix.go:193:3)
	    at Object.$packages.syscall.StartProcess (FAIL	sync	1.051s
  • Loading branch information...
1 parent e6dec35 commit e3c80b5dd5cac9b106f1879e2f2aa28d0bf272cf @shurcooL shurcooL committed Dec 14, 2016
Showing with 26 additions and 0 deletions.
  1. +26 −0 compiler/natives/src/internal/testenv/testenv.go
@@ -0,0 +1,26 @@
+// +build js
+
+package testenv
+
+import (
+ "runtime"
+ "strings"
+)
+
+// HasExec reports whether the current system can start new processes
+// using os.StartProcess or (more commonly) exec.Command.
+func HasExec() bool {
+ switch runtime.GOOS {
+ case "nacl":
+ return false
+ case "darwin":
+ if strings.HasPrefix(runtime.GOARCH, "arm") {
+ return false
+ }
+ }
+ switch runtime.GOARCH {
+ case "js":
+ return false
+ }
+ return true
+}

0 comments on commit e3c80b5

Please sign in to comment.