mirror of
https://github.com/dlang/dmd.git
synced 2025-04-25 20:50:41 +03:00
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"`
This commit is contained in:
parent
e9920a3ab9
commit
f80c3f3a85
9 changed files with 692 additions and 95 deletions
9
dub.sdl
9
dub.sdl
|
@ -33,19 +33,14 @@ subPackage {
|
|||
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% ^
|
||||
--single "%DUB_PACKAGE_DIR%config.d" ^
|
||||
-- "%DUB_PACKAGE_DIR%generated/dub" ^
|
||||
"%DUB_PACKAGE_DIR%VERSION"
|
||||
` platform="windows"
|
||||
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"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue