tinygo
tinygo copied to clipboard
validation - see if timers logic works
This is a quick port of https://github.com/tinygo-org/tinygo/pull/1402 to current dev - seems to be functional...
@aykevl this is pretty much your code. Let me know if you'd sooner take it over.
Very nice. This code works on windows11.
package main
import (
"fmt"
"runtime"
"time"
)
func main() {
run()
fmt.Printf("done\n")
}
func run() {
ch := time.After(1 * time.Second)
for {
select {
case <-ch:
fmt.Printf("expired\n")
return
default:
runtime.Gosched()
}
}
}
And with this change, the following tests will be OK. This is very nice.
- encoding/base64
- image/jpeg
- mime/quotedprintable
https://tinygo.org/docs/reference/lang-support/stdlib/
@aykevl what do you think? This would be a great feature to get in to this release.
@aykevl what do you think about this PR? It would be great to merge it! :smile_cat:
@kenbell perhaps you can also include some of the original commit message in this commit?
Looks like need to run go fmt:
Unformatted:
src/runtime/timer_go118.go
make: *** [Makefile:180: fmt-check] Error 1
@deadprogram - thanks, yeah. Hopefully fixed that. The MacOS builds seem to be unreliable with the test-case as well. I think we need to either tweak the test case, or exclude on MacOS. I'll try tweaking it next, see if it can be more reliable. I'm guessing the CI worker is being paged out or something so go routines aren't running at the resolution of the test case?
I am very excited about this feature.
Thank you @kenbell for actually getting it in, and thanks @aykevl for all the original work on it.
Now merging!
Hmm, seems like macOS has troubles passing CI https://github.com/tinygo-org/tinygo/runs/7972019922?check_suite_focus=true#step:12:19780
Trying to run it a third time now...
@deadprogram - might want to back this out from dev until it's more robust in CI. I've been gradually backing off the timing on the test case, but looks like not far enough to be reliable yet. :(
I'll take another pass at increasing the timeouts.