Skip to content

Commit 611858f

Browse files
committed
Fixes locale dependent test output comparisons
The tests do not pass on systems with locale other than en-US. The error happens since the results are written to files and the contents of the files are compared to set of correct results produced under en-US locale. The fix is to imbue en-US culture to the test thread so that results will be output in format that is comparable with the test format. This patch fixes only tests, but do not guarantee calculation will be correct in production systems using a locale different than en-US. In particular, there can be problems in reading data and then conversing data from characters to numeric format. Fixes #74
1 parent fb06f38 commit 611858f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/Microsoft.ML.TestFramework/BaseTestClass.cs

+7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
// See the LICENSE file in the project root for more information.
44

55
using Microsoft.ML.Runtime.Internal.Internallearn.Test;
6+
using System.Globalization;
67
using System.IO;
8+
using System.Threading;
79
using Xunit.Abstractions;
810

911
namespace Microsoft.ML.TestFramework
@@ -18,6 +20,11 @@ public class BaseTestClass
1820

1921
public BaseTestClass(ITestOutputHelper output)
2022
{
23+
//This locale is currently set for tests only so that the produced output
24+
//files can be compared on systems with other locales to give set of known
25+
//correct results that are on en-US locale.
26+
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
27+
2128
var currentAssemblyLocation = new FileInfo(typeof(BaseTestClass).Assembly.Location);
2229
_rootDir = currentAssemblyLocation.Directory.Parent.Parent.Parent.Parent.FullName;
2330
_outDir = Path.Combine(currentAssemblyLocation.Directory.FullName, "TestOutput");

0 commit comments

Comments
 (0)