Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
521b9c3
Implement task environment APIs
AR-May Oct 15, 2025
38b6b37
Update src/Framework/PathHelpers/AbsolutePath.cs
AR-May Oct 15, 2025
dec8a43
Have environment variables case sensitivity defined by the platform
AR-May Oct 16, 2025
cb3796a
Fix mac os tests failures
AR-May Oct 16, 2025
3ee6525
Merge branch 'main' into implement-mt-apis
AR-May Oct 16, 2025
dbe28b6
Merge branch 'main' into implement-mt-apis
AR-May Nov 21, 2025
3a53037
Address some PR comments.
AR-May Nov 21, 2025
6e4af2d
Address PR comments - 2
AR-May Nov 24, 2025
e0bd256
Try to fix mac os tests.
AR-May Nov 24, 2025
5a84f3b
Add more tests for absolute paths.
AR-May Nov 24, 2025
5b28d23
Remove unnecessary test
AR-May Nov 24, 2025
1cfba8c
fix test reseting
JanProvaznik Nov 24, 2025
740d75e
fix macos symlinks
JanProvaznik Nov 25, 2025
42a28ab
Address PR comments - 3
AR-May Nov 25, 2025
1baaa4c
AbsolutePath naming and docs
JanProvaznik Nov 26, 2025
8e97c0a
minor doc changes
JanProvaznik Nov 26, 2025
abb7f4f
Consolidate environment variable utilities
JanProvaznik Nov 26, 2025
abba41e
Add cached FrozenDictionary-based GetEnvironmentVariables for Framework
JanProvaznik Nov 26, 2025
1a83cd4
add IEquatable, clarify docs of AbsolutePath
JanProvaznik Nov 26, 2025
dc771d0
move drivers to build from framework
JanProvaznik Nov 26, 2025
4c89a50
undo environmentutilities refactors after moving drivers to build
JanProvaznik Nov 26, 2025
ccc8144
fun with case sensitivity of file systems
JanProvaznik Nov 26, 2025
9c0a270
docs
JanProvaznik Nov 26, 2025
8c162d6
env vars are case sensitive on unix
JanProvaznik Nov 27, 2025
59ba721
remove unnecessary assemblyinfo
JanProvaznik Nov 27, 2025
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
71 changes: 71 additions & 0 deletions src/Framework.UnitTests/AbsolutePath_Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.IO;
using Microsoft.Build.Framework;
using Shouldly;
using Xunit;

namespace Microsoft.Build.UnitTests
{
public class AbsolutePath_Tests
{
[Fact]
public void AbsolutePath_FromAbsolutePath_ShouldPreservePath()
{
string absolutePathString = Path.GetTempPath();
var absolutePath = new AbsolutePath(absolutePathString);

absolutePath.Path.ShouldBe(absolutePathString);
Path.IsPathRooted(absolutePath.Path).ShouldBeTrue();
}

[Theory]
[InlineData("subfolder")]
[InlineData("deep/nested/path")]
[InlineData(".")]
[InlineData("")]
[InlineData("..")]
public void AbsolutePath_FromRelativePath_ShouldResolveAgainstBase(string relativePath)
{
string baseDirectory = Path.Combine(Path.GetTempPath(), "testfolder");
var basePath = new AbsolutePath(baseDirectory);
var absolutePath = new AbsolutePath(relativePath, basePath);

Path.IsPathRooted(absolutePath.Path).ShouldBeTrue();

string expectedPath = Path.Combine(baseDirectory, relativePath);
absolutePath.Path.ShouldBe(expectedPath);
}

[Fact]
public void AbsolutePath_Equality_ShouldWorkCorrectly()
{
string testPath = Path.GetTempPath();
var path1 = new AbsolutePath(testPath);
var path2 = new AbsolutePath(testPath);
var differentPath = new AbsolutePath(Path.Combine(testPath, "different"));

path1.ShouldBe(path2);
(path1 == path2).ShouldBeTrue();
path1.ShouldNotBe(differentPath);
(path1 == differentPath).ShouldBeFalse();
}

[Theory]
[InlineData("not/rooted/path", false, true)]
[InlineData("not/rooted/path", true, false)]
public void AbsolutePath_RootedValidation_ShouldBehaveProperly(string path, bool ignoreRootedCheck, bool shouldThrow)
{
if (shouldThrow)
{
Should.Throw<System.ArgumentException>(() => new AbsolutePath(path, ignoreRootedCheck: ignoreRootedCheck));
}
else
{
var absolutePath = new AbsolutePath(path, ignoreRootedCheck: ignoreRootedCheck);
absolutePath.Path.ShouldBe(path);
}
}
}
}
Loading
Loading