From 02c784ee71810d21cb0d38f9d36a8305b428b92e Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 18 Aug 2023 19:23:34 +0800 Subject: [PATCH] scripts/runTests.fsx: acceptance test for warning --- scripts/runTests.fsx | 24 ++++++++++++++++++++++++ test/testWarning.fsx | 7 +++++++ 2 files changed, 31 insertions(+) create mode 100644 test/testWarning.fsx diff --git a/scripts/runTests.fsx b/scripts/runTests.fsx index 102ccd4a..25c83633 100755 --- a/scripts/runTests.fsx +++ b/scripts/runTests.fsx @@ -331,3 +331,27 @@ let legacyDefineTest = Process.Execute(CreateCommand(legacyDefineTest, String.Empty), Echo.All) |> UnwrapDefault + + +let warningTest = Path.Combine(TestDir.FullName, "testWarning.fsx") |> FileInfo + +let currentDir = Directory.GetCurrentDirectory() + +let possibleDirBuildProps = + Path.Combine(currentDir, "Directory.Build.props") |> FileInfo + +if possibleDirBuildProps.Exists then + // this file could alter the behaviour of fsxc when compiling, making the result of the test be misleading + possibleDirBuildProps.Delete() + +let warningAsErrorProc = + Process.Execute(CreateCommand(warningTest, String.Empty), Echo.All) + +match warningAsErrorProc.Result with +| Error _ -> + // warning as error worked! + () +| _ -> + failwithf + "Should have failed to compile/execute %s because warnings as errors" + warningTest.Name diff --git a/test/testWarning.fsx b/test/testWarning.fsx new file mode 100644 index 00000000..80cd0947 --- /dev/null +++ b/test/testWarning.fsx @@ -0,0 +1,7 @@ +#!/usr/bin/env fsx + +let GiveMeBool() : bool = + false + +GiveMeBool() +printf "hello"