www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18111] New: unittests get different names depending on how

https://issues.dlang.org/show_bug.cgi?id=18111

          Issue ID: 18111
           Summary: unittests get different names depending on how the
                    files are passed to dmd
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: atila.neves gmail.com

/tmp/foo.d:
void _() {
    import dir1.dir2.bar;
    pragma(msg, __traits(getUnitTests, dir1.dir2.bar));
}

/tmp/dir1/dir2/bar.d:
module dir1.dir2.bar;
unittest { }
void _() { pragma(msg, __traits(getUnitTests, dir1.dir2.bar)); }

When compiling foo.d:
/tmp % dmd -c -unittest foo.d                                                   
tuple(__unittest_dir1_dir2_bar_d_2_0)

When compiling bar.d:
/tmp % dmd -c -unittest /tmp/dir1/dir2/bar.d                                    
tuple(__unittest__tmp_dir1_dir2_bar_d_2_0)

The symbol names don't match and a linker error ensues. This prevents
__traits(getUnittests) from being used in certain separate compilation
scenarios.

--
Dec 21 2017