Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@
<Compile Include="ErrorMessages\FS0988AtEndOfFile.fs" />
<Compile Include="ErrorMessages\Repro1548.fs" />
<Compile Include="ErrorMessages\WarnIfDiscardedInList.fs" />
<Compile Include="ErrorMessages\UnionCasePatternMatchingErrors.fs"/>
<Compile Include="ErrorMessages\InterfaceImplInAugmentationsTests.fs"/>
<Compile Include="ErrorMessages\UnionCasePatternMatchingErrors.fs" />
<Compile Include="ErrorMessages\InterfaceImplInAugmentationsTests.fs" />
<Compile Include="Language\IndexerSetterParamArray.fs" />
<Compile Include="Language\MultiDimensionalArrayTests.fs" />
<Compile Include="Language\RegressionTests.fs" />
Expand Down Expand Up @@ -207,6 +207,7 @@
<Compile Include="Signatures\RecordTests.fs" />
<Compile Include="Signatures\ArrayTests.fs" />
<Compile Include="Signatures\TypeTests.fs" />
<Compile Include="FSharpChecker\CommonWorkflows.fs" />
</ItemGroup>
<ItemGroup>
<Content Include="resources\**" CopyToOutputDirectory="Never" CopyToPublishDirectory="PreserveNewest" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
module FSharp.Compiler.ComponentTests.FSharpChecker.CommonWorkflows

open System
open System.IO

open Xunit

open FSharp.Test.ProjectGeneration

let projectDir = "test-projects"

let makeTestProject () =
let name = $"testProject{Guid.NewGuid().ToString()[..7]}"
let dir = Path.GetFullPath projectDir
{
Name = name
ProjectDir = dir ++ name
SourceFiles = [
sourceFile "First" []
sourceFile "Second" ["First"]
sourceFile "Third" ["First"]
{ sourceFile "Last" ["Second"; "Third"] with EntryPoint = true }
]
DependsOn = []
}

[<Fact>]
let ``Edit file, check it, then check dependent file`` () =
projectWorkflow (makeTestProject()) {
updateFile "First" breakDependentFiles
checkFile "First" expectSignatureChanged
saveFile "First"
checkFile "Second" expectErrors
}

[<Fact>]
let ``Edit file, don't check it, check dependent file`` () =
projectWorkflow (makeTestProject()) {
updateFile "First" breakDependentFiles
saveFile "First"
checkFile "Second" expectErrors
}

[<Fact>]
let ``Check transitive dependency`` () =
projectWorkflow (makeTestProject()) {
updateFile "First" breakDependentFiles
saveFile "First"
checkFile "Last" expectSignatureChanged
}

[<Fact>]
let ``Change multiple files at once`` () =
projectWorkflow (makeTestProject()) {
updateFile "First" (setPublicVersion 2)
updateFile "Second" (setPublicVersion 2)
updateFile "Third" (setPublicVersion 2)
saveAll
checkFile "Last" (expectSignatureContains "val f: x: 'a -> (ModuleFirst.TFirstV_2<'a> * ModuleSecond.TSecondV_2<'a>) * (ModuleFirst.TFirstV_2<'a> * ModuleThird.TThirdV_2<'a>) * TLastV_1<'a>")
}

[<Fact>]
let ``Files depend on signature file if present`` () =
(makeTestProject()
|> updateFile "First" (fun f -> { f with HasSignatureFile = true })
|> projectWorkflow) {
updateFile "First" breakDependentFiles
saveFile "First"
checkFile "Second" expectNoChanges
}

[<Fact>]
let ``Adding a file`` () =
projectWorkflow (makeTestProject()) {
addFileAbove "Second" (sourceFile "New" [])
updateFile "Second" (addDependency "New")
saveAll
checkFile "Last" (expectSignatureContains "val f: x: 'a -> (ModuleNew.TNewV_1<'a> * ModuleFirst.TFirstV_1<'a> * ModuleSecond.TSecondV_1<'a>) * (ModuleFirst.TFirstV_1<'a> * ModuleThird.TThirdV_1<'a>) * TLastV_1<'a>")
}

[<Fact>]
let ``Removing a file`` () =
projectWorkflow (makeTestProject()) {
removeFile "Second"
saveAll
checkFile "Last" expectErrors
}

[<Fact>]
let ``Changes in a referenced project`` () =
let name = $"library{Guid.NewGuid().ToString()[..7]}"
let dir = Path.GetFullPath projectDir
let library = {
Name = name
ProjectDir = dir ++ name
SourceFiles = [ sourceFile "Library" [] ]
DependsOn = []
}

let project =
{ makeTestProject() with DependsOn = [library] }
|> updateFile "First" (addDependency "Library")

projectWorkflow project {
updateFile "Library" updatePublicSurface
saveFile "Library"
checkFile "Last" expectSignatureChanged
}
1 change: 1 addition & 0 deletions tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Compile Include="..\scripts\scriptlib.fsx">
<Link>scriptlib.fsx</Link>
</Compile>
<Compile Include="ProjectGeneration.fs" />
<Compile Include="TestFramework.fs" />
<Compile Include="ILChecker.fs" />
<Compile Include="Utilities.fs" />
Expand Down
Loading