Difference between revisions of "Phobos development"

From D Wiki
Jump to: navigation, search
(Created page with "This page explains commonly used commands that are used while working with the D standard library <tt>phobos</tt>. = Unittest <tt>phobos</tt> = == Full build == If you want...")
 
(Replaced content with "Please see Contributing to Phobos")
 
Line 1: Line 1:
This page explains commonly used commands that are used while working with the D standard library <tt>phobos</tt>.
+
Please see [[Contributing to Phobos]]
 
 
= Unittest <tt>phobos</tt> =
 
 
 
== Full build ==
 
 
 
If you want to work on phobos itself, you need to run unittests&mdash;either for the full library, a package, or a module. To unittest the entire library:
 
 
 
<syntaxhighlight lang=bash>
 
make -j16 -f posix.mak unittest
 
</syntaxhighlight>
 
 
 
Adjust the parameter passed to <tt>-j</tt> depending on your machine (beefier machines support larger parameters). This command unittests <tt>phobos</tt> in both debug and release mode. To only test one of them, add <tt>BUILD=debug</tt> or <tt>BUILD=release</tt> to the command line, for example:
 
 
 
<syntaxhighlight lang=bash>
 
make -j16 -f posix.mak BUILD=debug unittest
 
</syntaxhighlight>
 
 
 
Specifying <tt>BUILD</tt> makes unittesting faster so it is recommended in iterative development. Just make sure both debug and release builds are tested before e.g. submitting a pull request.
 
 
 
== Test a single Phobos module ==
 
 
 
While changing one specific package or module, it's useful to be able to only unittest that particular entity. The following two commands only unittest (in debug mode) the <tt>std.algorithm</tt> package:
 
 
 
<syntaxhighlight lang=bash>
 
make -j16 -f posix.mak BUILD=debug std/algorithm.test
 
</syntaxhighlight>
 
 
 
Several modules, packages, or mix thereof may be specified for testing in the same command line. For example, this command also tests (and also in debug mode) the <tt>std.algorithm</tt> package and the <tt>std.conv</tt> module, with better parallelism:
 
 
 
<syntaxhighlight lang=bash>
 
make -j16 -f posix.mak BUILD=debug std/algorithm.test std/conv.test
 
</syntaxhighlight>
 
 
 
== Test a single module without rebuilding Phobos ==
 
 
 
You can test a module directly with <tt>rdmd</tt>:
 
 
 
<syntaxhighlight lang=bash>
 
rdmd --compiler=~/dlang/dmd/generated/linux/release/64/dmd -unittest -main std/algorithm/sorting.d
 
</syntaxhighlight>
 
 
 
(If you are on a different platform, replace <tt>linux></tt> with your respective platform)
 
 
 
However, be aware that this method doesn't recompile the Phobos library and thus only checks the executed file.
 
Thus you should only use this for fast builds on small changes.
 
 
 
= Run CI checks =
 
 
 
The auto-tester will fail your PR if your changes contain trailing whitespace or incorrect line endings. You can run this test locally with the command:
 
 
 
<syntaxhighlight lang=bash>
 
make -j16 -f posix.mak checkwhitespace
 
</syntaxhighlight>
 
 
 
CircleCi will also run various checks for the [http://dlang.org/dstyle.html DStyle] and ensures that every example is runnable on <tt>dlang.org</tt>.
 
You can run this test locally with:
 
 
 
<syntaxhighlight lang=bash>
 
make -f posix.mak style
 
</syntaxhighlight>
 

Latest revision as of 22:06, 11 December 2017