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

Moved CodeGen/EmittedIL/Mutation over to NUnit #7352

Merged
merged 10 commits into from
Aug 9, 2019

Conversation

sergey-tihon
Copy link
Contributor

@sergey-tihon sergey-tihon commented Aug 3, 2019

part of #7075

TODO:

  • Allow to use snippets with warnings
  • Make assemblyname stable (<StartupCode$Mutation02> vs <StartupCode$tmpF1A6> )
  • Support .NET Core (expected IL in test should be runtime independent,[mscorlib]System.Object vs [System.Runtime]System.Object )

@sergey-tihon
Copy link
Contributor Author

sergey-tihon commented Aug 4, 2019

Updated 08/08: New IL is generated with --optimize- option
Updated 08/09: -g option

Before merging this keep in mind that I've changed expected IL vs old baseline IL.
Not sure how current tests pass ... but hope that change is expected.

Everything is OK now.

@sergey-tihon sergey-tihon changed the title [WIP] Moved CodeGen/EmittedIL/Mutation over to NUnit Moved CodeGen/EmittedIL/Mutation over to NUnit Aug 4, 2019
@sergey-tihon
Copy link
Contributor Author

This PR is ready for review.
Anything I can do to help merge it?

@KevinRansom
Copy link
Member

@sergey-tihon the difference in the il between the original and your port is because, the original tests were compiled with optimization disabled. Whereas the
You can tell what the original compile switches were from the scflags in the env.lst file:

	SOURCE=Mutation01.fs   SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Mutation01.exe"		# Mutation01.fs -

	SOURCE=Mutation02.fs   SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Mutation02.exe"		# Mutation02.fs
	SOURCE=Mutation03.fs   SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Mutation03.exe"		# Mutation03.fs
	SOURCE=Mutation04.fs   SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Mutation04.exe"		# Mutation04.fs
	SOURCE=Mutation05.fs   SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Mutation05.exe"		# Mutation05.fs

@sergey-tihon
Copy link
Contributor Author

Thank you @KevinRansom I'll take a look how to do --optimize- inside test framework

@KevinRansom
Copy link
Member

@sergey-tihon probably just add a func:
CompilerAssert.CompileLibraryAndVerifyILWithOptions
and then pass in [| "--optimize-"|]

@sergey-tihon
Copy link
Contributor Author

I've added CompilerAssert.CompileLibraryAndVerifyILWithOptions function converted tests to be compiled with --optimize- option, but new IL still differ from the bsl

Please look at my previous comment bsl vs new, it it updated based on output from --optimize-

@KevinRansom
Copy link
Member

@sergey-tihon :
so apparently it's

[|"-g"; "--optimize-"; |]
  //fsc Program.fs -g --optimize-
  {
    .entrypoint
    // Code size       33 (0x21)
    .maxstack  4
    .locals init ([0] valuetype [mscorlib]System.TimeSpan x,
             [1] valuetype [mscorlib]System.TimeSpan V_1)
    IL_0000:  ldsfld     valuetype [mscorlib]System.TimeSpan [mscorlib]System.TimeSpan::MinValue
    IL_0005:  dup
    IL_0006:  stsfld     valuetype [mscorlib]System.TimeSpan '<StartupCode$Program>'.$Mutation02::x@2
    IL_000b:  stloc.0
    IL_000c:  call       valuetype [mscorlib]System.TimeSpan Mutation02::get_x()
    IL_0011:  stloc.1
    IL_0012:  ldloca.s   V_1
    IL_0014:  constrained. [mscorlib]System.TimeSpan
    IL_001a:  callvirt   instance string [mscorlib]System.Object::ToString()
    IL_001f:  pop
    IL_0020:  ret
  } // end of method $Mutation02::main@
  // fsc Program.fs
  {
    .entrypoint
    // Code size       38 (0x26)
    .maxstack  8
    IL_0000:  ldsfld     valuetype [mscorlib]System.TimeSpan [mscorlib]System.TimeSpan::MinValue
    IL_0005:  stsfld     valuetype [mscorlib]System.TimeSpan '<StartupCode$Program>'.$Mutation02::x@2
    IL_000a:  call       valuetype [mscorlib]System.TimeSpan Mutation02::get_x()
    IL_000f:  stsfld     valuetype [mscorlib]System.TimeSpan '<StartupCode$Program>'.$Mutation02::copyOfStruct@3
    IL_0014:  ldsflda    valuetype [mscorlib]System.TimeSpan '<StartupCode$Program>'.$Mutation02::copyOfStruct@3
    IL_0019:  constrained. [mscorlib]System.TimeSpan
    IL_001f:  callvirt   instance string [mscorlib]System.Object::ToString()
    IL_0024:  pop
    IL_0025:  ret
  } // end of method $Mutation02::main@

@sergey-tihon
Copy link
Contributor Author

@KevinRansom Thank you, my bad. I have tried -g for Mutation 1 test it did not affect IL and decided that irrelevant, but it really works for others.

The only question is the IL from first test, I've updated original comment with new IL.

@sergey-tihon
Copy link
Contributor Author

I found the issue, IL was different because I changed

member t.setV v = t.v <- 0

to

member t.setV _ = t.v <- 0

when was not able to compile source with warnings.

Everything should be OK now. Expected IL should match IL from bsl.

@cartermp
Copy link
Contributor

cartermp commented Aug 9, 2019

Thanks!

@cartermp cartermp merged commit 0353825 into dotnet:master Aug 9, 2019
@sergey-tihon sergey-tihon deleted the codegen_mutation branch August 9, 2019 17:59
@sergey-tihon sergey-tihon restored the codegen_mutation branch August 9, 2019 17:59
@sergey-tihon sergey-tihon deleted the codegen_mutation branch August 9, 2019 17:59
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Feb 23, 2021
* raw code-gen Mutable tests copy-paste

* Allow  to use code snippets with warnings in tests

* Replace random/temp assembly name by `asmName` in generated IL

* map `System.Runtime` types to `mscorlib` for .NET Core tests

* allow to use IL from full framework and .net core as `expected IL`

* remove old tests

*  Different error messages for `not found` expected IL and not `not fully found` IL

* CompilerAssert.CompileLibraryAndVerifyILWithOptions and expected IL update

* Added `-g` option

* Reverted back unused variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants