Modify MLBs to build and test on polymlb as well#19
Conversation
| @@ -1,2 +1,3 @@ | |||
| pkg.mlb | |||
| smlpkg.sml | |||
| call-main.sml | |||
There was a problem hiding this comment.
There might be a problem with MLKit's recompilation system having problems with the same file (call-main.sml) being part of multiple mlb-files... A solution may be to have two files instead - call-main.sml and call-main-futpkg.sml...
There was a problem hiding this comment.
Yes, thank you for the suggestion. That was indeed the cleaner solution, implemented in 2978dc9.
I used polymlb's default MLB annotation parameter to ignore both call-main's, so the compilation process uses the same .mlb files with all compilers.
| ../test/preamble.sml | ||
| test.sml | ||
| test_system.sml | ||
| ../test/postamble.sml |
There was a problem hiding this comment.
Wouldn't it be nicer to have a test.mlb file that features the test functionality, which may then be called from the individual test files? Would that work with PolyML - again, MLKit doesn't work well with sml-files being part of multiple mlb-files (mlb-files can mention other mlb-files, of course)...
There was a problem hiding this comment.
Again, thank you for the push on this. I was able to clean up the tests even further witout having to resort to multiple mlb files. What I did was:
- Create a TestSuite functor that keeps a local ref of test error count per instantiation.
- Load this functor definition via testSuite.mlb in each test.mlb
- Inside the tests themselves, instantiate and open the functor. This way the test bodies did not have to be refactored in any way
- Call
reportAndExit(from the opened TestSuite struct) at the end of the test file. - Have polymlb use
reportAndExitas themainentrypoint, so we don't have to resort to call-main workarouds. - I also extracted all the duplicated Makefile machinery to
test.mk, and included it where appropriate.
There was a problem hiding this comment.
This still means that polymlb evaluates the test as it's being "compiled", but I think that's acceptable, since the tests value is in their being executed at some point during the run.
|
I think having |
|
On a complete sidenote, It errors out with the message: Mlton and polymlb support this syntax as expected. In any case, I just export the full |
|
@athas this whole effort is simply scratching a personal itch. I really only use PolyML for my personal programming, because of the rapid compilation and testing turnaround. As I was trying to debug an issue I had with symlinks inside smlpkg dependencies, (solved here), I was really disheartened with how long it took to recompile the So I went and got smlpkg compiling with polymlb and was able to really tighten the feedback loop and figure things out quickly. I decided to put up the PR as a contribution to the project, in case others are interested in using poly to develop smlpkg. |
There are no plans for MLKit to support import filters... |
I've been compiling this project with my own hacky branch made to support
polymlb.This PR is a cleaned-up version of my hacky code, with the following changes:
smlpkg.mlb and futpkg.mlb now contain an extra
call-main.smlfile, which does theval _ = main ()trick to launch the main function when compiled with MLton/MLKit.when MLCOMP is
polymlb, the option to-ignore-call-mainis used, so the produced executable will use themainfunction as defined insmlpkg.smlandfutpkg.smlrespectively.Tests were modified more heavily. I noticed that test failures did not bubble up to the OS, and the only way to see that a test was failing was to look at the output.
I collected the duplicated code from the unit test files and made a test preamble and postamble. These are pre-pended and appended to the test suites, so any errors during evaluation get reported to the runner (After feedback, this is now implemented as amake).TestSuite()functor, opened in each test.sml suite. PolyMLB is instructed to usereportAndExitfrom the functor in lieu ofmain.The tests don't use the
call-maintrick, as I think it's overkill. In the case of tests, polymlb will just evaluate all the test cases as it "compiles" the executable, and if any tests fail, the "compilation" will abort, which signals an error code to make. If all the tests pass, the generated executable will always execute successfully, so it is in effect a witness to all the tests passing at comptime.The test logic remains unchanged.
Test suite behavior remains unchanged under mlton/mlkit, save for the changes in point
3), which cause test failures to exit the suite with a nonzero code.futpkgandsmlpkgnow compile in a separate mlb tempdir on mlkit, as code-sharingcall-mainwas erroring out the linker.There is now a PHONY
make test-all-supported-compilerstarget which runs all tests in sequence under mlton, mlkit, and polymlb.I'm open to fixes and suggestions, if you feel this work is not up to par.