Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to warnings as errors #33

Merged
merged 3 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ THIS REPO IS FACING A COMPLETE OVERHAUL/REVAMP/RENOVATION IN ORDER TO SUPPORT .N
Unfinished tasks so far:
* Revamp this ReadMe.md file to remove any mentions to Mono or the legacy .NET4.x framework.
* Remove legacy framework support (so that build system can converge into .fsx files instead of autotools in Unix + fsx in Windows).
* Make fsxc always enable warnAsError and fsx always disable it.
* Allow fsxc && fsx disable warnAsError (via --w flag? or --ignore-warnings).
* After doing the above, make both fsx and fsxc always enable warnAsError for the FS0020 warning described in https://stackoverflow.com/questions/38202685/fsx-script-ignoring-a-function-call-when-i-add-a-parameter-to-it
* Try creating VMs for CI that uninstall .NETCore/.NET6 completely (not just the dotnet executable removal hack), to make sure legacy framework build still works there.
* Try creating VMs for CI that uninstall Mono/.NET4.x completey (e.g. for macOS see: https://github.com/mono/website/commit/490797429d4b92584394292ff69fbdc0eb002948 )
Expand Down
4 changes: 3 additions & 1 deletion Tools/nugetPush.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ let FindOrGenerateNugetPackages() : seq<FileInfo> =
{
Command = "dotnet"
Arguments =
sprintf "pack -c Release -p:Version=%s" nugetVersion
sprintf
"pack --configuration Release -p:Version=%s"
nugetVersion
}

Process
Expand Down
8 changes: 7 additions & 1 deletion fsxc/Fsxc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,9 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() }
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
"""

let initialProjectContents = initialProjectContents
Expand Down Expand Up @@ -766,7 +769,10 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() }


#if !LEGACY_FRAMEWORK
sprintf "build %s -c %s" projectFile.FullName buildConfig
sprintf
"build %s --configuration %s"
projectFile.FullName
buildConfig
#else
let maybeDebugDefine =
if buildConfigIsDebug then
Expand Down
51 changes: 51 additions & 0 deletions scripts/runTests.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,54 @@ let legacyDefineTest =

Process.Execute(CreateCommand(legacyDefineTest, String.Empty), Echo.All)
|> UnwrapDefault


let contentOfScriptWithWarning =
"""#!/usr/bin/env fsx

let GiveMeBool() : bool =
false

GiveMeBool()
printf "hello"
"""

let warningTest = Path.Combine(TestDir.FullName, "testWarning.fsx") |> FileInfo
File.WriteAllText(warningTest.FullName, contentOfScriptWithWarning)

match Misc.GuessPlatform() with
| Misc.Platform.Windows -> ()
| _ ->
Process
.Execute(
{
Command = "chmod"
Arguments = sprintf "+x %s" warningTest.FullName
},
Echo.All
)
.UnwrapDefault()
|> ignore<string>

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

warningTest.Delete()
Loading