Skip to content

Commit

Permalink
ran fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
oh-yes-0-fps committed Sep 26, 2024
1 parent c1bcc63 commit 71a5717
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
5 changes: 1 addition & 4 deletions wpilibj/src/main/java/edu/wpi/first/wpilibj/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,7 @@ public static <R> R traceFunc(String name, Supplier<R> supplier) {
return ret;
}

/**
* This function is only to be used in tests
* and is package private to prevent misuse.
*/
/** This function is only to be used in tests and is package private to prevent misuse. */
static void resetForTest() {
threadLocalState.remove();
singleThreadedMode.set(false);
Expand Down
57 changes: 29 additions & 28 deletions wpilibj/src/test/java/edu/wpi/first/wpilibj/TracerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package edu.wpi.first.wpilibj;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;

import edu.wpi.first.hal.HAL;
import edu.wpi.first.networktables.DoubleEntry;
Expand Down Expand Up @@ -67,9 +67,9 @@ void traceThreadTest() {
Tracer.endTrace();

DoubleEntry test1Entry =
NetworkTableInstance.getDefault()
.getDoubleTopic("/Tracer/" + threadName + "/ThreadTest1")
.getEntry(0.0);
NetworkTableInstance.getDefault()
.getDoubleTopic("/Tracer/" + threadName + "/ThreadTest1")
.getEntry(0.0);
assertEquals(100.0, test1Entry.get(), 1.0);
}

Expand All @@ -78,17 +78,17 @@ void traceThreadTest() {
{
final String newThreadName = "TestThread";
try {
Thread thread = new Thread(
() -> {
Tracer.disableGcLoggingForCurrentThread();
Tracer.startTrace("ThreadTest1");
SimHooks.stepTiming(0.4);
Tracer.endTrace();
},
newThreadName
);
thread.start();
thread.join();
Thread thread =
new Thread(
() -> {
Tracer.disableGcLoggingForCurrentThread();
Tracer.startTrace("ThreadTest1");
SimHooks.stepTiming(0.4);
Tracer.endTrace();
},
newThreadName);
thread.start();
thread.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
Expand Down Expand Up @@ -116,25 +116,26 @@ void traceSingleThreadTest() {
SimHooks.stepTiming(0.1);
Tracer.endTrace();

DoubleEntry test1Entry = NetworkTableInstance.getDefault()
.getDoubleTopic("/Tracer/SingleThreadTest1")
.getEntry(0.0);
DoubleEntry test1Entry =
NetworkTableInstance.getDefault()
.getDoubleTopic("/Tracer/SingleThreadTest1")
.getEntry(0.0);
assertEquals(100.0, test1Entry.get(), 1.0);
}

// start a trace in a new thread after enabling single threaded mode,
// this should disable the tracer on the new thread, assert that the tracer did not run
{
try {
Thread thread = new Thread(
() -> {
Tracer.disableGcLoggingForCurrentThread();
Tracer.startTrace("SingleThreadTest1");
SimHooks.stepTiming(0.4);
Tracer.endTrace();
},
newThreadName
);
Thread thread =
new Thread(
() -> {
Tracer.disableGcLoggingForCurrentThread();
Tracer.startTrace("SingleThreadTest1");
SimHooks.stepTiming(0.4);
Tracer.endTrace();
},
newThreadName);
thread.start();
thread.join();
} catch (InterruptedException e) {
Expand All @@ -146,7 +147,7 @@ void traceSingleThreadTest() {
.getDoubleTopic("/Tracer/" + newThreadName + "/SingleThreadTest1")
.exists();

assertTrue(!test2EntryExists);
assertFalse(test2EntryExists);
}
}
}

0 comments on commit 71a5717

Please sign in to comment.