Skip to content

Commit e7403bf

Browse files
committed
Skip workload restore tests in Helix container due to read-only DOTNET_ROOT
1 parent 0d90f8c commit e7403bf

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

test/dotnet.Tests/CommandTests/Workload/Restore/GivenDotnetWorkloadRestore.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ public GivenDotnetWorkloadRestore(ITestOutputHelper log) : base(log)
1515
[Fact]
1616
public void ProjectsThatDoNotSupportWorkloadsAreNotInspected()
1717
{
18-
var testDir = _testAssetsManager.CreateTestDirectory().Path;
19-
var cliHome = Path.Combine(testDir, ".home");
18+
if(IsRunningInContainer())
19+
{
20+
// Skipping test in a Helix container environment due to read-only DOTNET_ROOT, which causes workload restore to fail when writing workload metadata.
21+
return;
22+
}
2023

2124
var projectPath =
2225
_testAssetsManager
@@ -26,7 +29,6 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected()
2629

2730
new DotnetWorkloadCommand(Log, "restore")
2831
.WithWorkingDirectory(projectPath)
29-
.WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome)
3032
.Execute()
3133
.Should()
3234
// if we did try to restore the dcproj in this TestAsset we would fail, so passing means we didn't!
@@ -36,8 +38,11 @@ public void ProjectsThatDoNotSupportWorkloadsAreNotInspected()
3638
[Fact]
3739
public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBreakTheBuild()
3840
{
39-
var testDir = _testAssetsManager.CreateTestDirectory().Path;
40-
var cliHome = Path.Combine(testDir, ".home");
41+
if(IsRunningInContainer())
42+
{
43+
// Skipping test in a Helix container environment due to read-only DOTNET_ROOT, which causes workload restore to fail when writing workload metadata.
44+
return;
45+
}
4146

4247
var projectPath =
4348
_testAssetsManager
@@ -47,10 +52,14 @@ public void ProjectsThatDoNotSupportWorkloadsAndAreTransitivelyReferencedDoNotBr
4752

4853
new DotnetWorkloadCommand(Log, "restore")
4954
.WithWorkingDirectory(projectPath)
50-
.WithEnvironmentVariable("DOTNET_CLI_HOME", cliHome)
5155
.Execute()
5256
.Should()
5357
// if we did try to restore the esproj in this TestAsset we would fail, so passing means we didn't!
5458
.Pass();
5559
}
60+
61+
private bool IsRunningInContainer()
62+
{
63+
return File.Exists("/.dockerenv") && RuntimeInformation.OSDescription.Contains("Ubuntu");
64+
}
5665
}

0 commit comments

Comments
 (0)