Skip to content

Commit bae0291

Browse files
committed
Tests now use correct path style on Windows vs Unix.
1 parent c6b0393 commit bae0291

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

test/Client.Tests/ClientTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public ClientTests(ITestOutputHelper testOutput)
3232
/// <summary>
3333
/// Get an absolute document path for use in tests.
3434
/// </summary>
35-
string AbsoluteDocumentPath => Path.DirectorySeparatorChar + "Foo.txt"; // Absolute path, cross-platform compatible.
35+
string AbsoluteDocumentPath => IsWindows ? @"C:\Foo.txt" : "/Foo.txt";
3636

3737
/// <summary>
3838
/// The <see cref="LanguageClient"/> under test.
@@ -141,4 +141,4 @@ void HandleServerInitialize()
141141
});
142142
}
143143
}
144-
}
144+
}

test/Client.Tests/TestBase.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Reactive.Disposables;
44
using System.Reflection;
5+
using System.Runtime.InteropServices;
56
using System.Threading;
67
using Xunit;
78
using Xunit.Abstractions;
@@ -124,5 +125,15 @@ protected virtual void Dispose(bool disposing)
124125
/// The logging level for the current test.
125126
/// </summary>
126127
protected virtual LogLevel LogLevel => LogLevel.Information;
128+
129+
/// <summary>
130+
/// Is the test running on Windows?
131+
/// </summary>
132+
protected virtual bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
133+
134+
/// <summary>
135+
/// Is the test running on a Unix-like operating system?
136+
/// </summary>
137+
protected virtual bool IsUnix => RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
127138
}
128139
}

0 commit comments

Comments
 (0)