From 885f5a978161a6493fbc95a9e31cdb007c28c28b Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Tue, 29 Dec 2020 10:30:23 -0800 Subject: [PATCH] [wpilibc] Speed up ScopedTracerTest (#2999) ScopedTracerTest now uses simulation time instead of wall clock time, so it doesn't have to actually wait 1.5 seconds. --- wpilibc/src/test/native/cpp/ScopedTracerTest.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/wpilibc/src/test/native/cpp/ScopedTracerTest.cpp b/wpilibc/src/test/native/cpp/ScopedTracerTest.cpp index cb4a83582d..8ffb51e587 100644 --- a/wpilibc/src/test/native/cpp/ScopedTracerTest.cpp +++ b/wpilibc/src/test/native/cpp/ScopedTracerTest.cpp @@ -2,28 +2,24 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. -#include -#include - #include #include #include #include "frc/ScopedTracer.h" +#include "frc/simulation/SimHooks.h" #include "gtest/gtest.h" wpi::SmallString<128> buf; wpi::raw_svector_ostream os(buf); -#ifdef __APPLE__ -TEST(ScopedTracerTest, DISABLED_Timing) { -#else TEST(ScopedTracerTest, Timing) { -#endif + frc::sim::PauseTiming(); { frc::ScopedTracer tracer("timing_test", os); - std::this_thread::sleep_for(std::chrono::milliseconds(1500)); + frc::sim::StepTiming(1.5_s); } + frc::sim::ResumeTiming(); wpi::StringRef out = os.str(); EXPECT_TRUE(out.startswith(" timing_test: 1.5"));