Skip to content

Commit c559923

Browse files
authored
Re-enable SB tests (#46055)
1 parent c062fee commit c559923

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/BasicScenarioTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class BasicScenarioTests : SdkTests
1919
{
2020
public BasicScenarioTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
2121

22-
// [Theory(Skip="https://github.com/dotnet/sdk/issues/42920")]
22+
[Theory]
2323
[MemberData(nameof(GetScenarioObjects))]
2424
public void VerifyScenario(TestScenario scenario) => scenario.Execute(DotNetHelper);
2525

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/DotNetFormatTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public DotNetFormatTests(ITestOutputHelper outputHelper) : base(outputHelper) {
2020
/// <Summary>
2121
/// Format an unformatted project and verify that the output matches the pre-computed solution.
2222
/// </Summary>
23-
// [Fact(Skip="https://github.com/dotnet/sdk/issues/42920")]
23+
// Disabled due to https://github.com/dotnet/roslyn/issues/76797
24+
// [Fact]
2425
public void FormatProject()
2526
{
2627
if (DotNetHelper.IsMonoRuntime)

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/DotNetWatchTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class DotNetWatchTests : SdkTests
1313
{
1414
public DotNetWatchTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
1515

16-
// [Fact(Skip="https://github.com/dotnet/sdk/issues/42920")]
16+
[Fact]
1717
public void WatchTests()
1818
{
1919
if (DotNetHelper.IsMonoRuntime)
@@ -36,7 +36,7 @@ public void WatchTests()
3636

3737
void processConfigCallback(Process process)
3838
{
39-
const string waitingString = "Waiting for changes";
39+
const string waitingString = "Waiting for a file to change";
4040
const string expectedString = "Hello from dotnet watch!";
4141

4242
bool fileChanged = false;

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/SymbolsTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public SymbolsTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
2424
/// <summary>
2525
/// Verifies that all symbols have valid sourcelinks.
2626
/// </summary>
27-
// [Fact(Skip="https://github.com/dotnet/sdk/issues/42920")]
27+
[Fact]
2828
public void VerifySdkSymbols()
2929
{
3030
try
@@ -66,6 +66,10 @@ private IList<string> VerifySdkFilesHaveMatchingSymbols(string symbolsRoot, stri
6666
{
6767
Assert.True(Directory.Exists(sdkRoot), $"Path, with SDK files to validate, does not exist: {sdkRoot}");
6868

69+
// Normalize paths, to ensure proper string replacement
70+
symbolsRoot = symbolsRoot.TrimEnd(Path.DirectorySeparatorChar);
71+
sdkRoot = sdkRoot.TrimEnd(Path.DirectorySeparatorChar);
72+
6973
var failedFiles = new ConcurrentBag<string>();
7074

7175
IEnumerable<string> allFiles = Directory.GetFiles(sdkRoot, "*", SearchOption.AllDirectories);

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/WebScenarioTests.cs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
56
using System.Collections.Generic;
67
using System.IO;
78
using System.Linq;
@@ -20,7 +21,7 @@ public class WebScenarioTests : SdkTests
2021
{
2122
public WebScenarioTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
2223

23-
// [Theory(Skip="https://github.com/dotnet/sdk/issues/42920")]
24+
[Theory]
2425
[MemberData(nameof(GetScenarioObjects))]
2526
public void VerifyScenario(TestScenario scenario) => scenario.Execute(DotNetHelper);
2627

@@ -37,8 +38,7 @@ private static IEnumerable<TestScenario> GetScenarios()
3738

3839
yield return new(nameof(WebScenarioTests), DotNetLanguage.CSharp, DotNetTemplate.Razor, DotNetActions.Build | DotNetActions.Run | DotNetActions.Publish);
3940
yield return new(nameof(WebScenarioTests), DotNetLanguage.CSharp, DotNetTemplate.BlazorWasm, DotNetActions.Build | DotNetActions.Run | DotNetActions.Publish);
40-
// Disabled due to .NET 10.0 transition. See https://github.com/dotnet/sdk/pull/42969
41-
// yield return new(nameof(WebScenarioTests), DotNetLanguage.CSharp, DotNetTemplate.WebApp, DotNetActions.PublishSelfContained, VerifyRuntimePacksForSelfContained);
41+
yield return new(nameof(WebScenarioTests), DotNetLanguage.CSharp, DotNetTemplate.WebApp, DotNetActions.PublishSelfContained, VerifyRuntimePacksForSelfContained);
4242
yield return new(nameof(WebScenarioTests), DotNetLanguage.CSharp, DotNetTemplate.Worker);
4343
}
4444

@@ -50,9 +50,30 @@ private static void VerifyRuntimePacksForSelfContained(string projectPath)
5050
string projNugetCachePath = Path.Combine(projectPath, "obj", "project.nuget.cache");
5151

5252
JsonNode? projNugetCache = JsonNode.Parse(File.ReadAllText(projNugetCachePath));
53-
string? restoredPackageFiles = projNugetCache?["expectedPackageFiles"]?.ToString();
53+
JsonArray? restoredPackageFiles = (JsonArray?)projNugetCache?["expectedPackageFiles"];
5454

5555
Assert.True(restoredPackageFiles is not null, "Failed to parse project.nuget.cache");
56-
Assert.True("[]" == restoredPackageFiles, "Runtime packs were retrieved from NuGet instead of the SDK");
56+
57+
string[] allowedPackages = [
58+
// Temporarily allowed due to https://github.com/dotnet/sdk/issues/46165
59+
// TODO: Remove this once the issue is resolved
60+
"Microsoft.AspNetCore.App.Internal.Assets"
61+
];
62+
63+
string packagesDirectory = Path.Combine(Environment.CurrentDirectory, "packages");
64+
65+
IEnumerable<string> packages = restoredPackageFiles
66+
.Select(file =>
67+
{
68+
string path = file.ToString();
69+
path = path.Substring(packagesDirectory.Length + 1); // trim the leading path up to the package name directory
70+
return path.Substring(0, path.IndexOf('/')); // trim the rest of the path
71+
})
72+
.Except(allowedPackages, StringComparer.OrdinalIgnoreCase);
73+
74+
if (packages.Any())
75+
{
76+
Assert.Fail($"The following runtime packs were retrieved from NuGet instead of the SDK: {string.Join(",", packages.ToArray())}");
77+
}
5778
}
5879
}

0 commit comments

Comments
 (0)