From 2914d62046011f8fac335b93903d2835204c28c9 Mon Sep 17 00:00:00 2001 From: Jason Naylor Date: Wed, 20 Nov 2024 13:32:53 -0800 Subject: [PATCH] Update libpalaso depdencies * This brings in a new version of L10nSharp with API changes --- .github/workflows/ci+cd.yml | 30 ++-- src/Chorus.Tests/ChorusFixtureSetup.cs | 18 ++ src/Chorus.Tests/clone/ClonerTests.cs | 1 - src/Chorus/Chorus.csproj | 4 +- src/Chorus/ChorusSystem.cs | 4 +- src/ChorusHub/ChorusHub.csproj | 4 +- src/ChorusHubApp/ChorusHubApp.csproj | 4 +- src/ChorusHubTests/ChorusHubFixtureSetup.cs | 15 ++ .../ChorusMerge.Tests.csproj | 2 +- .../ChorusMergeFixtureSetup.cs | 15 ++ src/ChorusMerge/Program.cs | 5 +- src/Installer/ChorusHub.wxs | 30 ++-- src/Installer/ChorusMergeModule.wxs | 24 +-- .../LibChorus.TestUtilities.csproj | 6 +- .../ChorusFileTypeHandlerCollectionTests.cs | 2 + src/LibChorusTests/LibChorus.Tests.csproj | 6 +- src/LibChorusTests/LibChorusSetupFixture.cs | 15 ++ .../merge/xml/lift/MultiTextMergingTests.cs | 160 +----------------- 18 files changed, 125 insertions(+), 220 deletions(-) create mode 100644 src/Chorus.Tests/ChorusFixtureSetup.cs create mode 100644 src/ChorusHubTests/ChorusHubFixtureSetup.cs create mode 100644 src/ChorusMerge.Tests/ChorusMergeFixtureSetup.cs create mode 100644 src/LibChorusTests/LibChorusSetupFixture.cs diff --git a/.github/workflows/ci+cd.yml b/.github/workflows/ci+cd.yml index a3e79c14c..330b0976a 100644 --- a/.github/workflows/ci+cd.yml +++ b/.github/workflows/ci+cd.yml @@ -53,31 +53,31 @@ jobs: - name: Build run: dotnet build --no-restore -c Release - - name: Install python2 for test execution - run: sudo apt-get install python2 - if: matrix.os == 'ubuntu-latest' + - name: install python2 for test execution + run: sudo apt-get install python2 + if: matrix.os == 'ubuntu-latest' - - name: Test Chorus - run: dotnet test src/Chorus.Tests/Chorus.Tests.csproj -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults + - name: test chorus + run: dotnet test src/chorus.tests/chorus.tests.csproj -f ${{ matrix.framework }} --no-build -c release --filter testcategory!=skiponbuildserver -- nunit.testoutputxml=testresults if: matrix.framework == 'net462' - - name: Test Chorus Hub - run: dotnet test src/ChorusHubTests/ChorusHubTests.csproj -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults + - name: test chorus hub + run: dotnet test src/chorushubtests/chorushubtests.csproj -f ${{ matrix.framework }} --no-build -c release --filter testcategory!=skiponbuildserver -- nunit.testoutputxml=testresults if: matrix.framework == 'net462' - - name: Test ChorusMerge - run: dotnet test src/ChorusMerge.Tests/ChorusMerge.Tests.csproj -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults + - name: test chorusmerge + run: dotnet test src/chorusmerge.tests/chorusmerge.tests.csproj -f ${{ matrix.framework }} --no-build -c release --filter testcategory!=skiponbuildserver -- nunit.testoutputxml=testresults - - name: Test LibChorus - run: dotnet test src/LibChorusTests/LibChorus.Tests.csproj -f ${{ matrix.framework }} --no-build -c Release --filter TestCategory!=SkipOnBuildServer -- NUnit.TestOutputXml=TestResults + - name: test libchorus + run: dotnet test src/libchorustests/libchorus.tests.csproj -f ${{ matrix.framework }} --no-build -c release --filter testcategory!=skiponbuildserver -- nunit.testoutputxml=testresults - # TODO: Give each test result its own name based on OS and framework and change the test-results.yml workflow accordingly, so that they don't overwrite each other - - name: Upload Test Results + # todo: give each test result its own name based on os and framework and change the test-results.yml workflow accordingly, so that they don't overwrite each other + - name: upload test results if: always() uses: actions/upload-artifact@v4 with: - name: Test Results (${{ matrix.framework }} on ${{matrix.os}}) - path: "**/TestResults/*.xml" + name: test results (${{ matrix.framework }} on ${{matrix.os}}) + path: "**/testresults/*.xml" build-installers: name: "Build Windows installers" diff --git a/src/Chorus.Tests/ChorusFixtureSetup.cs b/src/Chorus.Tests/ChorusFixtureSetup.cs new file mode 100644 index 000000000..1941e365d --- /dev/null +++ b/src/Chorus.Tests/ChorusFixtureSetup.cs @@ -0,0 +1,18 @@ +using L10NSharp; +using NUnit.Framework; + +namespace Chorus.Tests +{ + internal class ChorusFixtureSetup + { + [SetUpFixture] + public class SetupFixture + { + [OneTimeSetUp] + public void RunBeforeAnyTests() + { + LocalizationManager.StrictInitializationMode = false; + } + } + } +} diff --git a/src/Chorus.Tests/clone/ClonerTests.cs b/src/Chorus.Tests/clone/ClonerTests.cs index e83c2476a..295adaa13 100644 --- a/src/Chorus.Tests/clone/ClonerTests.cs +++ b/src/Chorus.Tests/clone/ClonerTests.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Drawing; using System.IO; diff --git a/src/Chorus/Chorus.csproj b/src/Chorus/Chorus.csproj index 354bd746e..9109fbf87 100644 --- a/src/Chorus/Chorus.csproj +++ b/src/Chorus/Chorus.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/src/Chorus/ChorusSystem.cs b/src/Chorus/ChorusSystem.cs index fe6c79c75..9df704e3b 100644 --- a/src/Chorus/ChorusSystem.cs +++ b/src/Chorus/ChorusSystem.cs @@ -123,11 +123,11 @@ public static void SetUpLocalization(string desiredUiLangId, var versionObj = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; // We don't need to reload strings for every "revision" (that might be every time we build). var version = "" + versionObj.Major + "." + versionObj.Minor + "." + versionObj.Build; - LocalizationManager.Create(TranslationMemory.XLiff, desiredUiLangId, "Chorus", + LocalizationManager.Create(desiredUiLangId, "Chorus", Application.ProductName, version, directoryOfInstalledXlfFiles, directoryOfUserModifiedXlfFiles, Icon.FromHandle(Properties.Resources.chorus32x32.GetHicon()), // should call DestroyIcon, but when? - "issues@chorus.palaso.org", "Chorus"); + "issues@chorus.palaso.org", new [] {"Chorus"}); } [Obsolete("Only one kind of TranslationMemory is supported: XLF; there is no need for the kind parameter.")] diff --git a/src/ChorusHub/ChorusHub.csproj b/src/ChorusHub/ChorusHub.csproj index 95644a920..bad50e55e 100644 --- a/src/ChorusHub/ChorusHub.csproj +++ b/src/ChorusHub/ChorusHub.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/src/ChorusHubApp/ChorusHubApp.csproj b/src/ChorusHubApp/ChorusHubApp.csproj index 177232fec..4b36fba56 100644 --- a/src/ChorusHubApp/ChorusHubApp.csproj +++ b/src/ChorusHubApp/ChorusHubApp.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/src/ChorusHubTests/ChorusHubFixtureSetup.cs b/src/ChorusHubTests/ChorusHubFixtureSetup.cs new file mode 100644 index 000000000..bf6f76389 --- /dev/null +++ b/src/ChorusHubTests/ChorusHubFixtureSetup.cs @@ -0,0 +1,15 @@ +using L10NSharp; +using NUnit.Framework; + +namespace ChorusHubTests +{ + [SetUpFixture] + public class ChorusHubFixtureSetup + { + [OneTimeSetUp] + public void RunBeforeAnyTests() + { + LocalizationManager.StrictInitializationMode = false; + } + } +} diff --git a/src/ChorusMerge.Tests/ChorusMerge.Tests.csproj b/src/ChorusMerge.Tests/ChorusMerge.Tests.csproj index 3193ad0fb..6fcfc68c2 100644 --- a/src/ChorusMerge.Tests/ChorusMerge.Tests.csproj +++ b/src/ChorusMerge.Tests/ChorusMerge.Tests.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/ChorusMerge.Tests/ChorusMergeFixtureSetup.cs b/src/ChorusMerge.Tests/ChorusMergeFixtureSetup.cs new file mode 100644 index 000000000..ab9b568ca --- /dev/null +++ b/src/ChorusMerge.Tests/ChorusMergeFixtureSetup.cs @@ -0,0 +1,15 @@ +using L10NSharp; +using NUnit.Framework; + +namespace ChorusMerge.Tests +{ + [SetUpFixture] + public class ChorusMergeFixtureSetup + { + [OneTimeSetUp] + public void RunBeforeAnyTests() + { + LocalizationManager.StrictInitializationMode = false; + } + } +} diff --git a/src/ChorusMerge/Program.cs b/src/ChorusMerge/Program.cs index 75e692215..d48f79af0 100644 --- a/src/ChorusMerge/Program.cs +++ b/src/ChorusMerge/Program.cs @@ -2,12 +2,10 @@ using System; using System.IO; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Text; using Chorus.FileTypeHandlers; using Chorus.merge; using Chorus.merge.xml.generic; -using SIL.PlatformUtilities; +using L10NSharp; // Allow redirecting Console.Error for unit tests (Avoid spurious build failures) [assembly: InternalsVisibleTo("ChorusMerge.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001005f4452c387d979e3cba05fd73bb9aebe8f8830874663d66a7869f614a8f5e8def658d5c5920fae609d28aa005d5a9af5bd758ca8f19ad0347b7aa76e1f723f8994792136f5ceff9fb6f719d4337f65da2e1d66a85cc5e28e4656a1a30c2ff513440393177625c725d3fb156dc3c11610ea5936b9404ab9d51f7eb71ac0aa27bd")] @@ -35,6 +33,7 @@ public static int Main(string[] args) { try { + LocalizationManager.StrictInitializationMode = false; string ourFilePath = args[0]; string commonFilePath = args[1]; string theirFilePath = args[2]; diff --git a/src/Installer/ChorusHub.wxs b/src/Installer/ChorusHub.wxs index b17d90665..7192f36c3 100644 --- a/src/Installer/ChorusHub.wxs +++ b/src/Installer/ChorusHub.wxs @@ -22,9 +22,9 @@ http://blogs.msdn.com/robmen/archive/2003/10/04/56479.aspx --> - - - + + + - + @@ -73,46 +73,46 @@ http://blogs.msdn.com/robmen/archive/2003/10/04/56479.aspx --> - + - + - + - + - + - + - + - + - + - + @@ -149,7 +149,7 @@ http://blogs.msdn.com/robmen/archive/2003/10/04/56479.aspx --> - + diff --git a/src/Installer/ChorusMergeModule.wxs b/src/Installer/ChorusMergeModule.wxs index 703c51970..b95e61b43 100644 --- a/src/Installer/ChorusMergeModule.wxs +++ b/src/Installer/ChorusMergeModule.wxs @@ -45,13 +45,13 @@ http://blogs.msdn.com/robmen/archive/2003/10/04/56479.aspx --> - + - + - + @@ -59,34 +59,34 @@ http://blogs.msdn.com/robmen/archive/2003/10/04/56479.aspx --> - + - + - + - + - + - + - + - + - + diff --git a/src/LibChorus.TestUtilities/LibChorus.TestUtilities.csproj b/src/LibChorus.TestUtilities/LibChorus.TestUtilities.csproj index a6ca46956..a74d65687 100644 --- a/src/LibChorus.TestUtilities/LibChorus.TestUtilities.csproj +++ b/src/LibChorus.TestUtilities/LibChorus.TestUtilities.csproj @@ -10,9 +10,9 @@ - - - + + + diff --git a/src/LibChorusTests/FileHandlers/ChorusFileTypeHandlerCollectionTests.cs b/src/LibChorusTests/FileHandlers/ChorusFileTypeHandlerCollectionTests.cs index 3863ca749..57a92c3e1 100644 --- a/src/LibChorusTests/FileHandlers/ChorusFileTypeHandlerCollectionTests.cs +++ b/src/LibChorusTests/FileHandlers/ChorusFileTypeHandlerCollectionTests.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Reflection; +using System.Runtime.InteropServices; using NUnit.Framework; using Chorus.FileTypeHandlers; using Chorus.FileTypeHandlers.audio; @@ -44,6 +45,7 @@ public void CreateWithInstalledHandlers_ContainsTestAFileTypeHandler() [Test] public void CreateWithInstalledHandlers_HandlersFromAdditionalAssembly() { + Assume.That(RuntimeInformation.FrameworkDescription.Contains(".NET Framework"), "Not running on .NET Framework"); var handlers = ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers( new[] { SamplePluginPath }).Handlers; Assert.That(handlers.Select(x => x.GetType().Name), Has.Member("TestAFileTypeHandler")); diff --git a/src/LibChorusTests/LibChorus.Tests.csproj b/src/LibChorusTests/LibChorus.Tests.csproj index 04ea7a741..daac3380b 100644 --- a/src/LibChorusTests/LibChorus.Tests.csproj +++ b/src/LibChorusTests/LibChorus.Tests.csproj @@ -17,9 +17,9 @@ - - - + + + diff --git a/src/LibChorusTests/LibChorusSetupFixture.cs b/src/LibChorusTests/LibChorusSetupFixture.cs new file mode 100644 index 000000000..c8b0801f9 --- /dev/null +++ b/src/LibChorusTests/LibChorusSetupFixture.cs @@ -0,0 +1,15 @@ +using L10NSharp; +using NUnit.Framework; + +namespace LibChorus.Tests +{ + [SetUpFixture] + public class LibChorusSetupFixture + { + [OneTimeSetUp] + public void RunBeforeAnyTests() + { + LocalizationManager.StrictInitializationMode = false; + } + } +} \ No newline at end of file diff --git a/src/LibChorusTests/merge/xml/lift/MultiTextMergingTests.cs b/src/LibChorusTests/merge/xml/lift/MultiTextMergingTests.cs index 5c78a6b80..a5e65e1db 100644 --- a/src/LibChorusTests/merge/xml/lift/MultiTextMergingTests.cs +++ b/src/LibChorusTests/merge/xml/lift/MultiTextMergingTests.cs @@ -7,7 +7,7 @@ using NUnit.Framework; -namespace LiftIO.Tests.Merging +namespace LibChorus.Tests.merge.xml.lift { [TestFixture] public class MultiTextMergingTests @@ -84,163 +84,5 @@ public void SkipConvertingElementToTextElementInAnotherFile() Assert.That(doc.DocumentElement.OuterXml, Does.Not.Contain("myStuff"), "Converted element to , but should not have."); Assert.That(doc.DocumentElement.OuterXml, Does.Contain("myStuff"), "Element went away, but should have been present."); } -/* - [Test] - public void MergeMultiTextNodes_OneAddedNewMultiTextElement() - { - string red = @""; - string ancestor = red; - - string blue = @" -
- first -
-
"; - - CheckBothWays(red, blue, ancestor, "lexical-unit/form[@lang='one']/text[text()='first']"); - } - - // private void CheckBothWays(string red, string blue, string ancestor, string xpath) - // { - // XmlNode result= LiftSavvyMergeStrategy.MergeMultiTextPieces(red, blue, ancestor); - // XmlTestHelper.AssertXPathMatchesExactlyOne(result.OuterXml, xpath); - // result= LiftSavvyMergeStrategy.MergeMultiTextPieces(blue, red, ancestor); - // XmlTestHelper.AssertXPathMatchesExactlyOne(result.OuterXml, xpath); - // } - - private void CheckBothWays(string red, string blue, string ancestor, params string[] xpaths) - { - CheckOneWay(red, blue, ancestor, xpaths); - CheckOneWay(blue, red, ancestor, xpaths); - } - - private void CheckOneWay(string ours, string theirs, string ancestor, params string[] xpaths) - { - XmlNode result = MultiTextMerger.MergeMultiTextPieces(ours, theirs, ancestor); - foreach (string xpath in xpaths) - { - XmlTestHelper.AssertXPathMatchesExactlyOne(result.OuterXml, xpath); - } - } - - [Test] - public void MergeMultiTextNodes_EachAddedDifferentAlternatives_GetBoth() - { - - string ancestor = @" - "; - - - string red = @" -
- first -
-
"; - - string blue = @" -
- second -
-
"; - - CheckBothWays(red, blue, ancestor, - "lexical-unit/form[@lang='one']/text[text()='first']", - "lexical-unit/form[@lang='two']/text[text()='second']"); - } - - [Test] - public void MergeMultiTextNodes_OneAddedAnAlternatives_GetBoth() - { - string red = @" -
- first -
-
"; - - string ancestor = red; - - string blue = @" -
- first -
-
- second -
-
"; - - CheckBothWays(red, blue, ancestor, - "lexical-unit/form[@lang='one']/text[text()='first']", - "lexical-unit/form[@lang='two']/text[text()='second']"); - } - - [Test] - public void MergeMultiTextNodes_OnePutSomethingInPreviouslyEmptyForm() - { - string red = @" -
- "; - - string ancestor = red; - - string blue = @" - - first - -
"; - - Assert.That(Utilities.AreXmlElementsEqual(red, blue), Is.False); - - CheckBothWays(red, blue, ancestor, - "lexical-unit/form[@lang='one']/text[text()='first']"); - } - - [Test] - public void MergeMultiTextNodes_OnePutSomethingInPreviouslyEmptyFormText() - { - string red = @" -
-
"; - - string ancestor = red; - - - string blue = @" -
- first -
-
"; - - CheckBothWays(red, blue, ancestor, - "lexical-unit/form[@lang='one']/text[text()='first']"); - } - - [Test] - public void WeDeletedAForm_FormRemoved() - { - string red = @""; - string blue = @" -
- first -
-
"; - string ancestor = blue; - - CheckOneWay(blue, red, ancestor, "lexical-unit[ not(form)]"); - } - - [Test] - public void TheyDeleteAForm_FormRemoved() - { - string red = @""; - string blue = @" -
- first -
-
"; - string ancestor = blue; - - CheckOneWay(blue, red, ancestor, "lexical-unit[ not(form)]"); - } -*/ } }