wpilibsuite / allwpilib

Official Repository of WPILibJ and WPILibC
https://wpilib.org/
Other
1.08k stars 611 forks source link

Hardcode random seed used for wpimath tests #7381

Open calcmogul opened 1 week ago

calcmogul commented 1 week ago

The tests often use physics sim classes that inject measurement noise. We should hardcode the random seed so the tests are deterministic. This will eliminate a source of test flakiness we've been seeing.

The seed could probably be set in wpimath/src/test/native/cpp/main.cpp before the tests are run.

rzblue commented 1 week ago

Is there any reason not to hardcode the seed across the board (ie, not just for tests)?

Either way, this requires a refactor of how noise is generated for the sim classes- the pseudorandom generator would need to be retained with the class instance rather than being recreated with a random seed each update.