-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix-file-locking #91
Fix-file-locking #91
Conversation
…tion() is always called to at least partially fix #85. Also makes WebotsSimulator constructor take the robot class instead of making the run() method take a robot instance. That helps discourage the test code from instantiating a robot because doing so might cause WPILib to try to start a NetworkTables server when another test already has one running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! You opened this while I was writing you a mattermost message about tests not working on my machine. This PR fixes that! :D
Side note: The first time I ran this, testShaftRotatesInAutonomous
failed, but I've tried it again, and it seems to work now, so it may just be a case of a non-ideal testing environment (i.e. me running too many programs at once).
*/ | ||
public WebotsSimulator(String worldFilePath) throws FileNotFoundException { | ||
public WebotsSimulator(String worldFilePath, | ||
Class<? extends TimedRobot> cls) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend taking a Supplier<TimedRobot>
instead, and then passing Robot::new
instead of Robot.class
. This would allow you to avoid the reflection later and support robot classes with non-default constructors.
} | ||
} | ||
|
||
static private synchronized void acquireFileLock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static private synchronized void acquireFileLock() | |
private static synchronized void acquireFileLock() |
Whoops, I hit approve while forgetting that I had suggestions (too excited about getting tests working) :/ My bad. |
Opened issue #94 to cover this. |
Move file locking to WebotsSimulator to fix #90 and ensure endCompetition() is always called to at least partially fix #85.
Also makes WebotsSimulator constructor take the robot class instead of making the run() method take a robot instance. That helps discourage the test code from instantiating a robot because doing so might cause WPILib to try to start a NetworkTables server when another test already has one running.