dlang-tour / core

D Language online tour (https://tour.dlang.org/) and online editor (https://run.dlang.io/)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UTs Not Running with Dependencies

jmh530 opened this issue · comments

The unittests for run.dlang.org do not seem to be running when there are dependencies.

I have no issue running the following code with flags -unittest -main and getting the expected result

import std.stdio : writeln;

unittest {
    writeln("here");
}

However, if I add in a library

/+dub.sdl:
dependency "mir-algorithm" version="~>3.4.19"
+/
import std.stdio : writeln;

unittest {
    writeln("here");
}

then I get the following error

/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o:function _start: error: undefined reference to 'main'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
dmd failed with exit code 1.

Note that I tried this with multiple dependency options. I figured at this point that main is not being generated for some reason, so I remove the -main flag and add in my own main function (so now just running with the -unittest flag)

/+dub.sdl:
dependency "mir-algorithm" version="~>3.4.19"
+/
import std.stdio : writeln;

unittest {
    writeln("here");
}

void main() { }

And now it does not print anything. If I remove the dub.sdl line at the top and the dependency, then it prints the expected result.

Just ran into this bug again.

/+dub.sdl:
dependency "automem" version="~>0.6.2"
+/

unittest {
    assert(0);
}

void main() { }

Closed in favor of 748