Tests: extract 'should update baselines' checks · dotnet/fsharp@4dccca0 · GitHub
Skip to content

Commit 4dccca0

Browse files
committed
Tests: extract 'should update baselines' checks
1 parent 9661324 commit 4dccca0

3 files changed

Lines changed: 19 additions & 22 deletions

File tree

‎tests/FSharp.Compiler.Service.Tests/SyntaxTreeTests.fs‎

Lines changed: 8 additions & 8 deletions

‎tests/FSharp.Test.Utilities/Compiler.fs‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ namespace FSharp.Test
55
open FSharp.Compiler.Interactive.Shell
66
open FSharp.Compiler.IO
77
open FSharp.Compiler.Diagnostics
8-
open FSharp.Compiler.Symbols
98
open FSharp.Compiler.Text
10-
open FSharp.Test.Assert
119
open FSharp.Test.Utilities
1210
open FSharp.Test.ScriptHelpers
1311
open Microsoft.CodeAnalysis
@@ -27,9 +25,10 @@ open TestFramework
2725

2826
open System.Runtime.CompilerServices
2927
open System.Runtime.InteropServices
30-
open FSharp.Compiler.CodeAnalysis
3128

3229
module rec Compiler =
30+
let shouldUpdateBaselines =
31+
Environment.GetEnvironmentVariable("TEST_UPDATE_BSL") <> null
3332

3433
[<AutoOpen>]
3534
type SourceUtilities () =
@@ -1230,10 +1229,8 @@ Expected:
12301229
{expected}
12311230
Actual:
12321231
{actual}"""
1233-
let updateBaseline () =
1234-
snd (Int32.TryParse(Environment.GetEnvironmentVariable("TEST_UPDATE_BSL"))) <> 0
12351232
let updateBaseLineIfEnvironmentSaysSo baseline =
1236-
if updateBaseline () then
1233+
if shouldUpdateBaselines then
12371234
if FileSystem.FileExistsShim baseline.FilePath then
12381235
FileSystem.CopyShim(baseline.FilePath, baseline.BslSource, true)
12391236

@@ -2020,7 +2017,7 @@ Actual:
20202017
match Assert.shouldBeSameMultilineStringSets expectedContent actualErrors with
20212018
| None -> ()
20222019
| Some diff ->
2023-
if Environment.GetEnvironmentVariable("TEST_UPDATE_BSL") <> null then
2020+
if shouldUpdateBaselines then
20242021
File.WriteAllText(path, actualErrors)
20252022

20262023
printfn $"{Path.GetFullPath path} \n {diff}"

‎tests/FSharp.Test.Utilities/SurfaceArea.fs‎

Lines changed: 7 additions & 7 deletions

0 commit comments

Comments
 (0)