www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - how to use dub to run all / chosen dependency lib's unittests

reply mw <mingwu gmail.com> writes:
Hi,

I'm using dub.json to specify the dependencies libs for my 
project.

I'm just wondering how I can use dub to run all the tests of 
those dependencies libs (of the transitive closure of *all* the 
libs) to make sure my project is built on a very solid foundation?

I know this could be very time-consuming, probably will run it 
over-night.

On the other hand, what's the command to run dub test on a single 
dependency lib?


Thanks.
Sep 19 2022
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 9/19/22 7:48 PM, mw wrote:
 Hi,
 
 I'm using dub.json to specify the dependencies libs for my project.
 
 I'm just wondering how I can use dub to run all the tests of those 
 dependencies libs (of the transitive closure of *all* the libs) to make 
 sure my project is built on a very solid foundation?
 
 I know this could be very time-consuming, probably will run it over-night.
 
 On the other hand, what's the command to run dub test on a single 
 dependency lib?
 
 
 Thanks.
 
I don't see any specific command to do it in dub itself. I've recently discovered that `dub describe` gives you the directories of all your dependencies in a JSON format. I used this to write an install script for dependent library artifacts. See [here](https://github.com/schveiguy/raylib-d/blob/master/install/source/app.d). It would be pretty easy to do the same thing to run dependency unit tests. e.g. something like `foreach(dir; getDubDependencyDirectories) { cd(dir); execute("dub", "test"); }` You'd have to write getDubDependencyDirectories. But it's just parsing JSON. -Steve
Sep 19 2022
parent mw <mingwu gmail.com> writes:
On Monday, 19 September 2022 at 23:57:31 UTC, Steven 
Schveighoffer wrote:

 I don't see any specific command to do it in dub itself.

 I've recently discovered that `dub describe` gives you the 
 directories of all your dependencies in a JSON format.

 I used this to write an install script for dependent library 
 artifacts. See 
 [here](https://github.com/schveiguy/raylib-d/blob/master/install/source/app.d).

 It would be pretty easy to do the same thing to run dependency 
 unit tests. e.g. something like `foreach(dir; 
 getDubDependencyDirectories) { cd(dir); execute("dub", "test"); 
 }`

 You'd have to write getDubDependencyDirectories. But it's just 
 parsing JSON.
Thanks. Maybe Python is easier for such glue code. BTW, does any of the unit test library can do what I want? E.g. https://code.dlang.org/packages/unit-threaded
Sep 19 2022