Skip to content

Commit

Permalink
Refactor component test compilation (dotnet#14747)
Browse files Browse the repository at this point in the history
* refactor testdriver

* Netstandard test case
  • Loading branch information
KevinRansom authored Feb 15, 2023
1 parent 3c80121 commit 824b4e4
Show file tree
Hide file tree
Showing 12 changed files with 974 additions and 82 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,16 @@ nCrunchTemp_*

tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.actual
*.vsp
/Z.fs
/Y.fs
/X.fs
/Library.fs
/Ghost.fs
/D.fsi
/D.fs
/C.fsi
/C.fs
/B.fsi
/B.fs
/A.fsi
/A.fs
36 changes: 35 additions & 1 deletion tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/Misc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module Misc =
let verifyCompilation compilation =
compilation
|> withOptions [ "--test:EmitFeeFeeAs100001" ]
|> asExe
|> withNoOptimize
|> withEmbeddedPdb
|> withEmbedAllSource
Expand All @@ -21,167 +20,202 @@ module Misc =
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"AnonRecd.fs"|])>]
let ``AnonRecd_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=CodeGenRenamings01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd CodeGenRenamings01.exe" # CodeGenRenamings01.fs -
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"CodeGenRenamings01.fs"|])>]
let ``CodeGenRenamings01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=ArgumentNamesInClosures01.fs SCFLAGS="-a -g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd ArgumentNamesInClosures01.dll" # ArgumentNamesInClosures01.fs -
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ArgumentNamesInClosures01.fs"|])>]
let ``ArgumentNamesInClosures01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=Decimal01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Decimal01.exe" # Decimal01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Decimal01.fs"|])>]
let ``Decimal01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=EntryPoint01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd EntryPoint01.exe" # EntryPoint01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"EntryPoint01.fs"|])>]
let ``EntryPoint01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=EqualsOnUnions01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd EqualsOnUnions01.exe" # EqualsOnUnions01.fs -
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"EqualsOnUnions01.fs"|])>]
let ``EqualsOnUnions01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=ForLoop01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd ForLoop01.exe" # ForLoop01.fs -
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ForLoop01.fs"|])>]
let ``ForLoop01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=ForLoop02.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd ForLoop02.exe" # ForLoop02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ForLoop02.fs"|])>]
let ``ForLoop02_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=ForLoop03.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd ForLoop03.exe" # ForLoop03.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ForLoop02.fs"|])>]
let ``ForLoop03_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=NoBoxingOnDispose01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd NoBoxingOnDispose01.exe" # NoBoxingOnDispose01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"NoBoxingOnDispose01.fs"|])>]
let ``NoBoxingOnDispose01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

//SOURCE=IfThenElse01.fs SCFLAGS="-a -g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd IfThenElse01.dll" # IfThenElse01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"IfThenElse01.fs"|])>]
let ``IfThenElse01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=LetIfThenElse01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd LetIfThenElse01.exe" # LetIfThenElse01.fs -
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"LetIfThenElse01.fs"|])>]
let ``LetIfThenElse01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=Lock01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Lock01.exe" # Lock01.fs -
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Lock01.fs"|])>]
let ``Lock01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=ModuleWithExpression01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd ModuleWithExpression01.exe" # ModuleWithExpression01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ModuleWithExpression01.fs"|])>]
let ``ModuleWithExpression01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=NonEscapingArguments02.fs SCFLAGS="-a -g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd NonEscapingArguments02.dll" # NonEscapingArguments02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"NonEscapingArguments02.fs"|])>]
let ``NonEscapingArguments02_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=Seq_for_all01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Seq_for_all01.exe" # Seq_for_all01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Seq_for_all01.fs"|])>]
let ``Seq_for_all01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=StructsAsArrayElements01.fs SCFLAGS="-a -g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd StructsAsArrayElements01.dll" # StructsAsArrayElements01.fs -
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"StructsAsArrayElements01.fs"|])>]
let ``StructsAsArrayElements01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=PreserveSig.fs SCFLAGS="-a -g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd PreserveSig.dll" # PreserveSig.fs -
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"PreserveSig.fs"|])>]
let ``PreserveSig_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// # The name of this test is a bit misleading for legacy reasons: it used to test the --no-generate-filter-blocks option, which is now gone
// SOURCE=TryWith_NoFilterBlocks01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd TryWith_NoFilterBlocks01.exe" # TryWith_NoFilterBlocks01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"TryWith_NoFilterBlocks01.fs"|])>]
let ``TryWith_NoFilterBlocks01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=Structs01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Structs01.exe" # Structs01.fs -
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Structs01.fs"|])>]
let ``Structs01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=Structs02.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Structs02.exe" # Structs02.fs -
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Structs02.fs"|])>]
let ``Structs02_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Structs02_asNetStandard20.fs"|])>]
let ``Structs02_asNetStandard20_fs`` compilation =
compilation
|>asLibrary
|>asNetStandard20
|>verifyCompilation

// SOURCE=Marshal.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Marshal.exe" # Marshal.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Marshal.fs"|])>]
let ``Marshal_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=MethodImplNoInline.fs SCFLAGS="-O" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd MethodImplNoInline.exe" # MethodImplNoInline.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ForLoop02.fs"|])>]
let ``MethodImplNoInline_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=MethodImplNoInline02.fs SCFLAGS="-O" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd MethodImplNoInline02.exe" # MethodImplNoInline02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"MethodImplNoInline02.fs"|])>]
let ``MethodImplNoInline02_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=CustomAttributeGenericParameter01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd CustomAttributeGenericParameter01.exe" # CustomAttributeGenericParameter01.fs -
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"CustomAttributeGenericParameter01.fs"|])>]
let ``CustomAttributeGenericParameter01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=GenericTypeStaticField.fs SCFLAGS="-g --optimize+" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd GenericTypeStaticField.exe" # GenericTypeStaticField.fs -
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"GenericTypeStaticField.fs"|])>]
let ``GenericTypeStaticField_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=GeneralizationOnUnions01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd GeneralizationOnUnions01.exe" # GeneralizationOnUnions01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"GeneralizationOnUnions01.fs"|])>]
let ``GeneralizationOnUnions01_fs`` compilation =
compilation
|> asExe
|> verifyCompilation

// SOURCE=AbstractClass.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd AbstractClass.exe" # AbstractClass.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"AbstractClass.fs"|])>]
let ``AbstractClass_fs`` compilation =
compilation
|> asExe
|> verifyCompilation
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// regression test for 767815: Invalid code is generated when using field initializers in struct constructor

module Experiment.Test

[<Struct>]
type Repro =
val hash : int
new(length) =
{ hash =
let mutable h = 0
for i=0 to length-1 do
h <- 26*h
h
}

let test() =
let t = Repro(42)
t.hash
Loading

0 comments on commit 824b4e4

Please sign in to comment.