zacho2 / clock Goto Github PK
View Code? Open in Web Editor NEWThis project forked from benbjohnson/clock
Clock is a small library for mocking time in Go.
License: MIT License
This project forked from benbjohnson/clock
Clock is a small library for mocking time in Go.
License: MIT License
Another test race found by running go test -race -count=10000
Output:
==================
WARNING: DATA RACE
Write at 0x00c4200fc220 by goroutine 60:
sync/atomic.StoreInt32()
/usr/local/Cellar/go/1.8.3/libexec/src/runtime/race_amd64.s:229 +0xb
clock.TestClock_Ticker.func1()
/Users/zkipp/go/src/clock/clock_test.go:113 +0x4d
Previous write at 0x00c4200fc220 by goroutine 59:
clock.TestClock_Ticker()
/Users/zkipp/go/src/clock/clock_test.go:126 +0x1d6
testing.tRunner()
/usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107
Goroutine 60 (running) created at:
clock.TestClock_Ticker()
/Users/zkipp/go/src/clock/clock_test.go:114 +0xb3
testing.tRunner()
/usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107
Goroutine 59 (running) created at:
testing.(*T).Run()
/usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:697 +0x543
testing.runTests.func1()
/usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:882 +0xaa
testing.tRunner()
/usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:657 +0x107
testing.runTests()
/usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:888 +0x4e0
testing.(*M).Run()
/usr/local/Cellar/go/1.8.3/libexec/src/testing/testing.go:822 +0x1c3
main.main()
clock/_test/_testmain.go:90 +0x20f
==================
--- FAIL: TestClock_Ticker (0.10s)
clock_test.go:127: too early
testing.go:610: race detected during execution of test
If Timer.Stop() is called when an internal Tick() occurs which marks the underlying Timer as stopped, a race occurs for writes to the variable stopped
. See the following race detector output (some verbose output removed):
==================
WARNING: DATA RACE
Read at 0x00c4201d1800 by goroutine 126:
github.com/Zacho2/clock.(*Timer).Stop()
/Users/zkipp/go/src/github.com/Zacho2/clock/clock.go:255 +0xac
Previous write at 0x00c4201d1800 by goroutine 124:
github.com/Zacho2/clock.(*internalTimer).Tick()
/Users/zkipp/go/src/github.com/Zacho2/clock/clock.go:288 +0xbd
github.com/Zacho2/clock.(*Mock).runNextTimer()
/Users/zkipp/go/src/github.com/Zacho2/clock/clock.go:136 +0x1f1
github.com/Zacho2/clock.(*Mock).Add()
/Users/zkipp/go/src/github.com/Zacho2/clock/clock.go:76 +0xd7
==================
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.