-
Notifications
You must be signed in to change notification settings - Fork 28
Convert unittests in .d files to use d-lang unittests
#141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Alex-Muirhead
wants to merge
11
commits into
master
Choose a base branch
from
d-unittests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6094904 to
3345864
Compare
Collaborator
Author
|
Removed all the final |
944967d to
c88f2fc
Compare
9b4e6ec to
f06262c
Compare
cd1927d to
28fdad1
Compare
To make this play nicer with our existing d-unittests, we create a separate test_gas_calc file, and ensure we build gas-calc before running the tests. This new test_gas_calc uses std.process to launch the compiled gas-calc.
This makes the intention clearer than using a filter operation, however runs the risk of the relative path being incorrect if moved.
28fdad1 to
843e98c
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Current unittests in D source files use
tclscripts for testing, and generate a separate executable for each unittest (enabled using specific version flags). This leaves 3 points of failure:tclscript for testingBy converting all unittests to use the specific
unittestblock (enabled via the--unittestflag), we can compile an entire module to a single executable that runs all tests. As long as the file is marked as a source file, any unittests it contains will be correctly run.Additions
However, the default test-runner for D is extremely noisy (listing entire stack traces for assertion failures), without adding much information.
Example verbose output
For a single assert fail:
I've added a separate
test_runner.dfile tosrc/utils/that aims to emulate the output of PyTest (already used inexamples/).Example test_runner output
Features
--unittest) will have their unittest run. This is usually more information than required. The executable generated bytest_runner.dhas a--module <name>option, which filters tests down to those belonging to modules starting with<name>(i.e.--module gas.diffusionwill only run tests withingas/diffusion/).stdoutcapturing: The previous unittesting would fail a test if it wrote tostdout(viawritelnetc). Within the new framework, any output is captured, and only displayed in the error description of failed/errored tests. This helps with debugging tests without cluttering the output / causing false positives.util.test_runnermodule contains askip(string message = "Skipped test")function, and the relevant unittest won't count as failed or errored. This function won't cause any problems with existing test runners.Notes
makefiles for these modules contain combinations oftest,test-all,test-real, andtest-complextargets. A unified naming convention would be best.