Skip to content

Commit

Permalink
Merge branch 'marcpopMSFT-updatetfm' of https://github.com/dotnet/sdk
Browse files Browse the repository at this point in the history
…into marcpopMSFT-updatetfm
  • Loading branch information
marcpopMSFT committed Nov 18, 2022
2 parents 6bc8daf + c4deeb3 commit 7783633
Show file tree
Hide file tree
Showing 110 changed files with 22,039 additions and 19,706 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>$(AspNetTestTfm)</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Copyright>© Microsoft</Copyright>
<Product>Razor Test</Product>
<Company>Microsoft</Company>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>$(AspNetTestTfm)</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Copyright>© Microsoft</Copyright>
<Product>Razor Test</Product>
<Company>Microsoft</Company>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Copyright>© Microsoft</Copyright>
<Product>Razor Test</Product>
<Company>Microsoft</Company>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Copyright>© Microsoft</Copyright>
<Product>Razor Test</Product>
<Company>Microsoft</Company>
Expand Down
7 changes: 6 additions & 1 deletion src/RazorSdk/update-test-baselines.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
param([switch] $Validate)
$RepoRoot= Resolve-Path "$PSScriptRoot/../.."

$TestProjects = "Microsoft.NET.Sdk.Razor.Tests", "Microsoft.NET.Sdk.BlazorWebAssembly.Tests" |
ForEach-Object { Join-Path -Path "$RepoRoot/src/Tests/" -ChildPath $_ };

$TestProjects | ForEach-Object { dotnet test --no-build -l "console;verbosity=normal" $_ -e ASPNETCORE_TEST_BASELINES=true --filter AspNetCore=BaselineTest }
if($Validate){
$TestProjects | ForEach-Object { dotnet test --no-build -l "console;verbosity=normal" $_ --filter AspNetCore=BaselineTest }
}else {
$TestProjects | ForEach-Object { dotnet test --no-build -l "console;verbosity=normal" $_ -e ASPNETCORE_TEST_BASELINES=true --filter AspNetCore=BaselineTest }
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void Publish60Hosted_Works()
AssertManifest(manifest, LoadPublishManifest());

AssertPublishAssets(
StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)),
manifest,
publishOutputDirectory.FullName,
intermediateOutputPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,6 @@ public class BlazorWasmBaselineTests : AspNetSdkBaselineTest
{
public BlazorWasmBaselineTests(ITestOutputHelper log, bool generateBaselines) : base(log, generateBaselines)
{
PathTemplatizer = TemplatizeCompressedAssets;
}

private string TemplatizeCompressedAssets(StaticWebAsset asset, string originalValue, StaticWebAsset relatedAsset)
{
if (!asset.IsAlternativeAsset() && Path.GetExtension(asset.Identity) != ".gz")
{
return null;
}

if (asset.RelatedAsset == originalValue)
{
return null;
}

if (originalValue.Replace("[[CustomPackageVersion]]", "__CustomVersion__").Replace("[[hash]]", "__Hash__").Contains("[["))
{
return null;
}

var result = asset.Identity.Contains("[[") ? asset.Identity : Path.Combine(Path.GetDirectoryName(asset.Identity), "[[" + asset.RelativePath + "]]");

if (GenerateBaselines)
{
result = Regex.Replace(result, DotNetJSHashRegexPattern, DotNetJSHashTemplate);
return result.Replace(RuntimeVersion, "${RuntimeVersion}").Replace(DefaultPackageVersion, "${PackageVersion}");
}
else
{
return result.Replace("${RuntimeVersion}", RuntimeVersion).Replace("${PackageVersion}", DefaultPackageVersion);
}
}

protected override string EmbeddedResourcePrefix => string.Join('.', "Microsoft.NET.Sdk.BlazorWebAssembly.Tests", "StaticWebAssetsBaselines");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using Microsoft.AspNetCore.Razor.Tasks;
using Microsoft.NET.TestFramework.Assertions;
Expand All @@ -18,12 +15,8 @@ namespace Microsoft.NET.Sdk.BlazorWebAssembly.Tests
{
public class BlazorWasmStaticWebAssetsIntegrationTest : BlazorWasmBaselineTests
{
private static readonly string DotNet5JSRegexPattern = "dotnet\\.5\\.[0-9]+\\.[0-9]+\\.js";
private readonly string DotNet5JSTemplate;

public BlazorWasmStaticWebAssetsIntegrationTest(ITestOutputHelper log) : base(log, GenerateBaselines)
{
DotNet5JSTemplate = $"dotnet.{RuntimeVersion}.js";
}

[Fact]
Expand Down Expand Up @@ -55,7 +48,7 @@ public void StaticWebAssets_BuildMinimal_Works()
new FileInfo(finalPath).Should().Exist();

AssertBuildAssets(
StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)),
manifest,
outputPath,
intermediateOutputPath);
}
Expand Down Expand Up @@ -85,7 +78,7 @@ public void StaticWebAssets_PublishMinimal_Works()
AssertManifest(manifest, LoadPublishManifest());

AssertPublishAssets(
StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)),
manifest,
publishPath,
intermediateOutputPath);
}
Expand Down Expand Up @@ -116,7 +109,7 @@ public void StaticWebAssets_Build_Hosted_Works()
new FileInfo(finalPath).Should().Exist();

AssertBuildAssets(
StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)),
manifest,
outputPath,
intermediateOutputPath);
}
Expand Down Expand Up @@ -147,7 +140,7 @@ public void StaticWebAssets_Publish_Hosted_Works()
AssertManifest(manifest, LoadPublishManifest());

AssertPublishAssets(
StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)),
manifest,
publishPath,
intermediateOutputPath);
}
Expand Down Expand Up @@ -178,12 +171,12 @@ public void StaticWebAssets_Publish_DoesNotIncludeXmlDocumentationFiles_AsAssets
AssertManifest(manifest, LoadPublishManifest());

AssertPublishAssets(
StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)),
manifest,
publishPath,
intermediateOutputPath);
}

[Fact]
[Fact(Skip = "https://github.com/dotnet/sdk/issues/29111")]
public void StaticWebAssets_HostedApp_ReferencingNetStandardLibrary_Works()
{
// Arrange
Expand Down Expand Up @@ -221,32 +214,14 @@ public void StaticWebAssets_HostedApp_ReferencingNetStandardLibrary_Works()
new FileInfo(path).Should().Exist();
var manifest = StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path));

// We have to special case this test given we are forcing `blazorwasm` to be a `net5` project above.
// Given this, the `dotnet.*.js` file produced will be a dotnet.5.*.*.js file in line with the TFM and not the SDK (which is .NET 6 or beyond).
// This conflicts with our assumptions throughout the rest of the test suite that the SDK version matches the TFM.
// To minimize special casing throughout the entire test suite, we just update this particular test's assets to reflect the SDK version.
var numFilesUpdated = 0;
foreach (var f in manifest.Assets)
{
if (Regex.Match(f.RelativePath, DotNet5JSRegexPattern).Success)
{
f.Identity = Regex.Replace(f.Identity, DotNet5JSRegexPattern, DotNet5JSTemplate);
f.RelativePath = Regex.Replace(f.RelativePath, DotNet5JSRegexPattern, DotNet5JSTemplate);
f.OriginalItemSpec = Regex.Replace(f.OriginalItemSpec, DotNet5JSRegexPattern, DotNet5JSTemplate);

numFilesUpdated++;
}
}
Assert.Equal(2, numFilesUpdated);

AssertManifest(manifest, LoadBuildManifest());

// GenerateStaticWebAssetsManifest should copy the file to the output folder.
var finalPath = Path.Combine(outputPath, "blazorhosted.staticwebassets.runtime.json");
new FileInfo(finalPath).Should().Exist();

AssertBuildAssets(
StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)),
manifest,
outputPath,
intermediateOutputPath);
}
Expand Down Expand Up @@ -293,27 +268,10 @@ public void StaticWebAssets_BackCompatibilityPublish_Hosted_Works()
new FileInfo(path).Should().Exist();
var manifest = StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path));

// We have to special case this test given we are forcing `blazorwasm` to be a `net5` project above.
// Given this, the `dotnet.*.js` file produced will be a dotnet.5.*.*.js file in line with the TFM and not the SDK (which is .NET 6 or beyond).
// This conflicts with our assumptions throughout the rest of the test suite that the SDK version matches the TFM.
// To minimize special casing throughout the entire test suite, we just update this particular test's assets to reflect the SDK version.
var numFilesUpdated = 0;
var frameworkFolder = Path.Combine(publishPath, "wwwroot", "_framework");
var frameworkFolderFiles = Directory.GetFiles(frameworkFolder, "*", new EnumerationOptions { RecurseSubdirectories = false });
foreach (var f in frameworkFolderFiles)
{
if (Regex.Match(f, DotNet5JSRegexPattern).Success)
{
File.Move(f, Regex.Replace(f, DotNet5JSRegexPattern, DotNet5JSTemplate));
numFilesUpdated++;
}
}
Assert.Equal(3, numFilesUpdated);

AssertManifest(manifest, LoadPublishManifest());

AssertPublishAssets(
StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)),
manifest,
publishPath,
intermediateOutputPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

<ItemGroup>
<Compile Include="..\Microsoft.NET.Sdk.Razor.Tests\AspNetSdkBaselineTest.cs" Link="AspNetSdkBaselineTest.cs" />
<Compile Include="..\Microsoft.NET.Sdk.Razor.Tests\StaticWebAssetsBaselineFactory.cs" Link="StaticWebAssetsBaselineFactory.cs" />
<Compile Include="..\Microsoft.NET.Sdk.Razor.Tests\StaticWebAssetsBaselineComparer.cs" Link="StaticWebAssetsBaselineComparer.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 7783633

Please sign in to comment.