-
Notifications
You must be signed in to change notification settings - Fork 570
Go 1.8 support (version bump to GopherJS 1.8-1). #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Looking at fixing It currently fails without much output in CI:
Adding
Also, we may need to add support for the new |
Narrowed down the cause of var deepEqualTests = []DeepEqualTest{
// ... all the old ones continue to work okay.
// but the new "Possible loops" cause trouble.
// Commenting them out causes TestDeepEqual to pass.
// Possible loops.
{&loop1, &loop1, true},
{&loop1, &loop2, true},
{&loopy1, &loopy1, true},
{&loopy1, &loopy2, true},
} After that, only |
More specifically, it's only these cases that are problematic: // Possible loops.
{&loop1, &loop1, true}, // ok
{&loop1, &loop2, true}, // fails
{&loopy1, &loopy1, true}, // ok
{&loopy1, &loopy2, true}, // fails And |
Great, CI is passing now! ✅ Next up is addressing remaining TODOs. Most of the failures that I fixed weren't regressions in behavior with 1.8, but rather known/existing issues being triggered. I didn't have to do much to get previously working things to continue to work. But first, I will rewrite history and squash some related commits to make the PR smaller and each commit more logical. |
Ok, I've done an interactive rebase to squash/re-arrange commits and clean up the history to have more logical, well separated changes in each commit. Since this is now passing CI, do you want to look over it @neelance and leave any first-order comments that you might have? Next up we should look at the remaining TODOs inside the code and see if we can do anything about them. That said, for anyone eager to try this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far. Added some comments, except where you already have TODOs.
@@ -90,8 +90,6 @@ func importWithSrcDir(path string, srcDir string, mode build.ImportMode, install | |||
pkg.GoFiles = []string{"rand.go", "util.go"} | |||
case "crypto/x509": | |||
pkg.CgoFiles = nil | |||
case "hash/crc32": | |||
pkg.GoFiles = []string{"crc32.go", "crc32_generic.go"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yey.
// should override TestGamma specifically and not the package-wide tolerances, | ||
// because this will cause many other tests to be less accurate. Or maybe this | ||
// is fine? | ||
func close(a, b float64) bool { return tolerance(a, b, 4e-14) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still wondering where exactly we're losing precision. I guess it is because we're using some JS native math functions which are implemented slightly differently than the Go ones. Investigate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea what's going on here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made #589 to track this.
|
||
package reflect | ||
|
||
func Swapper(slice interface{}) func(i, j int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reflect.Swapper
, interesting addition. I guess this is because of sort
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is to enable the new way of sorting in 1.8.
func main() { | ||
m := testing.MainStart(matchString, tests, benchmarks, examples) | ||
m := testing.MainStart(testdeps.TestDeps{}, tests, benchmarks, examples) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is matchString
implemented now? As far as I remember this was done to avoid the dependency from testing
to regexp
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message of 3b29828 says:
The commit message of that go commit explains what happened.
It seems that it's still implemented the same way, using regexp
. They've just shuffled imports around into testdeps
package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I like it.
See golang/go@c56cc9b?w=1. Fixes the following issue when running gopherjs test: _testmain.go:162:25: cannot use matchString (value of type func(pat string, str string) (result bool, err error)) as testing.testDeps value in argument to testing.MainStart: missing method MatchString
By now, the crc32 package makes use of functions implemented in architecture-specific files. GopherJS ends up taking on the generic "other architectures" configuration that works when there isn't an architecture-specific CRC32-IEEE algorithm, nor an architecture-specific CRC32-C algorithm. In the future, it's possible hash/crc32 performance can be improved by doing something architecture-specific, but this will do for now. Fixes the following build issue for hash/crc32 package: $ gopherjs build hash/crc32 ../../../usr/local/go/src/hash/crc32/crc32.go:83:23: undeclared name: archAvailableCastagnoli ../../../usr/local/go/src/hash/crc32/crc32.go:86:3: undeclared name: archInitCastagnoli ../../../usr/local/go/src/hash/crc32/crc32.go:87:22: undeclared name: archUpdateCastagnoli ../../../usr/local/go/src/hash/crc32/crc32.go:107:17: undeclared name: archAvailableIEEE ../../../usr/local/go/src/hash/crc32/crc32.go:110:3: undeclared name: archInitIEEE ../../../usr/local/go/src/hash/crc32/crc32.go:111:16: undeclared name: archUpdateIEEE
It has been removed from Go repository in golang/go@7e9f420.
There were some new actions added in Go 1.8 (and 1.7), such as "errorcheckwithauto" in golang/go@d586aae. Since new action wasn't one of the ones we'd skip, it caused TestGoRepositoryCompilerTests to fail with errors like: # go run run.go -- live.go unexpected skip for live.go: Instead, skip all actions (even unfamiliar ones) except the ones we explicitly want to run.
There were 3 failing tests. One was a modified old test that wasn't previously run due to a build constraint (that has been removed in 1.8). It fails due to a compiler bug, see #551 that tracks it. Two were new tests that use unsupported packages/funcs (such as "unsafe", runtime.FuncForPC, runtime.Callers) and failed as a result.
…tion, implement runtime_SemacquireMutex. SetMutexProfileFraction was added in Go 1.8, and needs to be explicitly added to "runtime" package in GopherJS, because GopherJS doesn't inherit most of upstream .go files of "runtime" package. Document that it's not supported at this time. Implement runtime_SemacquireMutex with same code as runtime_Semacquire. Fixes many build errors. Fixes net/rpc/jsonrpc tests: $ gopherjs test net/rpc/jsonrpc /Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:1414 throw new Error(msg); ^ Error: runtime error: native function not implemented: sync.runtime_SemacquireMutex at $callDeferred (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:1414:17) at $panic (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:1453:3) at $throwRuntimeError (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/runtime.go:31:4) at $packages.sync.runtime_SemacquireMutex (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:3109:3) at $packages.sync.Mutex.ptr.Lock (/sync/mutex.go:87:5) at $packages.net/rpc.Server.ptr.sendResponse (/net/rpc/server.go:365:3) at $packages.net/rpc.service.ptr.call (/net/rpc/server.go:394:3) at f (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:52:21) at $goroutine (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:1473:19) at Timeout.$runScheduled [as _onTimeout] (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.438174805:1514:7) at tryOnTimeout (timers.js:224:11) at Timer.listOnTimeout (timers.js:198:5) FAIL net/rpc/jsonrpc 1.813s
… 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
These were implemented in pure Go before. In Go 1.8, they're now using stubs and are implemented in assembly. This causes the following errors in GopherJS: Error: runtime error: native function not implemented: math.Cosh Error: runtime error: native function not implemented: math.Sinh Error: runtime error: native function not implemented: math.Tanh Implement them via JavaScript math object, analogous to Cos, Sin, Tan.
…ix TestGamma. Before this change, TestGamma fails with: $ gopherjs test --short --minify --run='^Test' math --- FAIL: TestGamma (0.08s) all_test.go:2234: Gamma(171) = 7.257415615307958e+306, want 7.257415615307999e+306 all_test.go:2234: Gamma(171.6) = 1.5858969096672286e+308, want 1.5858969096672565e+308 all_test.go:2234: Gamma(171.624) = 1.794211759924792e+308, want 1.7942117599248104e+308 all_test.go:2234: Gamma(-171.5) = 1.93162654317124e-310, want 1.9316265431712e-310 FAIL FAIL math 0.786s The tolerances are defined with these values upstream in Go 1.8: func close(a, b float64) bool { return tolerance(a, b, 1e-14) } func veryclose(a, b float64) bool { return tolerance(a, b, 4e-16) }
…me.SetFinalizer. Document that runtime.SetFinalizer is unsupported.
Based on go4 version, with fast path from 1.8 standard library. Fixes TestSwapper.
Allows all reflect tests to pass. TODO: Fix the underlying issue. We may need to implement pointer cycle detection here.
…terTests testcases. Allows all database/sql/driver tests to pass. TODO: Fix the underlying issue.
It fails when source map support is disabled, but passes when it's enabled. But CI has it disabled at this time.
Its functionality is now available in standard library as of Go 1.8. See kardianos/osext#20.
Implementation is noop and does not change max stack, instead it always returns the initial value. This is similar to SetGCPercent. Package runtime/debug is not officially supported, so there are no hard requirements for functionality here. Use initial value for 32-bit value, which is 250 MB (but 250000000). Source: https://github.com/golang/go/blob/ea7d9e6a52ca64c200dcc75621e75f209ceceace/src/runtime/proc.go#L113-L120. Fixes new compress/flate test added in golang/go@9c3630f: $ gopherjs test --short --run='^TestMaxStackSize$' compress/flate --- FAIL: TestMaxStackSize (0.10s) /Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1414 throw new Error(msg); ^ Error: runtime error: native function not implemented: runtime/debug.setMaxStack at $callDeferred (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1414:17) at $panic (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1453:3) at $b (/testing/testing.go:622:5) at $callDeferred (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1426:23) at $panic (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1453:3) at $throwRuntimeError (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/runtime.go:31:4) at setMaxStack (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:25166:3) at Object.SetMaxStack (/runtime/debug/garbage.go:116:3) at TestMaxStackSize (/compress/flate/deflate_test.go:872:3) at tRunner (/testing/testing.go:657:3) at $goroutine (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1473:19) at Timeout.$runScheduled [as _onTimeout] (/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.240135062:1514:7) at ontimeout (timers.js:365:14) at tryOnTimeout (timers.js:237:5) at Timer.listOnTimeout (timers.js:207:5) FAIL compress/flate 0.748s
…mentation. Replace it with a not-implemented-erroring one. This fixes the issue #583 where on darwin a call to os.Getwd is made, which makes syscalls, and causes a warning to be printed to console: warning: system calls not available, see https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md os.Executable is documented to be unsupported on nacl: // Executable is not supported on nacl or OpenBSD (unless procfs is // mounted.) GOARCH=js is similar to nacl in many ways, so it's pretty expected os.Executable wouldn't be supported here either. Use https://github.com/golang/go/blob/990124da2a6ca5a54b38733b51018e2f8758cfae/src/os/executable_procfs.go#L21 as template for error message. Fixes #583.
Done with go1.8 (final), latest version of vfsgendev: go generate ./...
I've rebased this on top of latest I see there's one failure:
That means a previously known failure is now passing. It might be because of something that was fixed in I'll need to look into that after I get back from the Go 1.8 release party! 🎉 |
The unexpected passing test above makes perfect sense. Here it is:
And #551 is now resolved (on master). So that needs to be updated to a "known pass". Edit: Done in 16fddcc. |
+1 - go1.8 support looking good on my projects! |
GopherJS 1.8-1 is now released and available on See blog post about it here: https://medium.com/gopherjs/gopherjs-1-8-1-is-released-b4473712ab95#.a8a6f3ltk. See tweet here: https://twitter.com/GopherJS/status/832708146443399170. Thanks everyone! 🎉 |
This is a WIP PR to track work to support Go 1.8.
go1.8beta1
has been released.Each commit is bite-sized, with rationale and description, and fixes a specific issue.
It's now at a stage where only some of the standard library tests are failing. I'll make a table to track remaining work.
Update: All failing tests have been fixed, but there are some known TODOs remaining in code.
database/sql/driver
Test Failure Details
hash/crc32
math
io
reflect
runtime
net/rpc/jsonrpc
Test Failure Details
sync
Test Failure Details