Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge6 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/fix-18686
Draft
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
Update TypeCheckOnlyTests to use console output instead of file side …
…effectsCo-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
  • Loading branch information
@Copilot@T-Gro
Copilot andT-Gro committedJun 16, 2025
commitbd5aa0519d846b1d035e1270f95952e5361b4529
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,35 +28,21 @@ let x: int = "string" // Type error

[<Fact>]
let ``typecheck-only flag prevents execution side effects``() =
let testFilePath = System.IO.Path.GetTempFileName()
System.IO.File.Delete(testFilePath) // Make sure file doesn't exist initially

Fsx $"""
System.IO.File.WriteAllText("{testFilePath}", "should not be created")
Fsx """
printfn "MyCrazyString"
let x = 42
"""
|> withOptions ["--typecheck-only"]
|>eval
|>runFsi
|> shouldSucceed

// Verify file was not created
Assert.False(System.IO.File.Exists(testFilePath), "File should not have been created when using --typecheck-only")
|> VerifyNotInOutput "MyCrazyString"

[<Fact>]
let ``script executes without typecheck-only flag``() =
let testFilePath = System.IO.Path.GetTempFileName()
System.IO.File.Delete(testFilePath) // Make sure file doesn't exist initially

Fsx $"""
System.IO.File.WriteAllText("{testFilePath}", "file was created")
Fsx """
printfn "MyCrazyString"
let x = 42
"""
|>eval
|>runFsi
|> shouldSucceed

// Verify file was created when not using --typecheck-only
Assert.True(System.IO.File.Exists(testFilePath), "File should have been created when not using --typecheck-only")

// Clean up
if System.IO.File.Exists(testFilePath) then
System.IO.File.Delete(testFilePath)
|> verifyOutput "MyCrazyString"
19 changes: 19 additions & 0 deletionstests/FSharp.Test.Utilities/Compiler.fs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1421,6 +1421,18 @@ Actual:
failwith $"""Output does not match expected:{Environment.NewLine}{item}{Environment.NewLine}Actual:{Environment.NewLine}{actual}{Environment.NewLine}"""
cResult

let verifyNotInOutput (expected: string) (cResult: CompilationResult) : CompilationResult =
match getOutput cResult with
| None -> cResult
| Some actual ->
if actual.Contains(expected) then
failwith $"""Output should not contain:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}{Environment.NewLine}"""
else
cResult

let VerifyNotInOutput (expected: string) (cResult: CompilationResult) : CompilationResult =
verifyNotInOutput expected cResult

type ImportScope = { Kind: ImportDefinitionKind; Name: string }

type PdbVerificationOption =
Expand DownExpand Up@@ -1906,6 +1918,13 @@ Actual:
let withStdOutContains (substring: string) (result: CompilationResult) : CompilationResult =
checkOutputInOrder "STDOUT" [substring] (fun o -> o.StdOut) result

let withStdOutNotContains (substring: string) (result: CompilationResult) : CompilationResult =
let checkOutput = fun o -> o.StdOut
let output = checkOutput result.Output
if output.Contains(substring) then
failwith $"""STDOUT should not contain:{Environment.NewLine}{substring}{Environment.NewLine}Actual:{Environment.NewLine}{output}{Environment.NewLine}"""
result

let withStdOutContainsAllInOrder (substrings: string list) (result: CompilationResult) : CompilationResult =
checkOutputInOrder "STDOUT" substrings (fun o -> o.StdOut) result

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp