Skip to content

Commit 0656bd1

Browse files
author
edelgadoh
committed
Adding labels to split StopWatch feature - skip issue happening only in MacOS 13
1 parent b7a0928 commit 0656bd1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/test/java/org/apache/commons/lang3/time/StopWatchTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.commons.lang3.AbstractLangTest;
3434
import org.apache.commons.lang3.ThreadUtils;
3535
import org.apache.commons.lang3.reflect.FieldUtils;
36+
import org.junit.jupiter.api.Assumptions;
3637
import org.junit.jupiter.api.RepeatedTest;
3738
import org.junit.jupiter.api.Test;
3839

@@ -540,6 +541,7 @@ void testSplitsWithStringLabels() {
540541
final String report = watch.getReport();
541542
final String updatedReport = report.replaceAll("4\\d\\d", "4**").replaceAll("3\\d\\d", "3**").replaceAll("2\\d\\d", "2**");
542543

544+
assumeNotMacOs13();
543545
assertEquals(
544546
System.lineSeparator() + "one 00:00:00.4**" +
545547
System.lineSeparator() + "two 00:00:00.3**" +
@@ -587,6 +589,7 @@ void testSplitsWithIntLabels() {
587589
final String report = watch.getReport();
588590
final String updatedReport = report.replaceAll("4\\d\\d", "4**").replaceAll("3\\d\\d", "3**").replaceAll("2\\d\\d", "2**");
589591

592+
assumeNotMacOs13();
590593
assertEquals(
591594
System.lineSeparator() + "1 00:00:00.4**" +
592595
System.lineSeparator() + "2 00:00:00.3**" +
@@ -620,12 +623,21 @@ void testNanoSplitsWithLabel() {
620623
final String report = watch.getNanoReport();
621624
final String updatedReport = report.replaceAll(" 2\\d+", " 20*******").replaceAll(" 3\\d+", " 30*******");
622625

626+
assumeNotMacOs13();
623627
assertEquals(System.lineSeparator() + "coding 20*******" +
624628
System.lineSeparator() + "eating 30*******",
625629
updatedReport
626630
);
627631
}
628632

633+
// Note: On macOS the clock granularity and scheduling can cause minor deviations.
634+
static void assumeNotMacOs13() {
635+
String os = System.getProperty("os.name").toLowerCase();
636+
String version = System.getProperty("os.version");
637+
Assumptions.assumeTrue(!(os.contains("mac") && version.startsWith("13")),
638+
() -> "Skipping test on macOS 13");
639+
}
640+
629641
private int throwIOException() throws IOException {
630642
throw new IOException("A");
631643
}

0 commit comments

Comments
 (0)