go.dbus icon indicating copy to clipboard operation
go.dbus copied to clipboard

Fix flaky tests: don't rely on map iteration order.

Open bradfitz opened this issue 11 years ago • 4 comments
trafficstars

Enumerating maps is random in Go. Due to a bug, in Go 1.1 and Go 1.2, enumeration over small maps had a deterministic order. in Go 1.3, the enumeration is always random.

bradfitz avatar May 19 '14 18:05 bradfitz

Please merge this patch.

gpaul avatar May 27 '14 08:05 gpaul

@gpaul @bradfitz I would like to merge this in to github.com/godbus/dbus but I don't see the test which relies on the ordering...

philips avatar Sep 16 '14 22:09 philips

TestFormatVariant.

I found this due to Google's internal testing infrastructure. We're using this patch internally to make tests happy.

Verify with:

$ go get -u github.com/godbus/dbus $ go test -cpu=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 github.com/godbus/dbus --- FAIL: TestFormatVariant (0.00s) variant_test.go:27: test 10: got "{"two": 2, "one": 1}", wanted "{"one": 1, "two": 2}" --- FAIL: TestFormatVariant (0.00s) variant_test.go:27: test 10: got "{"two": 2, "one": 1}", wanted "{"one": 1, "two": 2}" --- FAIL: TestFormatVariant (0.00s) variant_test.go:27: test 10: got "{"two": 2, "one": 1}", wanted "{"one": 1, "two": 2}" --- FAIL: TestFormatVariant (0.00s) variant_test.go:27: test 10: got "{"two": 2, "one": 1}", wanted "{"one": 1, "two": 2}" --- FAIL: TestFormatVariant (0.00s) variant_test.go:27: test 10: got "{"two": 2, "one": 1}", wanted "{"one": 1, "two": 2}" --- FAIL: TestFormatVariant (0.00s) variant_test.go:27: test 10: got "{"two": 2, "one": 1}", wanted "{"one": 1, "two": 2}" --- FAIL: TestFormatVariant (0.00s) variant_test.go:27: test 10: got "{"two": 2, "one": 1}", wanted "{"one": 1, "two": 2}" --- FAIL: TestFormatVariant (0.00s) variant_test.go:27: test 10: got "{"two": 2, "one": 1}", wanted "{"one": 1, "two": 2}" --- FAIL: TestFormatVariant (0.00s) variant_test.go:27: test 10: got "{"two": 2, "one": 1}", wanted "{"one": 1, "two": 2}" FAIL FAIL github.com/godbus/dbus 0.201s

bradfitz avatar Sep 17 '14 15:09 bradfitz

@bradfitz ah! thank you. merged into github.com/godbus/dbus

philips avatar Sep 17 '14 15:09 philips