Hack to try to see if we can get GH builds to pass

This commit is contained in:
Gary Gregory 2023-08-13 15:22:10 -04:00
parent 5bad7ea2fc
commit bba01b04be
1 changed files with 15 additions and 2 deletions

View File

@ -25,9 +25,11 @@ import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.text.DateFormatSymbols;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.TimeZone;
@ -44,6 +46,7 @@ import org.junitpioneer.jupiter.DefaultLocale;
import org.junitpioneer.jupiter.DefaultTimeZone;
import org.junitpioneer.jupiter.ReadsDefaultLocale;
import org.junitpioneer.jupiter.ReadsDefaultTimeZone;
import org.opentest4j.AssertionFailedError;
/* make test reproducible */ @DefaultLocale(language = "en")
/* make test reproducible */ @DefaultTimeZone(TimeZones.GMT_ID)
@ -105,6 +108,8 @@ public class FastDateParser_TimeZoneStrategyTest extends AbstractLangTest {
assumeTrue(LocaleUtils.isAvailableLocale(locale), () -> toFailureMessage(locale, null));
final String[][] zones = ArraySorter.sort(DateFormatSymbols.getInstance(locale).getZoneStrings(), Comparator.comparing(array -> array[0]));
int failCount = 0; // HACK counter
List<AssertionFailedError> parseExceptionList = new ArrayList<>();
for (final String[] zone : zones) {
for (int zIndex = 1; zIndex < zone.length; ++zIndex) {
final String tzDisplay = zone[zIndex];
@ -117,15 +122,23 @@ public class FastDateParser_TimeZoneStrategyTest extends AbstractLangTest {
try {
parser.parse(tzDisplay);
} catch (ParseException e) {
failCount++;
// Missing "Zulu" or something else in broken JDK's GH builds?
final ByteArrayOutputStream zonesOut = new ByteArrayOutputStream();
final PrintStream zonesPs = new PrintStream(zonesOut);
final AtomicInteger i = new AtomicInteger();
// Comment in for more debug data:
Stream.of(zones).forEach(zoneArray -> zonesPs.printf("[%,d] %s%n", i.getAndIncrement(), Arrays.toString(zoneArray)));
fail(String.format(
parseExceptionList.add(new AssertionFailedError(String.format(
"%s: with tzDefault = %s, locale = %s, zones[][] size = '%s', zIndex = %,d, tzDisplay = '%s', parser = '%s', zones size = %,d, zones = %s",
e, timeZone, locale, zone.length, zIndex, tzDisplay, parser.toStringAll(), zones.length, zonesOut), e);
e, timeZone, locale, zone.length, zIndex, tzDisplay, parser.toStringAll(), zones.length, zonesOut), e));
// HACK check
if (failCount > 43) {
// HACK fail
// Why are builds passing locally for me failing on GitHub?
System.err.println(parseExceptionList);
fail(e);
}
}
}
}