From bdcb444f40fa2a08d2c76c78ad8c3c7e13ce14c2 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Thu, 25 Aug 2022 08:23:29 -0700 Subject: [PATCH] Fix test case (#13782) Co-authored-by: Vlad Zarytovskii --- .../ConsoleOnlyOptionsTests.fs | 15 ++++++++++----- .../FSharp.Compiler.Service.Tests.fsproj | 2 +- ...d-help-output.txt => expected-help-output.bsl} | 5 +++-- 3 files changed, 14 insertions(+), 8 deletions(-) rename tests/FSharp.Compiler.Service.Tests/{expected-help-output.txt => expected-help-output.bsl} (98%) diff --git a/tests/FSharp.Compiler.Service.Tests/ConsoleOnlyOptionsTests.fs b/tests/FSharp.Compiler.Service.Tests/ConsoleOnlyOptionsTests.fs index 943b49103..332c5cbde 100644 --- a/tests/FSharp.Compiler.Service.Tests/ConsoleOnlyOptionsTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/ConsoleOnlyOptionsTests.fs @@ -11,16 +11,21 @@ open TestDoubles [] [] let ``Help is displayed correctly`` () = + try + if System.Console.BufferWidth < 80 then + System.Console.BufferWidth <- 80 + with _ -> () + let builder = getArbitraryTcConfigBuilder() + builder.showBanner <- false // We don't need the banner + let blocks = GetCoreFscCompilerOptions builder - let expectedHelp = File.ReadAllText $"{__SOURCE_DIRECTORY__}/expected-help-output.txt" + let expectedHelp = File.ReadAllText $"{__SOURCE_DIRECTORY__}/expected-help-output.bsl" let help = GetHelpFsc builder blocks - // contains instead of equals - // as we don't control the 1st line of the output (the version) - // it's tested separately - StringAssert.Contains(expectedHelp, help.Replace("\r\n", Environment.NewLine)) + let actualHelp = help.Replace("\r\n", Environment.NewLine) + Assert.AreEqual(expectedHelp, actualHelp, $"Console width: {System.Console.BufferWidth}\nExpected: {expectedHelp}\n Actual: {actualHelp}") |> ignore [] let ``Version is displayed correctly`` () = diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 81f470dcb..30e2e9c93 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -20,7 +20,7 @@ - + Never diff --git a/tests/FSharp.Compiler.Service.Tests/expected-help-output.txt b/tests/FSharp.Compiler.Service.Tests/expected-help-output.bsl similarity index 98% rename from tests/FSharp.Compiler.Service.Tests/expected-help-output.txt rename to tests/FSharp.Compiler.Service.Tests/expected-help-output.bsl index 7d787f6ce..6be21d85f 100644 --- a/tests/FSharp.Compiler.Service.Tests/expected-help-output.txt +++ b/tests/FSharp.Compiler.Service.Tests/expected-help-output.bsl @@ -1,5 +1,4 @@ -Copyright (c) Microsoft Corporation. All Rights Reserved. - + - OUTPUT FILES - --out: Name of the output file (Short form: @@ -23,6 +22,8 @@ run on: x86, x64, Arm, Arm64, Itanium, anycpu32bitpreferred, or anycpu. The default is anycpu. +--compressmetadata[+|-] Compress interface and optimization + data files --nooptimizationdata Only include optimization information essential for implementing inlined constructs. -- GitLab