www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to unit-test a phobos module?

reply Q. Schroll <qs.il.paperinik gmail.com> writes:
When trying to unit-test an unchanged phobos module from 
phobos/master, I get errors such as

     module core.lifetime import copyEmplace not found

and template instantiation errors. What is the correct arguments 
to pass to (r)dmd? I know it worked for me some years ago, but 
somehow, it doesn't work now.

I've looked at [1], [2], [3] which didn't work (maybe outdated?). 
How do you do it and what am I doing wrong?

My setup:
* A fresh DMD installed a few minutes ago.
* Clone of my Phobos fork with up-to-date changes from 
dlang/phobos/master.

In the clone's folder, ~/dlang/phobos, I tried the following 
commands:

     $ dmd -main -unittest -version=StdUnittest -I. -run 
std/<module>.d

and

     $ rdmd -main -unittest -version=StdUnittest -I. std/<module>.d

I have the feeling I'm missing something quite obvious.

[1] 
https://wiki.dlang.org/Contributing_to_Phobos#Test_a_single_Phobos_module
[2] 
https://wiki.dlang.org/Building_under_Windows#Building_Phobos_2
[3] https://github.com/dlang/phobos/blob/master/CONTRIBUTING.md
Nov 25 2020
next sibling parent reply Paul Backus <snarwin gmail.com> writes:
On Wednesday, 25 November 2020 at 20:58:20 UTC, Q. Schroll wrote:
 My setup:
 * A fresh DMD installed a few minutes ago.
 * Clone of my Phobos fork with up-to-date changes from 
 dlang/phobos/master.
Do you have clones of dmd and druntime too? If not, try following these instructions: https://wiki.dlang.org/Starting_as_a_Contributor#Typical_Contributor_Workflow
Nov 25 2020
parent reply Q. Schroll <qs.il.paperinik gmail.com> writes:
On Wednesday, 25 November 2020 at 21:11:24 UTC, Paul Backus wrote:
 On Wednesday, 25 November 2020 at 20:58:20 UTC, Q. Schroll 
 wrote:
 My setup:
 * A fresh DMD installed a few minutes ago.
 * Clone of my Phobos fork with up-to-date changes from 
 dlang/phobos/master.
Do you have clones of dmd and druntime too?
Why would I need those? I haven't needed them back then.
Nov 25 2020
parent reply Paul Backus <snarwin gmail.com> writes:
On Wednesday, 25 November 2020 at 21:16:06 UTC, Q. Schroll wrote:
 On Wednesday, 25 November 2020 at 21:11:24 UTC, Paul Backus 
 wrote:
 On Wednesday, 25 November 2020 at 20:58:20 UTC, Q. Schroll 
 wrote:
 My setup:
 * A fresh DMD installed a few minutes ago.
 * Clone of my Phobos fork with up-to-date changes from 
 dlang/phobos/master.
Do you have clones of dmd and druntime too?
Why would I need those? I haven't needed them back then.
copyEmplace isn't in druntime 2.094.2.
Nov 25 2020
parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Wed, Nov 25, 2020 at 09:49:12PM +0000, Paul Backus via Digitalmars-d-learn
wrote:
 On Wednesday, 25 November 2020 at 21:16:06 UTC, Q. Schroll wrote:
 On Wednesday, 25 November 2020 at 21:11:24 UTC, Paul Backus wrote:
 On Wednesday, 25 November 2020 at 20:58:20 UTC, Q. Schroll wrote:
 My setup:
 * A fresh DMD installed a few minutes ago.
 * Clone of my Phobos fork with up-to-date changes from
 dlang/phobos/master.
Do you have clones of dmd and druntime too?
Why would I need those? I haven't needed them back then.
copyEmplace isn't in druntime 2.094.2.
My guess is that the problem is caused by trying to compile Phobos with a compiler that uses an incompatible version of druntime. T -- Insanity is doing the same thing over and over again and expecting different results.
Nov 25 2020
parent reply Q. Schroll <qs.il.paperinik gmail.com> writes:
On Wednesday, 25 November 2020 at 21:57:12 UTC, H. S. Teoh wrote:
 On Wed, Nov 25, 2020 at 09:49:12PM +0000, Paul Backus via 
 Digitalmars-d-learn wrote:
 On Wednesday, 25 November 2020 at 21:16:06 UTC, Q. Schroll 
 wrote:
 On Wednesday, 25 November 2020 at 21:11:24 UTC, Paul Backus 
 wrote:
 On Wednesday, 25 November 2020 at 20:58:20 UTC, Q. Schroll 
 wrote:
 My setup:
 * A fresh DMD installed a few minutes ago.
 * Clone of my Phobos fork with up-to-date changes from
 dlang/phobos/master.
Do you have clones of dmd and druntime too?
Why would I need those? I haven't needed them back then.
copyEmplace isn't in druntime 2.094.2.
My guess is that the problem is caused by trying to compile Phobos with a compiler that uses an incompatible version of druntime.
One of the issues is, I don't know what DRuntime really is. As far as I understand on the surface-level, it's functionality one would expect to be implemented by the compiler, but actually implemented in plain D code. A low-level Phobos if you want. So I'm a little confused why there's even a need for it to be "built". Isn't it "just code" like Phobos? I'm increasingly frustrated because, honestly, it seems I don't know enough about the build processes or build tools used. The Wiki expects Digital Mars make to be there, also says explicitly not to confuse it with GNU make, but in my DMD folder there is none. Since it's a plain install, I suspect the Wiki is outdated. How am I expected to figure things out? It seems like everyone else knows how to do it, just I'm too stupid.
 *ME* Why would I need those? I haven't needed them back then.
I wrote that not saying "do the work for me, guys" but "please tell me what changed".
Nov 25 2020
next sibling parent Paul Backus <snarwin gmail.com> writes:
On Thursday, 26 November 2020 at 00:17:26 UTC, Q. Schroll wrote:
 One of the issues is, I don't know what DRuntime really is. As 
 far as I understand on the surface-level, it's functionality 
 one would expect to be implemented by the compiler, but 
 actually implemented in plain D code. A low-level Phobos if you 
 want. So I'm a little confused why there's even a need for it 
 to be "built". Isn't it "just code" like Phobos?
Phobos depends on DRuntime, and both Phobos and DRuntime depend on the D compiler. When you download version 2.094.2 of the compiler (the latest release), it comes with the corresponding versions of Phobos and DRuntime, and is configured to automatically include them in its import paths. If you want to compile the development version of Phobos, you will generally need the development versions of DRuntime and DMD as well, because of the dependency relationships between them. If you try to compile the development version of Phobos using the latest released versions of DMD and DRuntime, you are liable to run into dependency issues like the one in your original post.
 *ME* Why would I need those? I haven't needed them back then.
I wrote that not saying "do the work for me, guys" but "please tell me what changed".
I have no idea what changed for *your* setup, because (a) I develop on Linux, not Windows, and (b) I've only been involved in D development since 2018. Personally, I followed the instructions on the "Starting as a Contributor" and "Contributing to Phobos" pages, and they worked for me.
Nov 25 2020
prev sibling parent Steven Schveighoffer <schveiguy gmail.com> writes:
On 11/25/20 7:17 PM, Q. Schroll wrote:
 On Wednesday, 25 November 2020 at 21:57:12 UTC, H. S. Teoh wrote:
 On Wed, Nov 25, 2020 at 09:49:12PM +0000, Paul Backus via 
 Digitalmars-d-learn wrote:
 On Wednesday, 25 November 2020 at 21:16:06 UTC, Q. Schroll wrote:
 On Wednesday, 25 November 2020 at 21:11:24 UTC, Paul Backus > wrote:
 On Wednesday, 25 November 2020 at 20:58:20 UTC, Q. Schroll > > 
wrote:
 My setup:
 * A fresh DMD installed a few minutes ago.
 * Clone of my Phobos fork with up-to-date changes from
 dlang/phobos/master.
 Do you have clones of dmd and druntime too?
Why would I need those? I haven't needed them back then.
copyEmplace isn't in druntime 2.094.2.
My guess is that the problem is caused by trying to compile Phobos with a compiler that uses an incompatible version of druntime.
One of the issues is, I don't know what DRuntime really is. As far as I understand on the surface-level, it's functionality one would expect to be implemented by the compiler, but actually implemented in plain D code. A low-level Phobos if you want. So I'm a little confused why there's even a need for it to be "built". Isn't it "just code" like Phobos?
Druntime is in many respects the library portion of the language. It's the glue that allows some language pieces to work (e.g. Object, associative arrays, TypeInfo, etc.). There are also pieces that are purely independent of the compiler. But it used to be that just Phobos existed, and no Druntime. Druntime is actually the runtime portion of Tango, factored out so that both Phobos and Tango could use the same underlying runtime. It used to be, if you wanted to use a Tango-based library, you couldn't use a Phobos-based one as well. At this point, it's a nice separation of the Language features that must be library implemented from the user library (Phobos).
 
 I'm increasingly frustrated because, honestly, it seems I don't know 
 enough about the build processes or build tools used. The Wiki expects 
 Digital Mars make to be there, also says explicitly not to confuse it 
 with GNU make, but in my DMD folder there is none. Since it's a plain 
 install, I suspect the Wiki is outdated. How am I expected to figure 
 things out? It seems like everyone else knows how to do it, just I'm too 
 stupid.
Like any projects that are built over decades, Phobos and Druntime have accumulated esoteric build systems, and things you just "have to know". I honestly can't help you with your troubles, because I only ever use Windows when I have to. But I'm sure there are ways to get done what you want to get done. This might involve wrestling with the build system, or figuring out the correct command line based on the build system. -Steve
Nov 26 2020
prev sibling parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 11/25/20 3:58 PM, Q. Schroll wrote:
 When trying to unit-test an unchanged phobos module from phobos/master, 
 I get errors such as
 
      module core.lifetime import copyEmplace not found
 
 and template instantiation errors. What is the correct arguments to pass 
 to (r)dmd? I know it worked for me some years ago, but somehow, it 
 doesn't work now.
 
 I've looked at [1], [2], [3] which didn't work (maybe outdated?). How do 
 you do it and what am I doing wrong?
 
 My setup:
 * A fresh DMD installed a few minutes ago.
 * Clone of my Phobos fork with up-to-date changes from dlang/phobos/master.
 
 In the clone's folder, ~/dlang/phobos, I tried the following commands:
 
      $ dmd -main -unittest -version=StdUnittest -I. -run std/<module>.d
 
 and
 
      $ rdmd -main -unittest -version=StdUnittest -I. std/<module>.d
 
 I have the feeling I'm missing something quite obvious.
 
 [1] 
 https://wiki.dlang.org/Contributing_to_Phobos#Test_a_single_Phobos_module
 [2] https://wiki.dlang.org/Building_under_Windows#Building_Phobos_2
 [3] https://github.com/dlang/phobos/blob/master/CONTRIBUTING.md
I typically do: make -f posix.mak std/<module>.test -Steve
Nov 25 2020
parent reply Q. Schroll <qs.il.paperinik gmail.com> writes:
On Wednesday, 25 November 2020 at 21:16:15 UTC, Steven 
Schveighoffer wrote:
 I typically do:

 make -f posix.mak std/<module>.test

 -Steve
For some reason, [1] says `make.exe` would be installed by the DMD installer, but I found none. It explicitly says not to use GNU make. (I'm on Windows.) [1] https://wiki.dlang.org/Building_under_Windows
Nov 25 2020
next sibling parent Max Haughton <maxhaton gmail.com> writes:
On Wednesday, 25 November 2020 at 21:36:36 UTC, Q. Schroll wrote:
 On Wednesday, 25 November 2020 at 21:16:15 UTC, Steven 
 Schveighoffer wrote:
 I typically do:

 make -f posix.mak std/<module>.test

 -Steve
For some reason, [1] says `make.exe` would be installed by the DMD installer, but I found none. It explicitly says not to use GNU make. (I'm on Windows.) [1] https://wiki.dlang.org/Building_under_Windows
The digital mars make is actually distributed with the c compiler. Developing on Windows is such a complete pain e.g. setting it up so it can find the linker and cl. For that reason I currently just do all dmd/phobos/druntime hacking inside WSL because that way I can just press build (dmd has build.d which is cross-platform but druntime and phobos both aren't fun to build on windows unless you've done it recently)
Nov 25 2020
prev sibling parent reply Mike Parker <aldacron gmail.com> writes:
On Wednesday, 25 November 2020 at 21:36:36 UTC, Q. Schroll wrote:

 [1] https://wiki.dlang.org/Building_under_Windows
You might try Digger. That will hide all the tedious bits. https://code.dlang.org/packages/digger
Nov 25 2020
parent reply Q. Schroll <qs.il.paperinik gmail.com> writes:
On Thursday, 26 November 2020 at 05:29:16 UTC, Mike Parker wrote:
 On Wednesday, 25 November 2020 at 21:36:36 UTC, Q. Schroll 
 wrote:

 [1] https://wiki.dlang.org/Building_under_Windows
You might try Digger. That will hide all the tedious bits. https://code.dlang.org/packages/digger
I think using digger in principle works and I assume the problems I got aren't Digger's fault, but ae's. Building DMD + DRuntime failed. In my working folder (created by DUB running Digger), there's DMD.exe, but trying compiling anything results in "Error: cannot find source code for runtime library file 'object.d'" I did nothing but follow the instructions on code.dlang.org/packages/digger : dub fetch digger dub run digger -- build I tried building the current version v2.94.2 and tried --model=64, nothing helped. The error I'm presented is when
    work\build\bin\dmd.exe -lib -ofphobos64.lib -Xfphobos.json 
 -conf= -m64 [..1]
        -I../druntime\import std\stdio.d [..2]
is executed. [..1] IMO unrelated options [..2] following many more std modules, probably all that there are (haven't checked) The error message is:
 std\stdio.d(16): Error: module stddef is in file 
 'core\stdc\stddef.d' which cannot be read
I have no idea why the import failed. The stdc subfolder isn't in the core folder, but that core folder isn't even in a druntime/import folder anyway. Something's going horribly wrong. It seems something beyond us just doesn't want me to get D stuff done. :( Tomorrow, I'll try setting up a dual boot and give it a shot there. (Not the dub experience but following https://wiki.dlang.org/Building_under_Posix) Thank you all for your answers.
Nov 26 2020
next sibling parent Vladimir Panteleev <thecybershadow.lists gmail.com> writes:
On Friday, 27 November 2020 at 04:08:33 UTC, Q. Schroll wrote:
 I think using digger in principle works and I assume the 
 problems I got aren't Digger's fault, but ae's. Building DMD + 
 DRuntime failed.
Sorry about this. It was caused by a breaking change in Druntime's build script: https://github.com/dlang/druntime/pull/3026 I pushed a new version of Digger which includes a fix.
Nov 27 2020
prev sibling parent aberba <karabutaworld gmail.com> writes:
On Friday, 27 November 2020 at 04:08:33 UTC, Q. Schroll wrote:
 On Thursday, 26 November 2020 at 05:29:16 UTC, Mike Parker 
 wrote:
 Tomorrow, I'll try setting up a dual boot and give it a shot 
 there. (Not the dub experience  but following 
 https://wiki.dlang.org/Building_under_Posix)
Have you heard about WSL...WSL2? You don't need dual boot anymore. Read https://docs.microsoft.com/en-us/windows/wsl/about
Nov 27 2020