unit test broken [DUB bug?]

Chris Katko ckatko at gmail.com
Sun Dec 12 05:54:44 UTC 2021


Running 64-bit Linux
```
dmd --version
DMD64 D Compiler v2.098.0-beta.2

dub --version
DUB version 1.27.0-beta.2, built on Sep  7 2021
```

the following code 'compiles' in one project.

```d
unittest
{
gasdindgaslkdgansklnasgdlknaglkgansklsdg;
}

void main(){} // compiles, links, and 'runs unit tests'
```

dub
[shows compiling, linking, then runs]

dub test

```
Running dfile-test-library
All unit tests have been run successfully.
```

Which made no sense whatsoever until I placed it into a second, 
different DUB project and catches it immediately using the same 
commands and test.

In a separate dub project I get the error message:

```
widescreen ~main: building configuration "application"...
source/app.d(4,1): Error: undefined identifier 
`gasdindgaslkdgansklnasgdlknaglkgansklsdg`
/usr/bin/dmd failed with exit code 1.
```


I'm not doing anything special with DUB and made both projects 
within a couple weeks of each other. I tried dub clean, dub, dub 
test. Still broken.



dub.json for broken project
```json
{
	"authors": [
		"chris"
	],
	"copyright": "Copyright © 2021, chris",
	"dependencies": {
		"crypto": "~>0.2.16"
	},
	"description": "A minimal D application.",
	"license": "proprietary",
	"name": "dfile"
}
```

dub.json for working project
```json
{
	"authors": [
		"chris"
	],
	"copyright": "Copyright © 2021, chris",
	"description": "A minimal D application.",
	"license": "proprietary",
	"name": "widescreen"
}
```

dub.json.selections (for broken project only)
```json
{
	"fileVersion": 1,
	"versions": {
		"crypto": "0.2.16",
		"intel-intrinsics": "1.6.1"
	}
}
```

Other than unit testing being broken, everything seems to work 
fine. I even deleted 99.9% of my code and left only the bad 
unittest code and a main, and it still compiles.


Could it be a bug where the previous unit test (at some point) 
was valid, and it's caching and still running that one? I have a 
/.dub/code/ d file I found:

```d
module dub_test_root;
import std.typetuple;
static import notes;
alias allModules = TypeTuple!(notes);

						import std.stdio;
						import core.runtime;

						void main() { writeln("All unit tests have been run 
successfully."); }
						shared static this() {
							version (Have_tested) {
								import tested;
								import core.runtime;
								import std.exception;
								Runtime.moduleUnitTester = () => true;
								enforce(runUnitTests!allModules(new 
ConsoleTestResultWriter), "Unit tests failed.");
							}
						}
```

Which doesn't appear in the "correct, not compiling" project 
directory which appears just empty. Possibly because it never 
successfully compiled a unit test suite.


More information about the Digitalmars-d-learn mailing list