Skip to content

Commit

Permalink
Permanent test for lurking ICU DLL's
Browse files Browse the repository at this point in the history
  • Loading branch information
papeh committed Jul 18, 2022
1 parent 2de34e6 commit ec3e8e3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ jobs:
DOTNET_NOLOGO: true

steps:
- name: Be Certain
run: cd \ && dir icuuc*.dll /b/s
if: matrix.os == 'windows-latest'

- name: Checkout
uses: actions/[email protected]
with:
Expand All @@ -47,10 +43,6 @@ jobs:
- name: Build
run: dotnet build

- name: Debug
run: cd \ && dir icuuc*.dll /b/s
if: matrix.os == 'windows-latest'

- name: Test
run: dotnet test --no-restore --no-build -p:ParallelizeAssembly=false

Expand Down
3 changes: 3 additions & 0 deletions LCM.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=C6562928DAAA5C419C0A4E5109498163/TodoIconStyle/@EntryValue">Normal</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=analyses/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Charis/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dlls/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=DLL_0027s/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Duolos/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=flid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=icuuc/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=LGPL/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ownerless/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Palaso/@EntryIndexedValue">True</s:Boolean>
Expand Down
37 changes: 32 additions & 5 deletions tests/SIL.LCModel.Core.Tests/Text/CustomIcuFallbackTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,44 @@ public void InitIcuDataDir_CustomIcuVersion()
[Test]
public void InitIcuDataDir_FallbackDefaultIcuVersion()
{
// NOTE: if this test fails, check that you don't have icuuc54.dll or icuuc62.dll somewhere,
// e.g. in C:\Program Files (x86)\Common Files\SIL
CopyIcuFiles(_tmpDir, DefaultIcuLibraryVersionMajor);
// Verify that the folder has the correct contents to execute the SUT
var icuFilesInTmpDir = Directory.EnumerateFiles(_tmpDir, "icudt*.dll", SearchOption.AllDirectories).ToArray();
Assert.That(icuFilesInTmpDir.Count, Is.EqualTo(2), string.Join("\r\n", icuFilesInTmpDir));
Assert.That(icuFilesInTmpDir.All(f => f.Contains(DefaultIcuLibraryVersionMajor)), Is.True, string.Join("\r\n", icuFilesInTmpDir));
// SUT
Console.WriteLine("InitIcuDataDir_FallbackDefaultIcuVersion");
Assert.That(RunTestHelper(_tmpDir, out _), Is.EqualTo($"{DefaultIcuLibraryVersionMajor}.2{Environment.NewLine}PRIVATE_USE_CHAR{Environment.NewLine}False"));
Console.WriteLine("InitIcuDataDir_FallbackDefaultIcuVersion finish");
var result = RunTestHelper(_tmpDir, out _);
var expected = $"{DefaultIcuLibraryVersionMajor}.2{Environment.NewLine}PRIVATE_USE_CHAR{Environment.NewLine}False";
if (result.Equals(expected))
{
// All is well; no need to search all over for unwanted ICU DLL's
return;
}
// If this test fails, check that we don't have icuuc##.dll somewhere, e.g. in C:\Program Files (x86)\Common Files\SIL
PrintIcuDllsOnPath();
Assert.That(result, Is.EqualTo(expected));
}

private static void PrintIcuDllsOnPath()
{
var files = new List<string>();
// ReSharper disable once PossibleNullReferenceException
foreach (var folder in Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator))
{
try
{
files.AddRange(Directory.EnumerateFiles(folder, "icuuc*.dll"));
}
catch (Exception e)
{
Console.WriteLine($"Error enumerating: {e}");
}
}
if (files.Any())
{
Console.WriteLine($"Found the following ICU DLL's lurking around:\r\n{string.Join("\r\n", files)}");
Console.WriteLine("(note: DLL's without a version number in the name should not be a problem)");
}
}

[Test]
Expand Down

0 comments on commit ec3e8e3

Please sign in to comment.