Fix test runs on xplat
This commit is contained in:
parent
dd297b6d09
commit
3369bb6e90
|
|
@ -21,29 +21,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation.Tests
|
|||
|
||||
public ApplicationTestFixture Fixture { get; }
|
||||
|
||||
public static IEnumerable<object[]> ApplicationWithTagHelpersData
|
||||
public static IEnumerable<object[]> SupportedFlavorsTheoryData
|
||||
{
|
||||
get
|
||||
{
|
||||
var runtimeFlavors = new[]
|
||||
{
|
||||
RuntimeFlavor.Clr,
|
||||
RuntimeFlavor.CoreClr,
|
||||
};
|
||||
|
||||
var urls = new[]
|
||||
{
|
||||
"Index",
|
||||
"ViewWithPreprocessor",
|
||||
};
|
||||
|
||||
return Enumerable.Zip(urls, runtimeFlavors, (a, b) => new object[] { a, b });
|
||||
return RuntimeFlavors.SupportedFlavors.Select(f => new object[] { f });
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(RuntimeFlavor.Clr)]
|
||||
[InlineData(RuntimeFlavor.CoreClr)]
|
||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||
public async Task Precompilation_RunsConfiguredCompilationCallbacks(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
|
|
@ -56,7 +43,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation.Tests
|
|||
};
|
||||
|
||||
// Act
|
||||
var response = await httpClient.GetStringAsync("");
|
||||
var response = await httpClient.GetStringWithRetryAsync("", Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("ApplicationWithConfigureMvc.Home.Index.txt", response);
|
||||
|
|
@ -64,8 +51,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation.Tests
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(RuntimeFlavor.Clr)]
|
||||
[InlineData(RuntimeFlavor.CoreClr)]
|
||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||
public async Task Precompilation_UsesConfiguredParseOptions(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
|
|
@ -78,7 +64,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation.Tests
|
|||
};
|
||||
|
||||
// Act
|
||||
var response = await httpClient.GetStringAsync("Home/ViewWithPreprocessor");
|
||||
var response = await httpClient.GetStringWithRetryAsync("Home/ViewWithPreprocessor", Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent(
|
||||
|
|
|
|||
|
|
@ -25,12 +25,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
|||
{
|
||||
get
|
||||
{
|
||||
var runtimeFlavors = new[]
|
||||
{
|
||||
RuntimeFlavor.Clr,
|
||||
RuntimeFlavor.CoreClr,
|
||||
};
|
||||
|
||||
var urls = new[]
|
||||
{
|
||||
"ClassLibraryTagHelper",
|
||||
|
|
@ -38,7 +32,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
|||
"NuGetPackageTagHelper",
|
||||
};
|
||||
|
||||
return Enumerable.Zip(urls, runtimeFlavors, (a, b) => new object[] { a, b });
|
||||
return Enumerable.Zip(urls, RuntimeFlavors.SupportedFlavors, (a, b) => new object[] { a, b });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +50,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
|||
};
|
||||
|
||||
// Act
|
||||
var response = await httpClient.GetStringAsync($"Home/{url}");
|
||||
var response = await httpClient.GetStringWithRetryAsync($"Home/{url}", Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent($"ApplicationWithTagHelpers.Home.{url}.txt", response);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
|
@ -30,8 +31,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
|||
|
||||
public string TempRestoreDirectory { get; } = CreateTempRestoreDirectory();
|
||||
|
||||
public ILogger Logger { get; private set; }
|
||||
|
||||
public IApplicationDeployer CreateDeployment(RuntimeFlavor flavor)
|
||||
{
|
||||
Logger = new LoggerFactory()
|
||||
.AddConsole()
|
||||
.CreateLogger($"{ApplicationName}:{flavor}");
|
||||
|
||||
if (!_isRestored)
|
||||
{
|
||||
Restore();
|
||||
|
|
@ -61,11 +68,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
|||
},
|
||||
};
|
||||
|
||||
var logger = new LoggerFactory()
|
||||
.AddConsole()
|
||||
.CreateLogger($"{ApplicationName}:{flavor}");
|
||||
|
||||
return ApplicationDeployerFactory.Create(deploymentParameters, logger);
|
||||
return ApplicationDeployerFactory.Create(deploymentParameters, Logger);
|
||||
}
|
||||
|
||||
protected virtual void Restore()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
||||
{
|
||||
public static class HttpClientExtensions
|
||||
{
|
||||
public static async Task<string> GetStringWithRetryAsync(
|
||||
this HttpClient httpClient,
|
||||
string url,
|
||||
ILogger logger)
|
||||
{
|
||||
var response = await RetryHelper.RetryRequest(() => httpClient.GetAsync(url), logger, retryCount: 5);
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
Assert.True(response.IsSuccessStatusCode,
|
||||
$"Failed to GET content from {url}. Status code {response.StatusCode}." +
|
||||
Environment.NewLine +
|
||||
content);
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
||||
{
|
||||
public static class RuntimeFlavors
|
||||
{
|
||||
public static IEnumerable<RuntimeFlavor> SupportedFlavors
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return RuntimeFlavor.CoreClr;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
yield return RuntimeFlavor.Clr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
|
|
@ -18,9 +20,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
|||
|
||||
public ApplicationTestFixture Fixture { get; }
|
||||
|
||||
public static IEnumerable<object[]> SupportedFlavorsTheoryData
|
||||
{
|
||||
get
|
||||
{
|
||||
return RuntimeFlavors.SupportedFlavors.Select(f => new object[] { f });
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(RuntimeFlavor.Clr)]
|
||||
[InlineData(RuntimeFlavor.CoreClr)]
|
||||
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||
public async Task Precompilation_WorksForSimpleApps(RuntimeFlavor flavor)
|
||||
{
|
||||
// Arrange
|
||||
|
|
@ -33,7 +42,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Precompilation
|
|||
};
|
||||
|
||||
// Act
|
||||
var response = await httpClient.GetStringAsync("");
|
||||
var response = await httpClient.GetStringWithRetryAsync("", Fixture.Logger);
|
||||
|
||||
// Assert
|
||||
TestEmbeddedResource.AssertContent("SimpleAppTest.Home.Index.txt", response);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"buildOptions": {
|
||||
"define": [
|
||||
"GENERATE_BASELINES"
|
||||
"__remove_this_to__GENERATE_BASELINES"
|
||||
],
|
||||
"embed": "Resources/*"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ namespace ApplicationWithConfigureStartup
|
|||
{
|
||||
if (node.Token.IsKind(SyntaxKind.StringLiteralToken))
|
||||
{
|
||||
return node.WithToken(SyntaxFactory.Literal(node.Token.ValueText.Replace("\r\n", "\r\n<br />")));
|
||||
return node.WithToken(SyntaxFactory.Literal(
|
||||
node.Token.ValueText.Replace(Environment.NewLine, Environment.NewLine + "<br />")));
|
||||
}
|
||||
|
||||
return node;
|
||||
|
|
|
|||
Loading…
Reference in New Issue