unit_threaded.runtime

This module implements a template mixin containing a program to search a list of directories for all .d files therein, then writes a D program to run all unit tests in those files using unit_threaded. The program implemented by this mixin only writes out a D file that itself must be compiled and run.

To use this as a runnable program, simply mix in and compile:

#!/usr/bin/rdmd
import unit_threaded;
mixin genUtMain;

Or just use rdmd with the included gen_ut_main, which does the above. The examples below use the second option.

By default, genUtMain will look for unit tests in a tests folder and write a program out to a file named ut.d. To change the file to write to, use the -f option. To change what directories to look in, simply pass them in as the remaining command-line arguments.

Members

Functions

findModuleEntries
DirEntry[] findModuleEntries(Options options)
Undocumented in source. Be warned that the author may not have intended to support it.
findModuleNames
string[] findModuleNames(Options options)
Undocumented in source. Be warned that the author may not have intended to support it.
getGenUtOptions
Options getGenUtOptions(string[] args)
Undocumented in source. Be warned that the author may not have intended to support it.
writeUtMainFile
string writeUtMainFile(string[] args)
Undocumented in source. Be warned that the author may not have intended to support it.
writeUtMainFile
string writeUtMainFile(Options options)
Undocumented in source. Be warned that the author may not have intended to support it.

Mixin templates

genUtMain
mixintemplate genUtMain()
Undocumented in source.

Structs

Options
struct Options
Undocumented in source.

Examples

# write ut.d that finds unit tests from files in the tests directory
rdmd $PHOBOS/std/experimental/testing/gen_ut_main.d

# write foo.d that finds unit tests from the src and other directories
rdmd $PHOBOS/std/experimental/testing/gen_ut_main.d -f foo.d src other

The resulting ut.d file (or as named by the -f option) is also a program that must be compiled and, when run, will run the unit tests found. By default, it will run all tests. To run one test or all tests in a particular package, pass them in as command-line arguments. The -h option will list all command-line options.

Examples (assuming the generated file is called ut.d):

rdmd -unittest ut.d # run all tests
rdmd -unittest ut.d tests.foo tests.bar # run all tests from these packages
rdmd ut.d -h # list command-line options

Meta