Bug 16995 – __traits(getUnittests) doesn't work with separate compilation

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-12-20T18:04:34Z
Last change time
2018-02-01T23:17:01Z
Assigned to
No Owner
Creator
Atila Neves

Comments

Comment #0 by atila.neves — 2016-12-20T18:04:34Z
foo.d: ----- void main() { import bar; foreach(ut; __traits(getUnitTests, bar)) ut(); } ----- bar.d: ----- unittest { assert(1 == 2); } ----- # compile all at once dmd -unittest foo.d bar.d # fine # compile separately dmd -c -unittest foo.d dmd -c -unittest bar.d dmd foo.o bar.o foo.o:foo.d:function _Dmain: error: undefined reference to '_D3bar16__unittestL2_531FZv' collect2: error: ld returned 1 exit status --- errorlevel 1 objdump shows me that bar.o has a '_D3bar14__unittestL2_1FZv' symbol, which is nearly, but not quite, what foo.o is trying to call.
Comment #1 by bugzilla — 2017-09-29T21:56:09Z
Comment #2 by github-bugzilla — 2017-09-30T20:33:53Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/f527810984133fb379f99c4b12a357257a53eefb Fix Issue 16995 - __traits(getUnittests) doesn't work with separate compilation https://github.com/dlang/dmd/commit/ebd6606840afea0034ce599815ed950fd558981c Merge pull request #6727 from atilaneves/fix_get_unittests_bug Fix issue 16995 - __traits(getUnitTests) works with separate compilation
Comment #3 by github-bugzilla — 2018-02-01T23:17:01Z
Commit pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/7c2ce0c5677066b97d87cd9654a8872f84636648 Use extendedModuleUnitTester in issue16995 test