leanovate / gopter

GOlang Property TestER
MIT License
599 stars 40 forks source link

Tests failing on master branch #78

Closed Porges closed 3 years ago

Porges commented 3 years ago

For example:

$ go test ./...
--- FAIL: TestRunnerParallelWorkers (3.02s)
    runner_test.go:174: [0] expected result time to be positive number but got 0s
    runner_test.go:174: [1] expected result time to be positive number but got 0s
    runner_test.go:174: [2] expected result time to be positive number but got 0s
! always fail: Falsified after 0 passed tests.
ARG_0: 0
ARG_0_ORIGINAL (1 shrinks): 299854320
Elapsed time: 0s
! always fail: Falsified after 0 passed tests.
ARG_0: 0
ARG_0_ORIGINAL (1 shrinks): 299854320
Elapsed time: 0s
FAIL
FAIL    github.com/leanovate/gopter     3.320s
ok      github.com/leanovate/gopter/arbitrary   0.683s
ok      github.com/leanovate/gopter/commands    0.739s
--- FAIL: TestOneConstOf (0.00s)
    one_of_test.go:51: Not all consts where generated: map[string]bool{"four":true, "two":true}
--- FAIL: TestOneGenOf (0.00s)
    one_of_test.go:51: Not all consts where generated: map[string]bool{"four":true, "three":true}
+ PtrOf: OK, passed 100 tests.
Elapsed time: 2.0028ms
--- FAIL: TestWeighted (0.01s)
    weighted_test.go:33: Result 250 for A falls outside acceptable range 50, 150
    weighted_test.go:33: Result 356 for B falls outside acceptable range 150, 250
    weighted_test.go:33: Result 394 for C falls outside acceptable range 650, 750
FAIL
FAIL    github.com/leanovate/gopter/gen 1.632s
ok      github.com/leanovate/gopter/prop        0.197s
FAIL
untoldwind commented 3 years ago

Looks like a typical "works for me" situation ;) Seriously though: I checked the travis-build, which was ok and just now added an additional github action (https://github.com/leanovate/gopter/actions) and they are working as well.

Not sure what the cause of this might be. Maybe it is the go version you are using or maybe your build-cache is messed up?

Porges commented 3 years ago

@untoldwind this is a fresh checkout with 1.15, at commit 9ec843d8. I’m on Windows, I don’t know if that (weirdly) could be part of the problem?

Porges commented 3 years ago

Actually TestOneConstOf and TestOneGenOf seem to be probabilistic and won’t always pass (due to commonOneOfTest).

Porges commented 3 years ago

(as to why the distribution of values generated in commonOneOfTest is so terrible, I don’t have an answer…)

untoldwind commented 3 years ago

It's been a very long time since I developed on windows, so I had to setup a VM and indeed there are some tests that fail there that are working perfectly fine on linux. It looks like the random number generator (math/rand) behaves differently on both systems, which is quiet surprising ... I need some time to get to the bottom of this ;)

untoldwind commented 3 years ago

Looks like the problem was more related to seeding rather than the rng. I fixed the tweaked the tests to use fixed seed. Please check if there are now working on your system as well.

Porges commented 3 years ago

@untoldwind Looks good, thanks!