From 64bfdc1a696b8116a3ec08d000e5b5903a6c441d Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 4 Dec 2017 20:24:26 -0800 Subject: [PATCH] Bail out of the integration tests if enable fails (#792) A failure is much better then an infinite loop. --- .../src/FRCUserProgram/cpp/TestEnvironment.cpp | 12 +++++++++++- .../wpi/first/wpilibj/test/AbstractComsSetup.java | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/wpilibcIntegrationTests/src/FRCUserProgram/cpp/TestEnvironment.cpp b/wpilibcIntegrationTests/src/FRCUserProgram/cpp/TestEnvironment.cpp index cdd97880d9..1c8fb9cb08 100644 --- a/wpilibcIntegrationTests/src/FRCUserProgram/cpp/TestEnvironment.cpp +++ b/wpilibcIntegrationTests/src/FRCUserProgram/cpp/TestEnvironment.cpp @@ -43,10 +43,20 @@ class TestEnvironment : public testing::Environment { HAL_ObserveUserProgramStarting(); LiveWindow::GetInstance()->SetEnabled(false); - llvm::outs() << "Waiting for enable\n"; + llvm::outs() << "Started coms\n"; + int enableCounter = 0; while (!DriverStation::GetInstance().IsEnabled()) { + if (enableCounter > 50) { + // Robot did not enable properly after 5 seconds. + // Force exit + llvm::errs() << " Failed to enable. Aborting\n"; + std::terminate(); + } + Wait(0.1); + + llvm::outs() << "Waiting for enable: " << enableCounter++ << "\n"; } } diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractComsSetup.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractComsSetup.java index 1db2e5e5b0..2db2b1aeaf 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractComsSetup.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractComsSetup.java @@ -66,6 +66,12 @@ public abstract class AbstractComsSetup { // Wait until the robot is enabled before starting the tests int enableCounter = 0; while (!DriverStation.getInstance().isEnabled()) { + if (enableCounter > 50) { + // Robot did not enable properly after 5 seconds. + // Force exit + TestBench.err().println("Failed to enable. Aborting"); + System.exit(1); + } try { Thread.sleep(100); } catch (InterruptedException ex) {