Unittest target doesn't seem to work
I wanted to learn D over the weekend and have run in to an issue using Mono-D 1.9.4 in combination with Xamarin studio 4.2.3 on Windows 7. Selecting the "Unittest" target in XS doesn't seem to do anything or just blurts out compile errors. Although running the command straight from the command-line does have the expected result. (the command as specified under "Tools -> Options -> Environment/D/Unittests")
When using the Unittest target the following is outputted in to the "Build Output":
Building: D-Console (Unittest)
Performing main compilation...
Current dictionary: C:\Users\Andre\Documents\D\Projects\D-Console\D-Console
C:\Program Files\D\2.065.0\dmd2\windows\bin\dmd.exe -unittest -debug -gc "main.d" "-IC:\Program Files\D\2.065.0\dmd2\src\druntime\import" "-IC:\Program Files\D\2.065.0\dmd2\src\phobos" "-odobj\Unittest" "-ofC:\Users\Andre\Documents\D\Projects\D-Console\D-Console\bin\Unittest\D-Console.exe"
OPTLINK (R) for Win32 Release 8.00.15
Copyright (C) Digital Mars 1989-2013 All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Warning 23: No Stack
obj\Unittest\D-Console.obj(D-Console)
Error 42: Symbol Undefined __d_unittestm
OPTLINK : Warning 134: No Start Address
--- errorlevel 1
Exit code 1
Build complete -- 1 error, 0 warnings
It seems that the settings for the Unittest target aren't used (the -main argument isn't provided). Fiddling around with the project build options for the Unittest target doesn't seem to make it any better either.
Including a dummy main method in the unittest block does make it build but when it is started the application doesn't do anything. Running the same binary (D-Console.pdb.exe) from the command line does output the expected result.
My test case; https://gist.github.com/AndreSteenveld/5a2cf1902f256c1b8b4a
It generally is difficult to determine whether a main method is provided by the user or whether it's done e.g. in some imported library (like vibe-d -- sounds weird, but just have a look at some example codes). Thus, there won't be a -main flag emitted by default.
You still could add it to the project configuration's extra compiler flag in the projects options.
- Or aren't these extra args included in the final build command line?
- There should be an assert exception thrown, right? In this case, try to execute run the program without a debugger. The exception handling within the debugger may be corrupted or so..I haven't tested it for a while.
- When adding additional arguments (using the project options -> Build/Compiling/"extra compiler options") they are just appended to the end of the line and don't seem to do anything.
- When running the executable from the command line the exception is thrown as expected. When I run it from XS (by hitting the "play" button left from the target selection drop-down) nothing happens. I couldn't find any option in the project options to disable the debugger for the Unittest target.
Also I would expect the Unittest target to use rdmd as the compiler and not dmd (as seen in the output). What does the "Unittest Command" do in Tools -> Options - "Environment/D/Unittests"?
https://github.com/aBothe/Mono-D/blob/master/MonoDevelop.DBinding/Unittest/UnittestSettings.cs#L33
Do you've got any dependency projects in your target unittest project? Because I had serious trouble getting a statically imported library to build properly..anyway it's using my '-main' flag written into the extra compiler arguments.
I got around the linking/building issue and posted a reply on my own question[1].
When I run the Unittest target now the application simply hangs. But when running the same executable from the command line it runs just fine. Relevant repo: https://github.com/AndreSteenveld/RDX