Skip to content

Commit

Permalink
Merge pull request #119 from DeepBlueRobotics/fix-each-test-taking-lo…
Browse files Browse the repository at this point in the history
…nger-than-the-last

Fix Each test (in the same process) takes about 3 seconds longer than the previous one #116.
  • Loading branch information
brettle authored Jul 17, 2024
2 parents d453216 + a84556f commit 7500719
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,11 @@ public void run() throws InstantiationException, IllegalAccessException,
// HAL must be initialized or SmartDashboard might not work.
HAL.initialize(500, 0);
waitForUserToStart(worldFile.getAbsolutePath());

// Restart timing before robot is constructed to ensure that timed callbacks added during
// the constructor (and our own onRobotInit callback) work properly.
SimHooks.restartTiming();
SimHooks.pauseTiming();
try (TimedRobot robot = robotConstructor.get();
var endNotifier = new Notifier(() -> {
endCompetition(robot);
Expand All @@ -784,7 +789,6 @@ public void run() throws InstantiationException, IllegalAccessException,
robot.getPeriod(), -robot.getPeriod());

this.endNotifier = endNotifier;
SimHooks.restartTiming();
SimHooks.resumeTiming();
isRobotCodeRunning = true;
try {
Expand Down

0 comments on commit 7500719

Please sign in to comment.