Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Use the following shell command:
```console
$ dotnet test
```
Tests involving symlink creation require elevated privileges on Windows, as this is enforced at the OS level.

Test Documentation
------------------
Expand Down
15 changes: 13 additions & 2 deletions TruePath.Tests/AbsolutePathTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 Friedrich von Never <friedrich@fornever.me>
// SPDX-FileCopyrightText: 2024-2026 TruePath contributors <friedrich@fornever.me>
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -91,7 +91,18 @@ public void ReadKind_IsSymlink()

var tempDirectoryInfo = Path.GetTempPath();

Directory.CreateSymbolicLink(currentDirectory, tempDirectoryInfo);
try
{
Directory.CreateSymbolicLink(currentDirectory, tempDirectoryInfo);
}
catch (IOException e) when (OperatingSystem.IsWindows() && !Utils.RunsOnCi())
{
if (e.Message.Contains("privilege") && (e.StackTrace?.Contains("CreateSymbolicLink") ?? false))
{
Assert.Skip("Tests involving symlink creation require elevated privileges on Windows, as this is enforced at the OS level.");
}
else throw;
}

// Act
var kind = localPath.ReadKind();
Expand Down
4 changes: 1 addition & 3 deletions TruePath.Tests/LocalPathTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// SPDX-FileCopyrightText: 2024 Friedrich von Never <friedrich@fornever.me>
// SPDX-FileCopyrightText: 2024-2026 TruePath contributors <friedrich@fornever.me>
//
// SPDX-License-Identifier: MIT

using Xunit.Abstractions;

namespace TruePath.Tests;

public class LocalPathTests(ITestOutputHelper output)
Expand Down
3 changes: 1 addition & 2 deletions TruePath.Tests/NormalizationTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-FileCopyrightText: 2024-2025 TruePath contributors <https://github.com/ForNeVeR/TruePath>
// SPDX-FileCopyrightText: 2024-2026 TruePath contributors <https://github.com/ForNeVeR/TruePath>
//
// SPDX-License-Identifier: MIT

using FsCheck;
using FsCheck.Fluent;
using FsCheck.Xunit;
using JetBrains.Annotations;
using Xunit.Abstractions;

namespace TruePath.Tests;

Expand Down
6 changes: 3 additions & 3 deletions TruePath.Tests/TruePath.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
SPDX-FileCopyrightText: 2024-2025 TruePath contributors <https://github.com/ForNeVeR/TruePath>
SPDX-FileCopyrightText: 2024-2026 TruePath contributors <https://github.com/ForNeVeR/TruePath>

SPDX-License-Identifier: MIT
-->
Expand All @@ -14,14 +14,14 @@ SPDX-License-Identifier: MIT
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FsCheck.Xunit" Version="3.3.2" />
<PackageReference Include="FsCheck.Xunit.v3" Version="3.3.2" />
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.v3" Version="3.2.2" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 6 additions & 1 deletion TruePath.Tests/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 TruePath contributors <https://github.com/ForNeVeR/TruePath>
// SPDX-FileCopyrightText: 2024-2026 TruePath contributors <https://github.com/ForNeVeR/TruePath>
//
// SPDX-License-Identifier: MIT

Expand All @@ -22,4 +22,9 @@ internal static string ToNonCanonicalCase(this string path)

return nonCanonicalPath;
}

internal static bool RunsOnCi()
{
return Environment.GetEnvironmentVariable("CI") is not null;
}
}