banditcpp / bandit

Human-friendly unit testing for C++11
https://banditcpp.github.io/bandit/
Other
259 stars 37 forks source link

Introduce controller_t and rework options #128

Closed sbeyer closed 6 years ago

sbeyer commented 6 years ago

This is an attempt to make the internals of bandit more flexible. The purpose of controller_t is to contain all the important things, like assertion framework, colorizer, failure formatter, reporter, run policy, and what else may come in the future. Now all our grammar is based on this type (and the static/inline grammar functions now call the according controller_t methods, hence the name).

The introduction of controller_t also allows to make the addition of colorizers/formatters/reporters more flexible: simply define it and then add it with a lambda that changes the corresponding settings. This allows to get rid of all the code about colorizers/formatters/reporters in different places of the bandit source and hence error-prone, and it now allows that users may define their own colorizers/formatters/reporters and register them.

Note that controller_t is called settings_t at the beginning of the branch and it is renamed afterwards.

Also note that despite the advantages, a disadvantage is that the specs became a little more awkward now.

codecov-io commented 6 years ago

Codecov Report

Merging #128 into master will increase coverage by 2.47%. The diff coverage is 98.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #128      +/-   ##
==========================================
+ Coverage   96.13%   98.61%   +2.47%     
==========================================
  Files          35       34       -1     
  Lines         932      940       +8     
  Branches       73       74       +1     
==========================================
+ Hits          896      927      +31     
+ Misses         36       13      -23
Impacted Files Coverage Δ
bandit/colorizers/interface.h 100% <ø> (ø) :arrow_up:
bandit/reporters/colored_base.h 100% <ø> (ø) :arrow_up:
bandit/reporters/interface.h 100% <ø> (ø) :arrow_up:
bandit/reporters/summary.h 100% <ø> (ø) :arrow_up:
bandit/failure_formatters/interface.h 100% <ø> (ø) :arrow_up:
bandit/run_policies/interface.h 100% <ø> (ø) :arrow_up:
bandit/context.h 100% <100%> (ø) :arrow_up:
bandit/options.h 97.82% <100%> (-0.47%) :arrow_down:
bandit/grammar.h 100% <100%> (+1.26%) :arrow_up:
bandit/controller.h 96.93% <96.93%> (ø)
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3cb21ec...6f5d234. Read the comment docs.