Skip to content

Commit 3540e95

Browse files
authored
Enable tests following the net10 transition (#44931)
2 parents 830cf11 + 9592c8a commit 3540e95

File tree

5 files changed

+42
-25
lines changed

5 files changed

+42
-25
lines changed

test/Microsoft.NET.Build.Containers.IntegrationTests/CreateNewImageTests.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public CreateNewImageTests(ITestOutputHelper testOutput)
2020
_testOutput = testOutput;
2121
}
2222

23-
[DockerAvailableFact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
23+
[DockerAvailableFact]
2424
public void CreateNewImage_Baseline()
2525
{
2626
DirectoryInfo newProjectDir = new(GetTestDirectoryName());
@@ -70,7 +70,7 @@ private static ImageConfig GetImageConfigFromTask(CreateNewImage task)
7070
return new(task.GeneratedContainerConfiguration);
7171
}
7272

73-
[DockerAvailableFact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
73+
[DockerAvailableFact]
7474
public void ParseContainerProperties_EndToEnd()
7575
{
7676
DirectoryInfo newProjectDir = new(GetTestDirectoryName());
@@ -133,7 +133,7 @@ public void ParseContainerProperties_EndToEnd()
133133
/// <summary>
134134
/// Creates a console app that outputs the environment variable added to the image.
135135
/// </summary>
136-
[DockerAvailableFact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
136+
[DockerAvailableFact]
137137
public void Tasks_EndToEnd_With_EnvironmentVariable_Validation()
138138
{
139139
DirectoryInfo newProjectDir = new(GetTestDirectoryName());
@@ -151,6 +151,8 @@ public void Tasks_EndToEnd_With_EnvironmentVariable_Validation()
151151
.Execute()
152152
.Should().Pass();
153153

154+
EndToEndTests.ChangeTargetFrameworkAfterAppCreation(newProjectDir.FullName);
155+
154156
File.WriteAllText(Path.Combine(newProjectDir.FullName, "Program.cs"), $"Console.Write(Environment.GetEnvironmentVariable(\"GoodEnvVar\"));");
155157

156158
new DotnetCommand(_testOutput, "build", "--configuration", "release", "/p:runtimeidentifier=linux-x64", $"/p:RuntimeFrameworkVersion={DockerRegistryManager.RuntimeFrameworkVersion}")
@@ -191,7 +193,7 @@ public void Tasks_EndToEnd_With_EnvironmentVariable_Validation()
191193
cni.BaseImageTag = pcp.ParsedContainerTag;
192194
cni.Repository = pcp.NewContainerRepository;
193195
cni.OutputRegistry = pcp.NewContainerRegistry;
194-
cni.PublishDirectory = Path.Combine(newProjectDir.FullName, "bin", "release", ToolsetInfo.CurrentTargetFramework, "linux-x64");
196+
cni.PublishDirectory = Path.Combine(newProjectDir.FullName, "bin", "release", EndToEndTests._oldFramework, "linux-x64");
195197
cni.WorkingDirectory = "/app";
196198
cni.Entrypoint = new TaskItem[] { new($"/app/{newProjectDir.Name}") };
197199
cni.ImageTags = pcp.NewContainerTags;
@@ -216,7 +218,7 @@ public void Tasks_EndToEnd_With_EnvironmentVariable_Validation()
216218
.And.HaveStdOut("Foo");
217219
}
218220

219-
[DockerAvailableFact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
221+
[DockerAvailableFact]
220222
public async System.Threading.Tasks.Task CreateNewImage_RootlessBaseImage()
221223
{
222224
const string RootlessBase = "dotnet/rootlessbase";

test/Microsoft.NET.Build.Containers.IntegrationTests/EndToEndTests.cs

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,20 @@ public void Dispose()
3838
_loggerFactory.Dispose();
3939
}
4040

41-
[DockerAvailableFact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
41+
internal static readonly string _oldFramework = "net9.0";
42+
// CLI will not let us to target net9.0 anymore but we still need it because images for net10.0 aren't ready yet.
43+
// so we let it create net10.0 app, then change the target. Since we're building just small sample applications, it works.
44+
internal static void ChangeTargetFrameworkAfterAppCreation(string path)
45+
{
46+
DirectoryInfo d = new DirectoryInfo(path);
47+
FileInfo[] Files = d.GetFiles("*.csproj"); //Getting .csproj files
48+
string csprojFilename = Files[0].Name; // There is only one
49+
string text = File.ReadAllText(Path.Combine(path, csprojFilename));
50+
text = text.Replace("net10.0", _oldFramework);
51+
File.WriteAllText(Path.Combine(path, csprojFilename), text);
52+
}
53+
54+
[DockerAvailableFact]
4255
public async Task ApiEndToEndWithRegistryPushAndPull()
4356
{
4457
ILogger logger = _loggerFactory.CreateLogger(nameof(ApiEndToEndWithRegistryPushAndPull));
@@ -85,7 +98,7 @@ public async Task ApiEndToEndWithRegistryPushAndPull()
8598
}
8699
}
87100

88-
[DockerAvailableFact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
101+
[DockerAvailableFact]
89102
public async Task ApiEndToEndWithLocalLoad()
90103
{
91104
ILogger logger = _loggerFactory.CreateLogger(nameof(ApiEndToEndWithLocalLoad));
@@ -126,7 +139,7 @@ public async Task ApiEndToEndWithLocalLoad()
126139
}
127140
}
128141

129-
[DockerAvailableFact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
142+
[DockerAvailableFact]
130143
public async Task ApiEndToEndWithArchiveWritingAndLoad()
131144
{
132145
ILogger logger = _loggerFactory.CreateLogger(nameof(ApiEndToEndWithArchiveWritingAndLoad));
@@ -193,8 +206,11 @@ private string BuildLocalApp([CallerMemberName] string testName = "TestName", st
193206
.Execute()
194207
.Should().Pass();
195208

209+
ChangeTargetFrameworkAfterAppCreation(Path.Combine(TestSettings.TestArtifactsDirectory, testName, "MinimalTestApp"));
210+
211+
196212
var publishCommand =
197-
new DotnetCommand(_testOutput, "publish", "-bl", "MinimalTestApp", "-r", rid, "-f", tfm, "-c", "Debug")
213+
new DotnetCommand(_testOutput, "publish", "-bl", "MinimalTestApp", "-r", rid, "-f", _oldFramework, "-c", "Debug")
198214
.WithWorkingDirectory(workingDirectory);
199215

200216
if (tfm == ToolsetInfo.CurrentTargetFramework)
@@ -205,11 +221,11 @@ private string BuildLocalApp([CallerMemberName] string testName = "TestName", st
205221
publishCommand.Execute()
206222
.Should().Pass();
207223

208-
string publishDirectory = Path.Join(workingDirectory, "MinimalTestApp", "bin", "Debug", tfm, rid, "publish");
224+
string publishDirectory = Path.Join(workingDirectory, "MinimalTestApp", "bin", "Debug", _oldFramework, rid, "publish");
209225
return publishDirectory;
210226
}
211227

212-
[DockerAvailableFact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
228+
[DockerAvailableFact]
213229
public async Task EndToEnd_MultiProjectSolution()
214230
{
215231
ILogger logger = _loggerFactory.CreateLogger(nameof(EndToEnd_MultiProjectSolution));
@@ -262,7 +278,7 @@ public async Task EndToEnd_MultiProjectSolution()
262278
document
263279
.Descendants()
264280
.First(e => e.Name.LocalName == "TargetFramework")
265-
.Value = ToolsetInfo.CurrentTargetFramework;
281+
.Value = _oldFramework;
266282

267283
stream.SetLength(0);
268284
await document.SaveAsync(stream, SaveOptions.None, CancellationToken.None);
@@ -275,7 +291,7 @@ public async Task EndToEnd_MultiProjectSolution()
275291
document
276292
.Descendants()
277293
.First(e => e.Name.LocalName == "TargetFramework")
278-
.Value = ToolsetInfo.CurrentTargetFramework;
294+
.Value = _oldFramework;
279295

280296
stream.SetLength(0);
281297
await document.SaveAsync(stream, SaveOptions.None, CancellationToken.None);
@@ -291,7 +307,7 @@ public async Task EndToEnd_MultiProjectSolution()
291307
commandResult.Should().HaveStdOutContaining("Pushed image 'consoleapp:latest'");
292308
}
293309

294-
[DockerAvailableTheory(Skip = "https://github.com/dotnet/sdk/issues/42850")]
310+
[DockerAvailableTheory(Skip = "https://github.com/dotnet/sdk/issues/45181")]
295311
[InlineData("webapi", false)]
296312
[InlineData("webapi", true)]
297313
[InlineData("worker", false)]
@@ -313,7 +329,6 @@ public async Task EndToEnd_NoAPI_ProjectType(string projectType, bool addPackage
313329

314330
newProjectDir.Create();
315331
privateNuGetAssets.Create();
316-
317332
new DotnetNewCommand(_testOutput, projectType, "-f", ToolsetInfo.CurrentTargetFramework)
318333
.WithVirtualHive()
319334
.WithWorkingDirectory(newProjectDir.FullName)
@@ -399,7 +414,6 @@ public async Task EndToEnd_NoAPI_ProjectType(string projectType, bool addPackage
399414
processResult.Should().Pass();
400415
Assert.NotNull(processResult.StdOut);
401416
string appContainerId = processResult.StdOut.Trim();
402-
403417
bool everSucceeded = false;
404418

405419

@@ -468,7 +482,7 @@ public async Task EndToEnd_NoAPI_ProjectType(string projectType, bool addPackage
468482
privateNuGetAssets.Delete(true);
469483
}
470484

471-
[DockerAvailableFact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
485+
[DockerAvailableFact]
472486
public void EndToEnd_NoAPI_Console()
473487
{
474488
DirectoryInfo newProjectDir = new(Path.Combine(TestSettings.TestArtifactsDirectory, "CreateNewImageTest"));
@@ -494,6 +508,7 @@ public void EndToEnd_NoAPI_Console()
494508
.WithEnvironmentVariable("NUGET_PACKAGES", privateNuGetAssets.FullName)
495509
.Execute()
496510
.Should().Pass();
511+
ChangeTargetFrameworkAfterAppCreation(newProjectDir.FullName);
497512

498513
File.Copy(Path.Combine(TestContext.Current.TestExecutionDirectory, "NuGet.config"), Path.Combine(newProjectDir.FullName, "NuGet.config"));
499514

@@ -506,7 +521,7 @@ public void EndToEnd_NoAPI_Console()
506521
.Should().Pass();
507522

508523
// Add package to the project
509-
new DotnetCommand(_testOutput, "add", "package", "Microsoft.NET.Build.Containers", "-f", ToolsetInfo.CurrentTargetFramework, "-v", packageVersion)
524+
new DotnetCommand(_testOutput, "add", "package", "Microsoft.NET.Build.Containers", "-f", _oldFramework , "-v", packageVersion)
510525
.WithEnvironmentVariable("NUGET_PACKAGES", privateNuGetAssets.FullName)
511526
.WithWorkingDirectory(newProjectDir.FullName)
512527
.Execute()
@@ -555,7 +570,7 @@ public void EndToEnd_NoAPI_Console()
555570
[DockerSupportsArchInlineData("linux/386", "linux-x86", "/app", Skip = "There's no apphost for linux-x86 so we can't execute self-contained, and there's no .NET runtime base image for linux-x86 so we can't execute framework-dependent.")]
556571
[DockerSupportsArchInlineData("windows/amd64", "win-x64", "C:\\app")]
557572
[DockerSupportsArchInlineData("linux/amd64", "linux-x64", "/app")]
558-
[DockerAvailableTheory(Skip = "https://github.com/dotnet/sdk/issues/42850")]
573+
[DockerAvailableTheory]
559574
public async Task CanPackageForAllSupportedContainerRIDs(string dockerPlatform, string rid, string workingDir)
560575
{
561576
ILogger logger = _loggerFactory.CreateLogger(nameof(CanPackageForAllSupportedContainerRIDs));

test/dotnet-watch.Tests/HotReload/ApplyDeltaTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.DotNet.Watcher.Tests
88
{
99
public class ApplyDeltaTests(ITestOutputHelper logger) : DotNetWatchTestBase(logger)
1010
{
11-
[Fact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
11+
[Fact]
1212
public async Task AddSourceFile()
1313
{
1414
Logger.WriteLine("AddSourceFile started");
@@ -43,7 +43,7 @@ public static void Print()
4343
await App.AssertOutputLineStartsWith("Changed!");
4444
}
4545

46-
[Fact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
46+
[Fact]
4747
public async Task ChangeFileInDependency()
4848
{
4949
var testAsset = TestAssets.CopyTestAsset("WatchAppWithProjectDeps")
@@ -69,7 +69,7 @@ public static void Print()
6969
}
7070

7171
// Test is timing out on .NET Framework: https://github.com/dotnet/sdk/issues/41669
72-
[CoreMSBuildOnlyFact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
72+
[CoreMSBuildOnlyFact]
7373
public async Task HandleTypeLoadFailure()
7474
{
7575
var testAsset = TestAssets.CopyTestAsset("WatchAppTypeLoadFailure")
@@ -206,7 +206,7 @@ public async Task BlazorWasm()
206206
//await App.AssertOutputLineStartsWith(MessageDescriptor.HotReloadSucceeded);
207207
}
208208

209-
[Fact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
209+
[Fact]
210210
public async Task BlazorWasm_MSBuildWarning()
211211
{
212212
var testAsset = TestAssets

test/dotnet-watch.Tests/HotReload/CompilationHandlerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.DotNet.Watcher.Tests;
88

99
public class CompilationHandlerTests(ITestOutputHelper logger) : DotNetWatchTestBase(logger)
1010
{
11-
[Fact(Skip = "https://github.com/dotnet/sdk/issues/42850")]
11+
[Fact]
1212
public async Task ReferenceOutputAssembly_False()
1313
{
1414
var testAsset = TestAssets.CopyTestAsset("WatchAppMultiProc")

test/dotnet-watch.Tests/HotReload/RuntimeProcessLauncherTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ async Task MakeRudeEditChange()
225225
}
226226
}
227227

228-
[Theory(Skip = "https://github.com/dotnet/sdk/issues/42850")]
228+
[Theory]
229229
[CombinatorialData]
230230
public async Task UpdateAppliedToNewProcesses(bool sharedOutput)
231231
{

0 commit comments

Comments
 (0)