-
Notifications
You must be signed in to change notification settings - Fork 789
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
Migrate Cambridge test suite (tests/fsharp) runner to NUnit #90
Conversation
How does this relate to #15? |
Impressive. I'd dearly love to get rid of all the .bat rubbish (originally my fault!!!) and replace it by F# scripting and NUnit. Somewhat ortogonally, I've often wondered I do wonder if large parts of the fsharp/... test suite that is "single-test-and-run" could simply be moved into FSharp.Core.Unittests.dll. Much of it is just testing functional correctness of the F# core library and F# core language constructs. We reused much of the suite to somewhat randomly test things like localization and signature file generation, and always drove it through the "fsc.exe" tool. |
@forki is orthogonal because
if your pr is merged before that one, i'll add the task for run it instead of modify the only problem i see, is we both replaced |
@enricosada very cool. we should now try to keep both PRs compatile. 👍 |
@dsyme Absolutely, there are lot of possible cleanup after the rewrite, with type safety now 💃 and easier to spot 👀 example 1: 'core/access'module Access =
let permutations =
FSharpTestSuite.allPermutation
|> List.map (fun p -> (new TestCaseData (p)).SetCategory(sprintf "%A" p) |> setTestDataInfo "access")
[<Test; TestCaseSource("permutations")>]
let access p = check (processor {
let { Directory = dir; Config = cfg } = testContext ()
do! SingleTestBuild.singleTestBuild cfg dir p
do! SingleTestRun.singleTestRun cfg dir p
}) This use only single-build -> single-run easy to spot
⭐ a good candidate to move to unit tests. example 2:
|
Seeing all those test variations is very cool. It shows that with this PR we could know more easily all the variations and tests that we're actually running :) |
I haven't taken a careful look, but it's awesome to see some stuff getting bootstrapped here. I do have some (rather, very many) thoughts on how to effectively re-architect the tests, will try to distill those and share sometime over the next few days. Independent of this particular PR, @KevinRansom and I are trying to figure out the best way to handle these "WIP" kinds of PRs, which are very valuable, but will likely required extended iteration and design changes. Managing these on a separate fork might be the best approach. |
//if NOT "%FSC:NOTAVAIL=X%" == "%FSC%" ( | ||
// goto Skip | ||
//) | ||
ignore "alredy checked fsc/fsi exists" |
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.
"already"
@enricosada This is great work, and is exactly what I had in mind in our earlier CodePlex discussion about implementing a new test runner. A few ideas/comments/suggestions:
@latkin Can you share your thoughts on re-architecting the tests? |
I'll push all tests on this branch today (+ lot of cleanup ). Thx @jack-pappas, i got the idea from your post on codeplex Last todo is to use a state monad to manage current directory+env vars, but i think is ok like this, a bit verbose but work ok ( i need an update monad for current directory and env var -> awesome ) About About xplat: [<Test; TestCaseSource("testData")>]
let hiding () = check (processor {
let { Directory = dir; Config = cfg } = testContext ()
let exec p = Command.exec dir cfg.EnvironmentVariables { Output = Inherit; Input = None; } p >> checkResult
let fsc = Printf.ksprintf (Commands.fsc exec cfg.FSC)
let peverify = Commands.peverify exec cfg.PEVERIFY
let fsc_flags = cfg.fsc_flags
// "%FSC%" %fsc_flags% -a --optimize -o:lib.dll lib.mli lib.ml libv.ml
do! fsc "%s -a --optimize -o:lib.dll" fsc_flags ["lib.mli";"lib.ml";"libv.ml"]
// "%PEVERIFY%" lib.dll
do! peverify "lib.dll"
// "%FSC%" %fsc_flags% -a --optimize -r:lib.dll -o:lib2.dll lib2.mli lib2.ml lib3.ml
do! fsc "%s -a --optimize -r:lib.dll -o:lib2.dll" fsc_flags ["lib2.mli";"lib2.ml";"lib3.ml"]
// "%PEVERIFY%" lib2.dll
do! peverify "lib2.dll"
// "%FSC%" %fsc_flags% --optimize -r:lib.dll -r:lib2.dll -o:client.exe client.ml
do! fsc "%s --optimize -r:lib.dll -r:lib2.dll -o:client.exe" fsc_flags ["client.ml"]
// "%PEVERIFY%" client.exe
do! peverify "client.exe"
}) we can run same test on mono (minus ngen) for paths i fixed all directory separator (using alwasy Path.Combine) like do! exec ("."/"test--optimize.exe") "" or do! exec (".."/"ConsoleApplication1"/"bin"/"Debug"/"Profile259"/"PortableTestEntry.exe") "" |
9e40d8a
to
7df7694
Compare
ok, pretty much done 😄 , all tests migrated. Skipped teststhese are ok, not run because rules like:
see test output message, about reason Failed testsI fixed test where possible ( see
i need some info:
run testsYou should try in visual studio, using visual studio test runner (nunit adapter required) Now test fixture read file For other filters options see previous post I tagged failing test on my machine with category:
you can easy filter them with notesWhole test suite is 3h on my machine (all permutations). Some test are useless ( see previous post ), we can cleanup unused permutations. About code formatting style, there is a style guide for this repo? spaces, etc. |
or @KevinRansom too, sry I forgot to ask you too (is a good idea to create a github group? @fsharp/visualfsharp or @Microsoft/visualfsharp )? I want to start with fsharpqa if this is ok (or need improvement but is ok as a way to migrate) |
Enrico, |
I waited for some reviews, but this pr is done, i removed the [WIP] open points: crossplatformThe test runner is ok. use new runner instead of old onechange nunit compatibility@latkin said let me know, i'll rebase soon to remove build failure (does not depend on this pr) |
@enricosada Can this new runner live alongside the old one (i.e., the @latkin @KevinRansom Is there any reason not to merge this in now? |
sure, this code add only code, doesnt change the current test suite as @jack-pappas said we can remove the old code later (hopefully soon ) . About ms internal build server, the build script download the nunit test runner, so is easier to run the suite from the current bat file If needed i can modify the bat runner to use nunit if a environment variable if set (like |
@enricosada, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
i need to change nunit -> xnunit? /cc @latkin @KevinRansom |
You don't need to change nunit to xunit. Although we may well change the repo over to repo at some point in the future. The way to think about it is this:
To cut a short story long, we may or may not do the things we have as issues, doing so depends on many things, not least of which is that more than one person buy of on a goal. I hope that clears things up somewhat. |
ok @KevinRansom but what are current goals? excluded bugfixs for fsharp4. |
This PR is really nice work, and a good starting point for any future contributions aimed at refactoring the tests. Unfortunately, it has been around for quite some time and will not realistically be merged, so I am finally closing it out. Overall, my take on it is that this PR is essentially just translating the current The deeper issues I see with the current system (and what a full refactoring should accomplish) include
This is obviously a lot of stuff and won't be accomplished in one fell swoop. As with any bigger contribution, we recommend that it be planned out/discussed a bit ahead of time and worked on piece by piece in a fork. |
@latkin sry for late response, It's not a problem if this pr is not accepted (i understand your reasons), but let me address some of your points, maybe i can change your decision. this pr:
I understand there is a quality bar and you waste time on review/merge, but there is an improvement here ready to be applied, and it can open to new cleanup/improvements. I think is a good addition, not the whole solution to test suite, this is the the initial cleanup and a move forward. That's an area with really little love, i dont expect that to change soon. i dont like long pr, easier merge a working base in
all that can be added, but is easier after the merge, or i can continue this pr until done, np. This pr doesn't change the tests (tests are also inside fsharp/fsharp), that's the premise of this work, i want to change the test runner. Also:
the others points:
|
@jack-pappas thx for help about that pr ( tweet, review etc ), really thx @7sharp9 status is: waiting for @KevinRansom review. The code is there (ported to NUnit 3), if we add that to master (yes master branch, not coreclr) it's only adding a new code, so it doesn't broke anything, it'is not enabled by default, can be run parallel to existing testsuite. Later we can merge in coreclr. I'd like to fix xplat ( fix exe name mostly ) but i need to have that merged before, is really a long effort (already rejected once). After that is fsharpqa suite (perl -> fs), easier that this one, because i can reuse the code. |
👍 I like that plan. Getting that done would really help the xplat and coreclr efforts. |
@@ -0,0 +1,186 @@ | |||
|
|||
module UpdateCmd |
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.
Please add a comment about what this file is for.
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.
it's the 1-1 conversion from src/update.cmd
.
Yuo are right, i'll add a comment with the original .bat file path in all converted .fs files, it's easier to understand.
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.
I think what I meant was "please take the time to record what this stuff is actually doing" :). I know the original cmd files weren't documented (and of course they should have been) - but now you're going through all this with such a fine toothcomb, it's a great opportunity to add a few basic comments recording what you've learned.
@dsyme during the review pls take in consideration i added lots of helper functions, but that's because i tried to write .bat -> .fs conversion as simple as possible to review ( usually 1-1 ) . |
// call ..\..\single-neg-test.bat neg40 | ||
// call ..\..\single-neg-test.bat neg41 | ||
// call ..\..\single-neg-test.bat neg42 | ||
do! processor.For (["neg87"; "neg86"; "neg85"; "neg84"; "neg83"; "neg82"; "neg81"; "neg80"; "neg79"; "neg78"; "neg77"; "neg76"; "neg75"; "neg74"; "neg73"; "neg72"; "neg71"; "neg70"; "neg69"; "neg68"; "neg67"; "neg66"; "neg65"; "neg64"; "neg61"; "neg63"; "neg62"; "neg20"; "neg24"; "neg32"; "neg37"; "neg37_a"; "neg60"; "neg59"; "neg58"; "neg57"; "neg56"; "neg56_a"; "neg56_b"; "neg55"; "neg54"; "neg53"; "neg52"; "neg51"; "neg50"; "neg49"; "neg48"; "neg47"; "neg46"; "neg10"; "neg10_a"; "neg45"; "neg44"; "neg43"; "neg38"; "neg39"; "neg40"; "neg41"; "neg42"], singleNegTest) |
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.
Why not use a for loop if processor
supports processor.For
?
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.
because my implementation doesn't work if i try to write as for loop.
Dont know why. That was something i wanted to ask for help
if you or someone else see the problem, can send me a pull request to this branch? i'll not rebase anymore this branch
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.
It's ok, we could fix it later.
This is absolutely amazing work - I can see it's been a huge effort. It's a huge step forward and puts us well down the path of modernizing the "fsharp" suite to something much more palatable (and eventually cross-platform). I personally would like to see all the *.bat files deleted as part of this change. (Somehow I don't think we should merge it if we don't delete the *.bat - either we are confident in this as the right direction - which I am - or not) |
Yes, you're right. You've done it exactly the right way. Some of the code comments are cosmetic and can be addressed later :) |
Hi, when I try to run the built tests using nunit I see this exception, any idea what I am doing wrong? Unhandled Exception: System.Exception: Failed to load the test engine ---> System.InvalidCastException: Unable to cast object Kevin |
@@ -3,4 +3,6 @@ | |||
<package id="NUnit" version="2.6.4" targetFramework="net40" /> | |||
<package id="NUnit.Runners" version="2.6.4" /> | |||
<package id="FsCheck" version="2.0.3" /> | |||
<package id="NUnit" version="3.0.0-beta-3" targetFramework="net45" /> |
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.
do we really want two different versions of NUnit? How about removing the old one?
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.
the old nunit is used in unit tests projects.
These proj are going to be converted to xunit instead of upgrade to nunit 3 in coreclr branch ( see #699 ) temporary or not.
Now nunit 3 final is release, so maybe is easier to upgrade the suite to nunit 3 final in all projects (usefull for coreclr too), but that's another pr
@KevinRansom the nunit console and assembly is beta3? |
Okay ... I will pull this as it stands, can you take care of the nunit upgrade? |
Pulled to master and vs2015 |
@KevinRansom GREAT! |
w00t! |
This is a spike to explore replacing current .bat based test runner with NUnit, for Cambridge suite (
tests/fsharp
).There is a discussion on codeplex about the Redmond suite (
tests/fsharpqa
), the idea is the same, Cambridge is easier to port before attempt Redmond suiteCurrent .bat based runner has some problems:
New runner
tests\fsharp\FSharp.Tests.fsproj
FSharp-Tests-Core.Access
insidetests/fsharp/core/_test.fs
single-test-build.bat
->single-test-build.fs
), easier to convert and diffThis pr when complete
#Records
intests\fsharp\core\access\test.fsx
)tests\RunTests.cmd
I need some feedback
tests\config.fs
ref/mutable messtests/fsharp/nunitConf.fs:114
)match Ok -> | ErrorLevel ->
to computation expressionworkflow
implement new runner without changing tests
put old .bat code inside test for easier diff, line by line
run side by side with old runner
modify .bat suite runner (
fsharp\tests\RunTests.cmd
) to use nunit test runner for Cambridge suite onlyremove .bat files of test runner
Future work (not this pr, but easier to implement after)
dont.use.empty.signature
file) with code or NUnit categories#Records
) with NUnit categoriestest.ok
,build.ok
) with exit code only or function resultNotes
VS Test Runner
To filter test inside visual studio test runner:
Project:FSharp.Tests
to show only Cambrige suiteTrait:FSI_FILE
to filter only FSI_FILE category (seeFSharpTestSuiteTypes.Permutation
union )Trait:access
to filter 'core/access'-Trait:FSC_HW
to excludeFSC_HW
testsex:
Project:FSharp.Tests Trait:FSC -Trait:FSC_HW
run all tests with FSC tag but not FSC_HW[TEST CHANGED]
I added changed test in separate commits with prefix [TEST CHANGED] because found bug/problems.
These can be evaluated before this pr, and easier to review/cherry-pick