diff --git a/circle.yml b/circle.yml index c25fc41a0..dfef8bbcb 100644 --- a/circle.yml +++ b/circle.yml @@ -20,7 +20,7 @@ test: - diff -u <(echo -n) <(go list ./compiler/natives/src/...) # All those packages should have // +build js. - gopherjs install -v net/http # Should build successfully (can't run tests, since only client is supported). - > - gopherjs test --minify -v --short + ulimit -s 10000 && gopherjs test --minify -v --short github.com/gopherjs/gopherjs/tests github.com/gopherjs/gopherjs/tests/main github.com/gopherjs/gopherjs/js diff --git a/tool.go b/tool.go index f129262c3..3760113de 100644 --- a/tool.go +++ b/tool.go @@ -750,9 +750,30 @@ func runNode(script string, args []string, dir string, quiet bool) error { } if runtime.GOOS != "windows" { - allArgs = append(allArgs, "--stack_size=10000", script) + // We've seen issues with stack space limits causing + // recursion-heavy standard library tests to fail (e.g., see + // https://github.com/gopherjs/gopherjs/pull/669#issuecomment-319319483). + // + // There are two separate limits in non-Windows environments: + // + // - OS process limit + // - Node.js (V8) limit + // + // GopherJS fetches the current OS process limit, and sets the + // Node.js limit to the same value. So both limits are kept in sync + // and can be controlled by setting OS process limit. E.g.: + // + // ulimit -s 10000 && gopherjs test + // + var r syscall.Rlimit + err := syscall.Getrlimit(syscall.RLIMIT_STACK, &r) + if err != nil { + return fmt.Errorf("failed to get stack size limit: %v", err) + } + allArgs = append(allArgs, fmt.Sprintf("--stack_size=%v", r.Cur/1000)) // Convert from bytes to KB. } + allArgs = append(allArgs, script) allArgs = append(allArgs, args...) node := exec.Command("node", allArgs...)