-
Notifications
You must be signed in to change notification settings - Fork 825
[WIP] Support --typecheck-only for fsi run (just typecheck, no execution) #18687
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
base: main
Are you sure you want to change the base?
Changes from all commits
4995602
89b69aa
a8db5c6
7ea403c
bd5aa05
9836e52
e276875
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module FSharp.Compiler.ComponentTests.Scripting.TypeCheckOnlyTests | ||
|
||
open Xunit | ||
open FSharp.Test | ||
open FSharp.Test.Compiler | ||
|
||
[<Fact>] | ||
let ``typecheck-only flag works for valid script``() = | ||
Fsx """ | ||
let x = 42 | ||
printfn "This should not execute" | ||
""" | ||
|> withOptions ["--typecheck-only"] | ||
|> compile | ||
|> shouldSucceed | ||
|
||
[<Fact>] | ||
let ``typecheck-only flag catches type errors``() = | ||
Fsx """ | ||
let x: int = "string" // Type error | ||
""" | ||
|> withOptions ["--typecheck-only"] | ||
|> compile | ||
|> shouldFail | ||
|> withDiagnostics [ | ||
(Error 1, Line 2, Col 14, Line 2, Col 22, "This expression was expected to have type\n 'int' \nbut here has type\n 'string'") | ||
] | ||
|
||
[<Fact>] | ||
let ``typecheck-only flag prevents execution side effects``() = | ||
Fsx """ | ||
printfn "MyCrazyString" | ||
let x = 42 | ||
""" | ||
|> withOptions ["--typecheck-only"] | ||
|> runFsi | ||
|> shouldSucceed | ||
|> verifyNotInOutput "MyCrazyString" | ||
|
||
[<Fact>] | ||
let ``script executes without typecheck-only flag``() = | ||
Fsx """ | ||
printfn "MyCrazyString" | ||
let x = 42 | ||
""" | ||
|> runFsi | ||
|> shouldSucceed | ||
|> verifyOutput "MyCrazyString" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You only really used
VerifyNotInOutput
in the test.The other added functions are not used and can be removed.
Also, add release notes for this new flag and new feature.
Also, do run tests via
./build.sh -c Release --testcoreclr --norestore
and address all failures.