buggins / dlangui

Cross Platform GUI for D programming language
Boost Software License 1.0
812 stars 120 forks source link

`dub test --coverage` does not work when importing dlangui in submodule #270

Open tom-tan opened 8 years ago

tom-tan commented 8 years ago

I reproduce it with dlangui 0.8.30 on Linux 64bit system.

Here is the commands to reproduce it. These commands initialize a new project with dlangui, make a submodule foo/bar, and add import dlangui; to foo/bar.d.

$ dub init example dlangui
$ cd example
$ mkdir source/foo
$ echo "module foo.bar; import dlangui;" > source/foo/bar.d
$ dub test --coverage

Expected: dub generates a binary and the test succesfully finishes.

Actual: It fails generating __test__library__. Here is the outputs:

$ dub test --coverage
Generating test runner configuration '__test__library__' for 'library' (library).
Performing "unittest-cov" build using dmd for x86_64.
derelict-util 2.0.6: target for configuration "library" is up to date.
derelict-ft 1.1.2: target for configuration "library" is up to date.
derelict-gl3 1.0.18: target for configuration "library" is up to date.
derelict-sdl2 2.0.0: target for configuration "library" is up to date.
dlangui 0.8.30: target for configuration "default" is up to date.
example ~master: building configuration "__test__library__"...
Linking...
../../.dub/packages/dlangui-0.8.30/dlangui/lib/libdlangui.a(sdlapp.o): In function `_D7dlangui9platforms3sdl6sdlapp7sdlmainFAAyaZi':
/home/tom-tan/repos/example/../../.dub/packages/dlangui-0.8.30/dlangui/src/dlangui/platforms/sdl/sdlapp.d:1781: undefined reference to `UIAppMain'
collect2: error: ld returned 1 exit status
--- errorlevel 1
dmd failed with exit code 1.

On windows systems, it seems to work.

buggins commented 8 years ago

will check it

tom-tan commented 8 years ago

I found a workaround for this issue.

When I add the following code into foo/bar.d, dub can generate __test_library__ and the test finishes correctly.

version(D_Coverage)
{
    version(unittest)
    {
        extern(C) int UIAppMain(string[] args) {
            return 0;
        }
    }
}