Fix ConcurrentModificationException in CommandScheduler (#1938)

This commit is contained in:
Oblarg
2019-10-18 10:56:12 -04:00
committed by Peter Johnson
parent bb0b207d2f
commit f4eedf597f
5 changed files with 78 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ package edu.wpi.first.wpilibj2.command;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.mockito.Mockito.verify;
class ScheduleCommandTest extends CommandTestBase {
@@ -28,4 +29,19 @@ class ScheduleCommandTest extends CommandTestBase {
verify(command1).schedule();
verify(command2).schedule();
}
@Test
void scheduleCommandDuringRunTest() {
CommandScheduler scheduler = CommandScheduler.getInstance();
InstantCommand toSchedule = new InstantCommand();
ScheduleCommand scheduleCommand = new ScheduleCommand(toSchedule);
SequentialCommandGroup group =
new SequentialCommandGroup(new InstantCommand(), scheduleCommand);
scheduler.schedule(group);
scheduler.schedule(new InstantCommand().perpetually());
scheduler.run();
assertDoesNotThrow(scheduler::run);
}
}