You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2019/09/06 09:01:30 UTC
[lucenenet] 20/21: BUG: Lucene.Net.TestFramework.LuceneTestCase:
Fixed edge case where random culture and/or time zone is not available on
macOS for random pick, so just return a sensible default in those cases
This is an automated email from the ASF dual-hosted git repository.
nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit 27b2c0603d8b8f93f7e84128b0ba9428212ffc82
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Fri Sep 6 15:52:05 2019 +0700
BUG: Lucene.Net.TestFramework.LuceneTestCase: Fixed edge case where random culture and/or time zone is not available on macOS for random pick, so just return a sensible default in those cases
---
src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
index 6b5ca6c..78da957 100644
--- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -1556,7 +1556,14 @@ namespace Lucene.Net.Util
/// </summary>
public static CultureInfo RandomCulture(Random random) // LUCENENET specific renamed from RandomLocale
{
- return RandomPicks.RandomFrom(random, CultureInfoSupport.GetNeutralAndSpecificCultures());
+ ICollection<CultureInfo> systemCultures = CultureInfoSupport.GetNeutralAndSpecificCultures();
+#if NETSTANDARD1_6
+ // .NET Core 1.0 on macOS seems to be flakey here and not return results occasionally, so compensate by
+ // returning CultureInfo.InvariantCulture when it happens.
+ if (systemCultures.Count == 0)
+ return CultureInfo.InvariantCulture;
+#endif
+ return RandomPicks.RandomFrom(random, systemCultures);
}
/// <summary>
@@ -1566,7 +1573,14 @@ namespace Lucene.Net.Util
/// </summary>
public static TimeZoneInfo RandomTimeZone(Random random)
{
- return RandomPicks.RandomFrom(random, TimeZoneInfo.GetSystemTimeZones());
+ var systemTimeZones = TimeZoneInfo.GetSystemTimeZones();
+#if NETSTANDARD1_6
+ // .NET Core 1.0 on macOS seems to be flakey here and not return results occasionally, so compensate by
+ // returning TimeZoneInfo.Local when it happens.
+ if (systemTimeZones.Count == 0)
+ return TimeZoneInfo.Local;
+#endif
+ return RandomPicks.RandomFrom(random, systemTimeZones);
}
/// <summary>