HomePhabricator

Avoid custom main for passing arguments to the unit tests

Description

Avoid custom main for passing arguments to the unit tests

Summary:
Since D4474 the unit tests rely on BOOST_TEST_NO_MAIN to override the
default Boost unit tests framework main function.
This doesn't work by default when Boost is built as a static library,
which is the case when the software builds against the depends
libraries.
This diff replaces the custom main with a global fixture, that forwards
custom arguments before any test begins.

This is an alternative to D4837.

Test Plan:

ninja check
ninja check-bitcoin-upgrade-activated

Edit src/tests/activation_tests.cpp: add the line

BOOST_TEST_MESSAGE("Phonon activation time : " << activation);

after the const auto activation = [...] in the isphononenabled test
case.

./src/test/test_bitcoin -t activation_tests --log_level=all

Look at the log, it should contain the line:

Phonon activation time : 1589544000

./src/test/test_bitcoin -t activation_tests --log_level=all \
  -- -phononactivationtime=1575158400

Look at the log, it should contain the line:

Phonon activation time : 1575158400

/src/test/test_bitcoin -t activation_tests --log_level=all -- -foo

Look at the log, it should contain the line (it may be prefixed with
more info):

Test setup error: std::invalid_argument: Invalid parameter -foo

Cross build `test_bitcoin` for any platform and check the build is

successful.

Reviewers: #bitcoin_abc, deadalnix, jasonbcox

Reviewed By: #bitcoin_abc, deadalnix, jasonbcox

Subscribers: jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D4841

Details

Provenance
FabienAuthored on Jan 6 2020, 13:29
FabienPushed on Jan 6 2020, 21:29
Reviewer
Restricted Project
Differential Revision
D4841: Avoid custom main for passing arguments to the unit tests
Parents
rABC97833b37ad0f: GUI: Change the receive button to respond to keypool state changing
Branches
Unknown
Tags
Unknown