|
24 | 24 | import java.nio.file.Path;
|
25 | 25 | import java.nio.file.SimpleFileVisitor;
|
26 | 26 | import java.nio.file.attribute.BasicFileAttributes;
|
| 27 | +import java.time.Instant; |
| 28 | +import java.time.LocalDateTime; |
| 29 | +import java.time.OffsetDateTime; |
| 30 | +import java.time.ZonedDateTime; |
| 31 | +import java.time.format.DateTimeFormatter; |
| 32 | +import java.time.temporal.ChronoUnit; |
| 33 | +import java.time.temporal.TemporalAccessor; |
27 | 34 | import java.util.ArrayList;
|
28 | 35 | import java.util.Collections;
|
29 | 36 | import java.util.HashMap;
|
@@ -80,6 +87,28 @@ private void scanTestFile(Path testReport) {
|
80 | 87 | return;
|
81 | 88 | }
|
82 | 89 |
|
| 90 | + // google sheets don't automatically recognize dates with time zone, here we reformat the date |
| 91 | + // so that it wouldn't have the time zone |
| 92 | + TemporalAccessor ta = |
| 93 | + DateTimeFormatter.ISO_DATE_TIME.parseBest( |
| 94 | + timestamp, ZonedDateTime::from, LocalDateTime::from); |
| 95 | + timestamp = DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(ta); |
| 96 | + |
| 97 | + // when test result file was modified more than 20 minutes after the time in the results file |
| 98 | + // then the test results were restored from gradle cache and the test wasn't actually executed |
| 99 | + Instant reportModified = Instant.ofEpochMilli(testReport.toFile().lastModified()); |
| 100 | + reportModified = reportModified.minus(20, ChronoUnit.MINUTES); |
| 101 | + Instant testExecuted = null; |
| 102 | + if (ta instanceof ZonedDateTime) { |
| 103 | + testExecuted = ((ZonedDateTime) ta).toInstant(); |
| 104 | + } else if (ta instanceof LocalDateTime) { |
| 105 | + testExecuted = ((LocalDateTime) ta).toInstant(OffsetDateTime.now().getOffset()); |
| 106 | + } |
| 107 | + if (testExecuted != null && reportModified.isAfter(testExecuted)) { |
| 108 | + System.err.println( |
| 109 | + "Ignoring " + testReport + " since it appears to be restored from gradle build cache"); |
| 110 | + } |
| 111 | + |
83 | 112 | class TestCase {
|
84 | 113 | final String className;
|
85 | 114 | final String name;
|
|
0 commit comments