From 0481cc6569bbef771eb5e0cb2bc3091842a0250e Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Thu, 6 Apr 2017 11:20:10 -0700 Subject: [PATCH] Fix travis We were missing the newline normalization from the test base class. --- .../CodeGenerationIntegrationTest.cs | 41 ------------------- .../IntegrationTests/IntegrationTestBase.cs | 12 ++++-- .../NamespaceToken.codegen.cs | 2 +- .../NamespaceToken.cshtml | 2 +- .../NamespaceToken.ir.txt | 2 +- .../NamespaceToken.mappings.txt | 8 ++-- 6 files changed, 16 insertions(+), 51 deletions(-) diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/CodeGenerationIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/CodeGenerationIntegrationTest.cs index e3a5e2866e..c32d648865 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/CodeGenerationIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/CodeGenerationIntegrationTest.cs @@ -1573,47 +1573,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests } #endregion - protected override RazorCodeDocument CreateCodeDocument() - { - if (Filename == null) - { - var message = $"{nameof(CreateCodeDocument)} should only be called from an integration test ({nameof(Filename)} is null)."; - throw new InvalidOperationException(message); - } - - var normalizedFileName = Filename.Substring(0, Filename.LastIndexOf("_")); - var sourceFilename = Path.ChangeExtension(normalizedFileName, ".cshtml"); - var testFile = TestFile.Create(sourceFilename); - if (!testFile.Exists()) - { - throw new XunitException($"The resource {sourceFilename} was not found."); - } - - var imports = new List(); - while (true) - { - var importsFilename = Path.ChangeExtension(normalizedFileName + "_Imports" + imports.Count.ToString(), ".cshtml"); - if (!TestFile.Create(importsFilename).Exists()) - { - break; - } - - imports.Add( - TestRazorSourceDocument.CreateResource(importsFilename, encoding: null, normalizeNewLines: true)); - } - - var codeDocument = RazorCodeDocument.Create( - TestRazorSourceDocument.CreateResource(sourceFilename, encoding: null, normalizeNewLines: true), imports); - - // This will ensure that we're not putting any randomly generated data in a baseline. - codeDocument.Items[DefaultRazorCSharpLoweringPhase.SuppressUniqueIds] = "test"; - - // This is to make tests work cross platform. - codeDocument.Items[DefaultRazorCSharpLoweringPhase.NewLineString] = "\r\n"; - - return codeDocument; - } - private void RunRuntimeTagHelpersTest(IEnumerable descriptors, string tagHelperPrefix = null) { // Arrange diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/IntegrationTestBase.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/IntegrationTestBase.cs index 93f3664acd..b4348df0b0 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/IntegrationTestBase.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/IntegrationTestBase.cs @@ -60,7 +60,9 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests throw new InvalidOperationException(message); } - var sourceFilename = Path.ChangeExtension(Filename, ".cshtml"); + var suffixIndex = Filename.LastIndexOf("_"); + var normalizedFileName = suffixIndex == -1 ? Filename : Filename.Substring(0, suffixIndex); + var sourceFilename = Path.ChangeExtension(normalizedFileName, ".cshtml"); var testFile = TestFile.Create(sourceFilename); if (!testFile.Exists()) { @@ -70,12 +72,12 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests var imports = new List(); while (true) { - var importsFilename = Path.ChangeExtension(Filename + "_Imports" + imports.Count.ToString(), ".cshtml"); + var importsFilename = Path.ChangeExtension(normalizedFileName + "_Imports" + imports.Count.ToString(), ".cshtml"); if (!TestFile.Create(importsFilename).Exists()) { break; } - + imports.Add( TestRazorSourceDocument.CreateResource(importsFilename, encoding: null, normalizeNewLines: true)); } @@ -85,6 +87,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests // This will ensure that we're not putting any randomly generated data in a baseline. codeDocument.Items[DefaultRazorCSharpLoweringPhase.SuppressUniqueIds] = "test"; + + // This is to make tests work cross platform. + codeDocument.Items[DefaultRazorCSharpLoweringPhase.NewLineString] = "\r\n"; + return codeDocument; } diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.codegen.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.codegen.cs index 9eb3d32e26..9ffd3b81ee 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.codegen.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.codegen.cs @@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles #pragma warning disable 219 private void __RazorDirectiveTokenHelpers__() { ((System.Action)(() => { -global::System.Object __typeHelper = nameof(Sytem.Globalization); +global::System.Object __typeHelper = nameof(System.Globalization); } ))(); } diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.cshtml b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.cshtml index a291a48ea7..0a8f147643 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.cshtml +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.cshtml @@ -1 +1 @@ -@custom Sytem.Globalization \ No newline at end of file +@custom System.Globalization \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.ir.txt b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.ir.txt index 51c411b81b..40909bb3a3 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.ir.txt +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.ir.txt @@ -9,7 +9,7 @@ Document - RazorIRToken - - CSharp - #pragma warning disable 219 CSharpStatement - RazorIRToken - - CSharp - private void __RazorDirectiveTokenHelpers__() { - DirectiveToken - (8:0,8 [19] NamespaceToken.cshtml) - Sytem.Globalization + DirectiveToken - (8:0,8 [20] NamespaceToken.cshtml) - System.Globalization CSharpStatement - RazorIRToken - - CSharp - } CSharpStatement - diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.mappings.txt b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.mappings.txt index c9835cb7a9..ff55f17ece 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.mappings.txt +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.mappings.txt @@ -1,5 +1,5 @@ -Source Location: (8:0,8 [19] TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.cshtml) -|Sytem.Globalization| -Generated Location: (413:10,44 [19] ) -|Sytem.Globalization| +Source Location: (8:0,8 [20] TestFiles/IntegrationTests/ExtensibleDirectiveTest/NamespaceToken.cshtml) +|System.Globalization| +Generated Location: (413:10,44 [20] ) +|System.Globalization|