How can one reliably run unittests
jfondren
julian.fondren at gmail.com
Sun Sep 5 15:52:51 UTC 2021
On Sunday, 5 September 2021 at 15:04:58 UTC, H. S. Teoh wrote:
> On Fri, Sep 03, 2021 at 08:39:35AM +0000, deadalnix via
> Digitalmars-d wrote: [...]
>> > > 3/ it still isn't possible to run the unit tests of
>> > > several modules in one go by passing a list of modules to
>> > > the compiler (in the same way you can compile several
>> > > modules in one go and generate an object file for all of
>> > > them at once).
>> >
>> > Of course you can. Under my proposal:
>> >
>> > dmd -unittest=module -i -run mod1.d mod2.d mod3.d main.d
>> >
>>
>> No, this will run the code in mod1.d , passing ["mod2.d"
>> "mod3.d" "main.d"] as command line arguments.
>
> I really don't understand the logic of this: surely the
> compiler ought to be able to know which module main() is
> declared in, so why does it need the user to select one
> specific module to be run?
```
$ grep -H . mod?.d
mod1.d:void main(string[] args) {
mod1.d: import std.stdio : writeln;
mod1.d: writeln(args[1 .. $]);
mod1.d:}
$ dmd -run mod1.d mod2.d mod3.d
["mod2.d", "mod3.d"]
```
mod1.d is a program that prints its args that I'd like to run
with some arguments. mod2.d and mod3.d are not modules that even
exist; I just want them printed out like that. Distinguishing
between dmd and program arguments isn't a matter of compiler
smarts.
More information about the Digitalmars-d
mailing list