nomad-software / dunit

Advanced unit testing toolkit for the D programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

any plans to continue supporting dunit?

SingingBush opened this issue · comments

for some time I've found dunit unusable. with my current dmd install (2.080.1) on Windows I can't run dub test with dunit in my project as it causes a linker error.

I think I need a bit more info. Is this a problem with dub or a problem with your linker? Also, what is the error message? Have you tried compiling it without dub?

seems to be a Windows problem. I basically generated a new project using dub then dumped the source from example.d into the project (also changed an assert to make a test fail) and ran dub test.

This works fine on my Fedora machine with dmd 2.079 + dub 1.8.0 and still works after updating to dmd 2.083 + dub 1.12.0 (although the output is nothing like what is shown in the readme):

$ dub test
Generating test runner configuration 'dunit-example-test-library' for 'library' (library).
Performing "unittest" build using /usr/bin/dmd for x86_64.
dunit 1.0.14: target for configuration "library" is up to date.
dunit-example ~master: building configuration "dunit-example-test-library"...
Linking...
To force a rebuild of up-to-date targets, run again with --force.
Running ./dunit-example-test-library 
dunit.error.DUnitAssertError@source/example.d(93): Failed asserting equal
----------------
/home/samael/.dub/packages/dunit-1.0.14/dunit/source/dunit/toolkit.d:394 pure @safe void dunit.toolkit.assertEqual!(ulong, int).assertEqual(ulong, int, immutable(char)[], immutable(char)[], ulong) [0x4780dd]
source/example.d:93 void people.__unittest_L64_C1() [0x456b76]
??:? void people.__modtest() [0x47e800]
??:? int core.runtime.runModuleUnitTests().__foreachbody2(object.ModuleInfo*) [0x499183]
??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)).__lambda2(immutable(object.ModuleInfo*)) [0x4811e6]
??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo*))).__foreachbody2(ref rt.sections_elf_shared.DSO) [0x488c71]
??:? int rt.sections_elf_shared.DSO.opApply(scope int delegate(ref rt.sections_elf_shared.DSO)) [0x488e04]
??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo*))) [0x488bfd]
??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)) [0x4811bd]
??:? runModuleUnitTests [0x498f59]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x483d80]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x483d07]
??:? _d_run_main [0x483c6f]
??:? main [0x4567e9]
??:? __libc_start_main [0x39415412]
1/1 unittests FAILED
Program exited with code 1

I'll try it on my Windows 10 machine in a bit and paste in the error.

ok, I've just done pretty much same on Windows (the problem I had before was that there was no main method in the project).

Still though the output of dub test is not as expected. Using the example code again and setting an assert with an invalid value I see the following output:

dub test --build=unittest                                                                                                                         
No source files found in configuration 'library'. Falling back to "dub -b unittest".                                                                
Performing "unittest" build using C:\D\dmd2\windows\bin\dmd.exe for x86.                                                                            
dunit 1.0.14: target for configuration "library" is up to date.                                                                                     
dunit_support ~master: building configuration "application"...                                                                                      
Linking...                                                                                                                                          
To force a rebuild of up-to-date targets, run again with --force.                                                                                   
Running .\dunit_support.exe                                                                                                                         
                                                                                                                                                    
dunit.error.DUnitAssertError@source\app.d(95): Failed asserting equal                                                                               
----------------                                                                                                                                    
0x00420D26 in pure @safe void dunit.toolkit.assertEqual!(ulong, int).assertEqual(ulong, int, immutable(char)[], immutable(char)[], uint) at C:\Users
\samael\AppData\Local\dub\packages\dunit-1.0.14\dunit\source\dunit\toolkit.d(394)                                                                   
0x004024D5 in void app.__unittest_L66_C1() at D:\geekery\projects\intellij-dlanguage-testing\dunit_support\source\app.d(96)
0x0042580C in void app.__modtest()
0x00435B9E in int core.runtime.runModuleUnitTests().__foreachbody1(object.ModuleInfo*)
0x0043965B in int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)).__lambda2(immutable(object.ModuleInfo*))
0x0042ED48 in _d_run_main
0x0042582C in main at D:\geekery\projects\intellij-dlanguage-testing\dunit_support\source\app.d(7)
0x00451EB9 in mainCRTStartup
0x771E8484 in BaseThreadInitThunk
0x77B9302C in RtlValidSecurityDescriptor                                                                                                            
0x77B92FFA in RtlValidSecurityDescriptor                                                                                                            
1/1 unittests FAILED
Program exited with code 1

this is Git Bash on windows btw.

Also, for context, I've been looking at this for Intellij D Language #431. For our use case we need output that can reliably be parsed by our plugin.

So you're saying that the issue here is that when an assert fails the output is not nicely formatted like the readme?

essentially yeah, not so much that it looks nice. More that it's consistent and useful.

eg; if running dub test had output something like stated in the readme:

+----------------------------------------------------------------------
| Failed asserting equal
+----------------------------------------------------------------------
| File: example.d
| Line: 91
+----------------------------------------------------------------------
| ✓ Expected value: (int) 1
| ✗ Actual value: (ulong) 2

we could hyperlink the user to line 91 in the source file.

The output from Unit Threaded in linked issue is fairly good. We can use it to display test names, total tests run with pass/fail ratio and time taken within the gui.

also d-unit in the way that it outputs the line in the source file AssertException@source\app.d(44) makes it fairly convenient for us to do something useful with it (actually just noticed output of dunit above had done similar DUnitAssertError@source\app.d(95)).

D has a fair few options for unit testing now. tbh I wish projects would work/merge together so that there could be 1 de facto library that is worth supporting. trying to guess which should be supported and then maintaining that support is too much overhead.