From eb83c36434aac94467acdd072af4ce6f927829a1 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Wed, 8 Apr 2020 09:23:18 +1000 Subject: [PATCH] Fix empty file resolution on MacOs (#80) --- docs/diff-tool.md | 4 ++++ src/DiffEngine.Tests/DiffEngine.Tests.csproj | 5 ++++- src/DiffEngine.Tests/DiffToolsTest.cs | 4 ++++ src/DiffEngine.Tests/ProcessCleanupTests.cs | 6 ++++-- src/DiffEngine.Tests/diffTools.include.md | 4 ++++ src/DiffEngine/DiffEngine.csproj | 5 ++++- src/DiffEngine/ProcessCleanup.cs | 1 - src/DiffEngine/ToolDefinition.cs | 3 ++- src/FakeDiffTool/FakeDiffTool.csproj | 2 +- src/Verify.Bunit/Verify.Bunit.csproj | 2 +- .../AssemblyLocation.cs | 17 +++++++++++++++++ src/Verify.Integration.Tests/Tests.cs | 8 +++++--- src/Verify.Integration.Tests/Tests_Single.cs | 6 ++++-- src/Verify.Integration.Tests/Tests_Split.cs | 7 +++++-- .../Verify.MSTest.Tests.csproj | 5 ++++- src/Verify.MSTest/Verify.MSTest.csproj | 7 +++++-- .../Verify.NUnit.Tests.csproj | 5 ++++- src/Verify.NUnit/Verify.NUnit.csproj | 5 ++++- .../Converters/ExtensionConverterTests.cs | 2 +- src/Verify.Tests/Verify.Tests.csproj | 8 +++++++- .../Verify.Xunit.Tests.csproj | 5 ++++- src/Verify.Xunit/Verify.Xunit.csproj | 5 ++++- src/Verify/Verify.csproj | 3 +++ src/appveyor.yml | 4 +++- 24 files changed, 98 insertions(+), 25 deletions(-) create mode 100644 src/Verify.Integration.Tests/AssemblyLocation.cs diff --git a/docs/diff-tool.md b/docs/diff-tool.md index 4dbe8f75f..9e951c096 100644 --- a/docs/diff-tool.md +++ b/docs/diff-tool.md @@ -87,6 +87,10 @@ This behavior is currently supported on Windows. On Linux and OSX, diff tool ins * `%ProgramFiles%\JetBrains\JetBrains Rider *\bin\rider64.exe` +### OSX scanned paths: + + * `/Applications/Rider*/Contents/MacOS/rider` + ## [VisualStudio](https://docs.microsoft.com/en-us/visualstudio/ide/reference/diff) * IsMdi: True diff --git a/src/DiffEngine.Tests/DiffEngine.Tests.csproj b/src/DiffEngine.Tests/DiffEngine.Tests.csproj index ad3dae1a6..11b1a48d4 100644 --- a/src/DiffEngine.Tests/DiffEngine.Tests.csproj +++ b/src/DiffEngine.Tests/DiffEngine.Tests.csproj @@ -1,9 +1,12 @@  - netcoreapp3.1;net48 + netcoreapp3.1 true + + netcoreapp3.1;net48 + diff --git a/src/DiffEngine.Tests/DiffToolsTest.cs b/src/DiffEngine.Tests/DiffToolsTest.cs index 083e4b18d..6e6fa1b5d 100644 --- a/src/DiffEngine.Tests/DiffToolsTest.cs +++ b/src/DiffEngine.Tests/DiffToolsTest.cs @@ -65,6 +65,7 @@ public void WriteFoundTools() writer.WriteLine($@" * `{path}`"); } } + if (!tool.BinaryExtensions.Any()) { continue; @@ -114,6 +115,8 @@ public void ExtensionLookup() Debug.WriteLine($"{tool.Key}: {tool.Value.Name}"); } } + +#if DEBUG [Fact] public void TryFind() { @@ -132,6 +135,7 @@ public void TryFind() Assert.False(DiffTools.TryFind(DiffTool.Kaleidoscope, "txt", out resolved)); Assert.Null(resolved); } +#endif public DiffToolsTest(ITestOutputHelper output) : base(output) diff --git a/src/DiffEngine.Tests/ProcessCleanupTests.cs b/src/DiffEngine.Tests/ProcessCleanupTests.cs index 42e624f6c..fd5343d6b 100644 --- a/src/DiffEngine.Tests/ProcessCleanupTests.cs +++ b/src/DiffEngine.Tests/ProcessCleanupTests.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +#if DEBUG +using System.Diagnostics; using System.Linq; using DiffEngine; using VerifyXunit; @@ -22,4 +23,5 @@ public ProcessCleanupTests(ITestOutputHelper output) : base(output) { } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/DiffEngine.Tests/diffTools.include.md b/src/DiffEngine.Tests/diffTools.include.md index 6227b9f52..977b80954 100644 --- a/src/DiffEngine.Tests/diffTools.include.md +++ b/src/DiffEngine.Tests/diffTools.include.md @@ -8,6 +8,10 @@ * `%ProgramFiles%\JetBrains\JetBrains Rider *\bin\rider64.exe` +### OSX scanned paths: + + * `/Applications/Rider*/Contents/MacOS/rider` + ## [VisualStudio](https://docs.microsoft.com/en-us/visualstudio/ide/reference/diff) * IsMdi: True diff --git a/src/DiffEngine/DiffEngine.csproj b/src/DiffEngine/DiffEngine.csproj index cc5f8959c..cc7104f51 100644 --- a/src/DiffEngine/DiffEngine.csproj +++ b/src/DiffEngine/DiffEngine.csproj @@ -1,10 +1,13 @@  + netstandard2.0;netstandard2.1 + + netstandard2.0;netstandard2.1;net461 - + diff --git a/src/DiffEngine/ProcessCleanup.cs b/src/DiffEngine/ProcessCleanup.cs index 6a89e5315..4df641f7b 100644 --- a/src/DiffEngine/ProcessCleanup.cs +++ b/src/DiffEngine/ProcessCleanup.cs @@ -21,7 +21,6 @@ static ProcessCleanup() public static void Refresh() { - Thread.Sleep(100); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { commands = FindAll().ToList(); diff --git a/src/DiffEngine/ToolDefinition.cs b/src/DiffEngine/ToolDefinition.cs index 1cd3e3968..67ec5eac3 100644 --- a/src/DiffEngine/ToolDefinition.cs +++ b/src/DiffEngine/ToolDefinition.cs @@ -19,7 +19,8 @@ class ToolDefinition public string[] OsxExePaths { get; } public bool SupportsText { get; } - public ToolDefinition(DiffTool name, + public ToolDefinition( + DiffTool name, string url, bool supportsAutoRefresh, bool isMdi, diff --git a/src/FakeDiffTool/FakeDiffTool.csproj b/src/FakeDiffTool/FakeDiffTool.csproj index 4b5bc6b84..4e7a95c24 100644 --- a/src/FakeDiffTool/FakeDiffTool.csproj +++ b/src/FakeDiffTool/FakeDiffTool.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - false + false bin diff --git a/src/Verify.Bunit/Verify.Bunit.csproj b/src/Verify.Bunit/Verify.Bunit.csproj index e92ed56b9..4e8085610 100644 --- a/src/Verify.Bunit/Verify.Bunit.csproj +++ b/src/Verify.Bunit/Verify.Bunit.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/Verify.Integration.Tests/AssemblyLocation.cs b/src/Verify.Integration.Tests/AssemblyLocation.cs new file mode 100644 index 000000000..39afdf41d --- /dev/null +++ b/src/Verify.Integration.Tests/AssemblyLocation.cs @@ -0,0 +1,17 @@ +using System; +using System.IO; + +static class AssemblyLocation +{ + static AssemblyLocation() + { + var assembly = typeof(AssemblyLocation).Assembly; + + var uri = new UriBuilder(assembly.CodeBase!); + var path = Uri.UnescapeDataString(uri.Path); + + CurrentDirectory = Path.GetDirectoryName(path)!; + } + + public static string CurrentDirectory; +} \ No newline at end of file diff --git a/src/Verify.Integration.Tests/Tests.cs b/src/Verify.Integration.Tests/Tests.cs index a2d7766d9..158e99623 100644 --- a/src/Verify.Integration.Tests/Tests.cs +++ b/src/Verify.Integration.Tests/Tests.cs @@ -1,4 +1,5 @@ -using System; +#if DEBUG +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -21,7 +22,7 @@ public partial class Tests : static Tests() { BuildServerDetector.Detected = false; - var diffToolPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "../../../../FakeDiffTool/bin/FakeDiffTool.exe")); + var diffToolPath = Path.GetFullPath(Path.Combine(AssemblyLocation.CurrentDirectory, "../../../../FakeDiffTool/bin/FakeDiffTool.exe")); tool = new ResolvedDiffTool( name: DiffTool.VisualStudio, exePath: diffToolPath, @@ -131,4 +132,5 @@ public Tests(ITestOutputHelper output) : { ClipboardCapture.Clear(); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/Verify.Integration.Tests/Tests_Single.cs b/src/Verify.Integration.Tests/Tests_Single.cs index 6ef766453..2f73e85af 100644 --- a/src/Verify.Integration.Tests/Tests_Single.cs +++ b/src/Verify.Integration.Tests/Tests_Single.cs @@ -1,4 +1,5 @@ -using System; +#if DEBUG +using System; using System.IO; using System.Threading.Tasks; using DiffEngine; @@ -132,4 +133,5 @@ async Task InitialVerify(Func target, bool hasMatchingDiffTool, VerifySe AssertExists(pair.Received); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/Verify.Integration.Tests/Tests_Split.cs b/src/Verify.Integration.Tests/Tests_Split.cs index f1db653e7..3f6e19976 100644 --- a/src/Verify.Integration.Tests/Tests_Split.cs +++ b/src/Verify.Integration.Tests/Tests_Split.cs @@ -1,4 +1,6 @@ -using System.IO; +#if DEBUG + +using System.IO; using System.Threading.Tasks; using DiffEngine; using Verify; @@ -122,4 +124,5 @@ async Task InitialVerifySplit(TypeToSplit target, bool hasMatchingDiffTool, Veri AssertExists(file2.Received); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/Verify.MSTest.Tests/Verify.MSTest.Tests.csproj b/src/Verify.MSTest.Tests/Verify.MSTest.Tests.csproj index 0a5fee256..36928b6aa 100644 --- a/src/Verify.MSTest.Tests/Verify.MSTest.Tests.csproj +++ b/src/Verify.MSTest.Tests/Verify.MSTest.Tests.csproj @@ -1,9 +1,12 @@  - netcoreapp3.1;net48 + netcoreapp3.1 true + + netcoreapp3.1;net48 + diff --git a/src/Verify.MSTest/Verify.MSTest.csproj b/src/Verify.MSTest/Verify.MSTest.csproj index f6abdd84e..9d4f0f01d 100644 --- a/src/Verify.MSTest/Verify.MSTest.csproj +++ b/src/Verify.MSTest/Verify.MSTest.csproj @@ -1,13 +1,16 @@  - netstandard2.0;netstandard2.1;net472 + netstandard2.0;netstandard2.1 $(NoWarn);CS0436 + + netstandard2.0;netstandard2.1;net472 + - + diff --git a/src/Verify.NUnit.Tests/Verify.NUnit.Tests.csproj b/src/Verify.NUnit.Tests/Verify.NUnit.Tests.csproj index 5417ec679..0ddf63d00 100644 --- a/src/Verify.NUnit.Tests/Verify.NUnit.Tests.csproj +++ b/src/Verify.NUnit.Tests/Verify.NUnit.Tests.csproj @@ -1,9 +1,12 @@  - netcoreapp3.1;net48 + netcoreapp3.1 true + + netcoreapp3.1;net48 + diff --git a/src/Verify.NUnit/Verify.NUnit.csproj b/src/Verify.NUnit/Verify.NUnit.csproj index 2dd2a1b04..4417083b4 100644 --- a/src/Verify.NUnit/Verify.NUnit.csproj +++ b/src/Verify.NUnit/Verify.NUnit.csproj @@ -1,12 +1,15 @@  + netstandard2.0;netstandard2.1 + + netstandard2.0;netstandard2.1;net472 - + diff --git a/src/Verify.Tests/Converters/ExtensionConverterTests.cs b/src/Verify.Tests/Converters/ExtensionConverterTests.cs index c0c9c4a9a..89ffbae7a 100644 --- a/src/Verify.Tests/Converters/ExtensionConverterTests.cs +++ b/src/Verify.Tests/Converters/ExtensionConverterTests.cs @@ -1,4 +1,4 @@ -#if(NETCOREAPP3_1) +#if(NETCOREAPP3_1 && DEBUG) using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; diff --git a/src/Verify.Tests/Verify.Tests.csproj b/src/Verify.Tests/Verify.Tests.csproj index 9d201c85b..c08da13f6 100644 --- a/src/Verify.Tests/Verify.Tests.csproj +++ b/src/Verify.Tests/Verify.Tests.csproj @@ -1,10 +1,16 @@  - netcoreapp3.1;net48 + netcoreapp3.1 true CS8002 + + netcoreapp3.1;net48 + + + + diff --git a/src/Verify.Xunit.Tests/Verify.Xunit.Tests.csproj b/src/Verify.Xunit.Tests/Verify.Xunit.Tests.csproj index edd6062cd..2c54476bd 100644 --- a/src/Verify.Xunit.Tests/Verify.Xunit.Tests.csproj +++ b/src/Verify.Xunit.Tests/Verify.Xunit.Tests.csproj @@ -1,9 +1,12 @@  - netcoreapp3.1;net48 + netcoreapp3.1 true + + netcoreapp3.1;net48 + diff --git a/src/Verify.Xunit/Verify.Xunit.csproj b/src/Verify.Xunit/Verify.Xunit.csproj index 8425569e6..d68eff3e9 100644 --- a/src/Verify.Xunit/Verify.Xunit.csproj +++ b/src/Verify.Xunit/Verify.Xunit.csproj @@ -1,11 +1,14 @@  + netstandard2.0;netstandard2.1 + + netstandard2.0;netstandard2.1;net472 - + diff --git a/src/Verify/Verify.csproj b/src/Verify/Verify.csproj index b636ff7bd..5ea5751f1 100644 --- a/src/Verify/Verify.csproj +++ b/src/Verify/Verify.csproj @@ -1,5 +1,8 @@  + netstandard2.0;netstandard2.1 + + netstandard2.0;netstandard2.1;net472 diff --git a/src/appveyor.yml b/src/appveyor.yml index 42cfdf2a6..8b2789f6c 100644 --- a/src/appveyor.yml +++ b/src/appveyor.yml @@ -1,4 +1,6 @@ -image: Visual Studio 2019 +image: +- macos +- Visual Studio 2019 skip_commits: message: /doco|Merge pull request.*/ build_script: