Issues running test.ps1 while investigating CultureInfo problems

I am trying to investigate the fsharp repo to find similar CultureInfo problems to this PR. However, when trying to run test.ps1 on Windows OS with PowerShell 7.4.4 to verifying the examplar, I run into these issues.

  • test.ps1 seems to first look at refactoring projects (tree-building, ledger and markdown). The scripts fails at ledger because of the inconsistency when using System.Environment.NewLine on the test but use \n on the main exercise. This fails because I use Windows which defaults to \r\n. Should I change them all to \n? The C# ledger exercise only uses \n.
  • After fixing that, test.ps1 replaces exercise with examplar but it fails at protein-translation project with
Move-Item: E:\code\CSharpCode\Exercism\fsharp\test.ps1:67
Line |
  67 |              Move-Item -Path $example -Destination $stub -Force
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path
     | 'E:\code\CSharpCode\Exercism\fsharp\build\practice\protein-translation\.articles\performance\code\.meta\Example.fs' because it does not exist.
  • I think it is because the protein-translation project has an extra project Benchmark.fsproj inside it and the script cannot find an Examplar.fs near it. I have added a condition check to bypass it but I wonder how this error doesn’t happen on the server?
  • F# ledger exercise uses new CultureInfo(string) a lot. I try changing it to new CultureInfo(string, false) but doing this fails 7/10 tests. Through more research, I find out that F# examplar do not take into account CultureInfo.NumberFormat.CurrencyNegativePattern and just roll with the default currency negative pattern from new CultureInfo(string). On the other hand, the C# examplar does set the currency negative pattern. I suggest changing the F# examplar to be similar to the C# one. I wonder how this passes the test on the server though. Do the server have a custom setting for “en-US” currency negative pattern?

About the CultureInfo issue on other exercises, there seem to be no more problems because F# test uses the [UseCulture] attribute from Exercism.Tests package, which uses new CultureInfo(string, false).

Yes please.

That is very weird and worth looking into.

AFAIK the server does not have a custom setting.

I still don’t understand how the ledger tests pass on the server. However, I think switching to new CultureInfo(string, false) is still more preferable because the current test result is really inconsistent. When I change my windows’ CurrencyNegativePattern setting, the test result changes too. Therefore, I suggest these changes in the PR here.

1 Like