dmd/dub.sdl
Jacob Carlborg f80c3f3a85 Add unit test runner.
This will allow to use the compiler as a library to implement more
unit test like tests. These tests will be able to inspect the
internals of the compiler to perform new kinds of tests that are not
possible today.

Unit tests live in the `test/unit` directory. They are written using
the built-in `unittest` blocks. The unit test framework supports
callbacks executed before and after each test. The unit test runner
allows to limit the tests executed either by file(s) and/or by UDAs.
Example:

```d
module self_test;

import support : afterEach, beforeEach;

@beforeEach initializeFrontend()
{
    import dmd.frontend : initDMD;
    initDMD();
}

@afterEach deinitializeFrontend()
{
    import dmd.frontend : deinitializeDMD;
    deinitializeDMD();
}

@("self test")
unittest
{
    import std.algorithm : each;
    import dmd.frontend;

    findImportPaths.each!addImport;

    auto t = parseModule("test.d", q{
        int a = 3;
    });

    assert(!t.diagnostics.hasErrors);
    assert(!t.diagnostics.hasWarnings);
}
```

* To run all unit tests, run: `./run.d -u`
* To run only the unit tests in a single file, run: `./run.d -u unit/self_test.d`
* To run only the unit tests matching a UDA, run: `./run.d -u --filter "self test"`
2019-02-09 11:57:14 +01:00

96 lines
1.8 KiB
Text

name "dmd"
description "The DMD compiler"
authors "Walter Bright"
copyright "Copyright © 1999-2018, The D Language Foundation"
license "BSL-1.0"
targetType "none"
dependency ":frontend" version="*"
subPackage {
name "root"
targetType "library"
sourcePaths "src/dmd/root"
}
subPackage {
name "lexer"
targetType "library"
sourcePaths
sourceFiles \
"src/dmd/console.d" \
"src/dmd/entity.d" \
"src/dmd/errors.d" \
"src/dmd/filecache.d" \
"src/dmd/globals.d" \
"src/dmd/id.d" \
"src/dmd/identifier.d" \
"src/dmd/lexer.d" \
"src/dmd/tokens.d" \
"src/dmd/utf.d"
preGenerateCommands `
"$${DUB_EXE}" \
--arch=$${DUB_ARCH} \
--compiler=$${DC} \
--single "$${DUB_PACKAGE_DIR}config.d" \
-- "$${DUB_PACKAGE_DIR}generated/dub" \
"$${DUB_PACKAGE_DIR}VERSION" \
/etc
` platform="posix"
preGenerateCommands `"%DUB_EXE%" --arch=%DUB_ARCH% --compiler="%DC%" --single "%DUB_PACKAGE_DIR%config.d" -- "%DUB_PACKAGE_DIR%generated/dub" "%DUB_PACKAGE_DIR%VERSION"` platform="windows"
stringImportPaths "generated/dub"
dependency "dmd:root" version="*"
}
subPackage {
name "parser"
targetType "library"
sourcePaths
sourceFiles \
"src/dmd/astbase.d" \
"src/dmd/parse.d" \
"src/dmd/transitivevisitor.d" \
"src/dmd/permissivevisitor.d" \
"src/dmd/strictvisitor.d"
dependency "dmd:lexer" version="*"
}
subPackage {
name "frontend"
targetType "library"
sourcePaths "src/dmd"
stringImportPaths "res"
versions \
"NoBackend" \
"GC" \
"NoMain" \
"MARS"
excludedSourceFiles "src/dmd/backend/*"
excludedSourceFiles "src/dmd/{\
dmsc,\
e2ir,\
eh,\
glue,\
iasm,\
iasmdmd,\
iasmgcc,\
objc_glue,\
s2ir,\
tocsym,\
toctype,\
toobj,\
todt,\
toir\
}.d"
dependency "dmd:parser" version="*"
}