Running unit tests from DUB single file packages

Johannes Loher johannes.loher at fg4f.de
Tue Dec 1 14:15:22 UTC 2020


Am 01.12.20 um 14:52 schrieb jmh530:
> On Tuesday, 1 December 2020 at 13:52:35 UTC, jmh530 wrote:
>> On Tuesday, 1 December 2020 at 11:40:38 UTC, Johannes Loher wrote:
>>> [snip]
>>>
>>> Any hints on how to execute unit tests from single file DUB packages?
>>> Is it even possible at the moment? Thanks in advance for any help!
>>>
>>>
>>> [1] https://adventofcode.com/
>>
>> Have you tried it without the imports?
> 
> Or rather, without the dependency.

The point of using DUB (and the single file package format) is easy
access to libraries from the DUB registry. If I didn't want to use a
dependency, I would not be using DUB at all. That said, leaving out the
dependency does not solve the issue, it also occurs with the following
source file:

```
#!/usr/bin/env dub
/+ dub.sdl:
    name "main"
+/

void main() {}

unittest {
    assert(true);
}
```

```
johannesloher at saiph:~> dub test --single main.d

Package main (configuration "application") defines no import paths, use
{"importPaths": [...]} or the default package directory structure to fix
this.

Generating test runner configuration 'main-test-application' for
'application' (executable).

Source file '/home/johannesloher/main.d' not found in any import path.
```


More information about the Digitalmars-d-learn mailing list