diff --git a/azure-pipelines-testbench.yaml b/azure-pipelines-testbench.yaml index 3ed5507b23..c87ba40c77 100644 --- a/azure-pipelines-testbench.yaml +++ b/azure-pipelines-testbench.yaml @@ -1,19 +1,46 @@ -# Starter pipeline -# Start with a minimal pipeline that you can customize to build and deploy your code. -# Add steps that build, run tests, deploy, and more: -# https://aka.ms/yaml - -trigger: -- master - -pool: - vmImage: 'ubuntu-latest' - -steps: -- script: echo Hello, world! - displayName: 'Run a one-line script' - -- script: | - echo Add other tasks to build, test, and deploy your project. - echo See https://aka.ms/yaml - displayName: 'Run a multi-line script' +# Testing steps for real hardware + +trigger: + batch: true + branches: + include: + - master + +jobs: +- job: TestBench + pool: RoboRioConnections + timeoutInMinutes: 60 + workspace: + clean: all + steps: + - task: Gradle@2 + condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))) + inputs: + workingDirectory: '' + gradleWrapperFile: 'gradlew' + gradleOptions: '-Xmx3072m' + publishJUnitResults: false + testResultsFiles: '**/TEST-*.xml' + tasks: 'copyWpilibJIntegrationTestJarToOutput copyWpilibCTestLibrariesToOutput' + options: '-Ponlylinuxathena -PbuildServer' + + - task: ShellScript@2 + displayName: Run Tests & Get Results + inputs: + scriptPath: test-scripts/jenkins-run-tests-get-results.sh + + - task: PublishTestResults@2 + displayName: Publish C++ Test Results + inputs: + testResultsFormat: 'JUnit' + testResultsFiles: 'cpp*.xml' + testRunTitle: 'C++ Test Report' + searchFolder: '$(System.DefaultWorkingDirectory)/test-reports' + + - task: PublishTestResults@2 + displayName: Publish Java Test Results + inputs: + testResultsFormat: 'JUnit' + testResultsFiles: 'java*.xml' + testRunTitle: 'Java Test Report' + searchFolder: '$(System.DefaultWorkingDirectory)/test-reports' diff --git a/test-scripts/config.sh b/test-scripts/config.sh index 2232b8db4f..48eeda4d14 100755 --- a/test-scripts/config.sh +++ b/test-scripts/config.sh @@ -31,7 +31,7 @@ DEFAULT_DESTINATION_CPP_TEST_RESULTS=${DEFAULT_DESTINATION_TEST_RESULTS_DIR}/${C DEFAULT_JAVA_TEST_NAME=FRCUserProgram.jar DEFAULT_JAVA_TEST_ARGS="" -DEFAULT_LOCAL_JAVA_TEST_FILE=../build/integrationTestFiles/java/wpilibjIntegrationTests.jar +DEFAULT_LOCAL_JAVA_TEST_FILE=../build/integrationTestFiles/java/wpilibjIntegrationTests-all.jar JAVA_REPORT=javareport.xml DEFAULT_LIBRARY_NATIVE_FILES=../build/integrationTestFiles/libs diff --git a/wpilibcIntegrationTests/src/main/native/cpp/MotorEncoderTest.cpp b/wpilibcIntegrationTests/src/main/native/cpp/MotorEncoderTest.cpp index 74242df745..ca6653cd94 100644 --- a/wpilibcIntegrationTests/src/main/native/cpp/MotorEncoderTest.cpp +++ b/wpilibcIntegrationTests/src/main/native/cpp/MotorEncoderTest.cpp @@ -5,6 +5,8 @@ /* the project. */ /*----------------------------------------------------------------------------*/ +#include + #include "TestBench.h" #include "frc/Encoder.h" #include "frc/Jaguar.h" @@ -146,7 +148,8 @@ TEST_P(MotorEncoderTest, PositionPIDController) { /* 10 seconds should be plenty time to get to the reference */ frc::Notifier pidRunner{[this, &pidController] { - m_speedController->Set(pidController.Calculate(m_encoder->GetDistance())); + auto speed = pidController.Calculate(m_encoder->GetDistance()); + m_speedController->Set(std::clamp(speed, -0.2, 0.2)); }}; pidRunner.StartPeriodic(pidController.GetPeriod()); Wait(10.0); @@ -171,9 +174,9 @@ TEST_P(MotorEncoderTest, VelocityPIDController) { /* 10 seconds should be plenty time to get to the reference */ frc::Notifier pidRunner{[this, &pidController] { - m_speedController->Set( - pidController.Calculate(m_filter->Calculate(m_encoder->GetRate())) + - 8e-5); + auto speed = + pidController.Calculate(m_filter->Calculate(m_encoder->GetRate())); + m_speedController->Set(std::clamp(speed, -0.3, 0.3)); }}; pidRunner.StartPeriodic(pidController.GetPeriod()); Wait(10.0); diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java index b14ad6f953..d2db15029f 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java @@ -23,6 +23,7 @@ import edu.wpi.first.wpilibj.controller.PIDController; import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture; import edu.wpi.first.wpilibj.test.AbstractComsSetup; import edu.wpi.first.wpilibj.test.TestBench; +import edu.wpi.first.wpiutil.math.MathUtils; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -181,8 +182,10 @@ public class MotorEncoderTest extends AbstractComsSetup { pidController.setIntegratorRange(-0.2, 0.2); pidController.setSetpoint(1000); - Notifier pidRunner = new Notifier( - () -> me.getMotor().set(pidController.calculate(me.getEncoder().getDistance()))); + Notifier pidRunner = new Notifier(() -> { + var speed = pidController.calculate(me.getEncoder().getDistance()); + me.getMotor().set(MathUtils.clamp(speed, -0.2, 0.2)); + }); pidRunner.startPeriodic(pidController.getPeriod()); Timer.delay(10.0); @@ -202,8 +205,10 @@ public class MotorEncoderTest extends AbstractComsSetup { pidController.setTolerance(200); pidController.setSetpoint(600); - Notifier pidRunner = - new Notifier(() -> me.getMotor().set(filter.calculate(me.getEncoder().getRate()) + 8e-5)); + Notifier pidRunner = new Notifier(() -> { + var speed = filter.calculate(me.getEncoder().getRate()); + me.getMotor().set(MathUtils.clamp(speed, -0.3, 0.3)); + }); pidRunner.startPeriodic(pidController.getPeriod()); Timer.delay(10.0);