|
33 | 33 | import org.apache.commons.lang3.AbstractLangTest; |
34 | 34 | import org.apache.commons.lang3.ThreadUtils; |
35 | 35 | import org.apache.commons.lang3.reflect.FieldUtils; |
| 36 | +import org.junit.jupiter.api.Assumptions; |
36 | 37 | import org.junit.jupiter.api.RepeatedTest; |
37 | 38 | import org.junit.jupiter.api.Test; |
38 | 39 |
|
@@ -540,6 +541,7 @@ void testSplitsWithStringLabels() { |
540 | 541 | final String report = watch.getReport(); |
541 | 542 | final String updatedReport = report.replaceAll("4\\d\\d", "4**").replaceAll("3\\d\\d", "3**").replaceAll("2\\d\\d", "2**"); |
542 | 543 |
|
| 544 | + assumeNotMacOs13(); |
543 | 545 | assertEquals( |
544 | 546 | System.lineSeparator() + "one 00:00:00.4**" + |
545 | 547 | System.lineSeparator() + "two 00:00:00.3**" + |
@@ -587,6 +589,7 @@ void testSplitsWithIntLabels() { |
587 | 589 | final String report = watch.getReport(); |
588 | 590 | final String updatedReport = report.replaceAll("4\\d\\d", "4**").replaceAll("3\\d\\d", "3**").replaceAll("2\\d\\d", "2**"); |
589 | 591 |
|
| 592 | + assumeNotMacOs13(); |
590 | 593 | assertEquals( |
591 | 594 | System.lineSeparator() + "1 00:00:00.4**" + |
592 | 595 | System.lineSeparator() + "2 00:00:00.3**" + |
@@ -620,12 +623,21 @@ void testNanoSplitsWithLabel() { |
620 | 623 | final String report = watch.getNanoReport(); |
621 | 624 | final String updatedReport = report.replaceAll(" 2\\d+", " 20*******").replaceAll(" 3\\d+", " 30*******"); |
622 | 625 |
|
| 626 | + assumeNotMacOs13(); |
623 | 627 | assertEquals(System.lineSeparator() + "coding 20*******" + |
624 | 628 | System.lineSeparator() + "eating 30*******", |
625 | 629 | updatedReport |
626 | 630 | ); |
627 | 631 | } |
628 | 632 |
|
| 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 | + |
629 | 641 | private int throwIOException() throws IOException { |
630 | 642 | throw new IOException("A"); |
631 | 643 | } |
|
0 commit comments