[SERVER-43367] unittest framework enhancements/bugfixes Created: 17/Sep/19  Updated: 29/Oct/23  Resolved: 02/Oct/19

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.3.1

Type: Task Priority: Minor - P4
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Dev Tools 2019-09-23, Dev Tools 2019-10-07
Participants:

 Description   

unittest: Suite refactor

  • Segregate old-style dbtests into their own Suite initialization
    system: OldStyleSuiteSpecification. This is where the funky
    deprecated features can live on without interfering with the
    Suite API. It also gives us a searchable base class to identify
    them in the future.
  • OldStyleSuite has `setupTests()` and an `add<T>()` that
    Suite does not have. Suite API can shrink when it doesn't
    have to support these dbtest adaptor features.
    Suite only needs non-template `add(name, callback)`.
  • Add OldStyleSuiteInitializer to some dbtests that were missing it!
    These didn't use SuiteInstance to register themselves and were incorrect.
    They would self register, resulting in _allSuites() holding a std::shared_ptr
    to a static-duration Suite object!
  • Change `getSuite()` to return `Suite&` instead of `Suite*`.
  • No more "self-registering" in Suite constructor. Registration
    must be done as a separate post-construction step. This removes
    some unusual lifetime management code and is easier to document.
    Suite::getSuite(name) is the only way to make a Suite, and it
    does the make_shared and registration calls with a pseudo-private
    ConstructorEnable idiom.
  • Suite->run() returns std::unique_ptr<Result> instead of
    raw `Result*`.
  • Suite._ran does nothing. Removed.
  • Result.cur does nothing. Removed.
  • Switch to pass-by-value and std::move for most ctor args.
  • Add explicit on 1-arg ctors.
  • Get rid of TestHolder. It's just a 2-field struct.
  • use fmt instead of snprintf
  • TEST and TEST_F macros: generate TEST_TYPE once.
  • TEST and TEST_F macros: inline the _agent variable.
  • Mark _doRun as `override`.
  • Terminology: replace CASE_NAME with SUITE_NAME.
  • rename DeathTestImpl -> DeathTestBase
  • move getDeathTestPattern into the test as a static member function
  • refactor out some repetition from the comparator decl macros
  • use constexpr if and diamond relops to clean up the
    ComparisonAssertion class.


 Comments   
Comment by Githook User [ 02/Oct/19 ]

Author:

{'username': 'BillyDonahue', 'email': 'billy.donahue@mongodb.com', 'name': 'Billy Donahue'}

Message: SERVER-43367 unittest framework refactor/fixes

  • Segregate old-style dbtests into their own Suite initialization
    system: OldStyleSuiteSpecification. This is where the funky
    deprecated features can live on without interfering with the
    Suite API. It also gives us a searchable base class to identify
    them in the future.

OldStyleSuite has `setupTests()` and an `add<T>()` that
Suite does not have. Suite API can shrink when it doesn't
have to support these dbtest adaptor features.
Suite only needs non-template `add(name, callback)`.

  • Add OldStyleSuiteInitializer to some dbtests that were missing it!
    These didn't use SuiteInstance to register themselves and were
    incorrect. They would self register, resulting in _allSuites()
    holding a std::shared_ptr to a static-duration Suite object!
  • Change `getSuite()` to return `Suite&` instead of `Suite*`.
  • No more "self-registering" in Suite constructor. Registration
    must be done as a separate post-construction step. This removes
    some unusual lifetime management code and is easier to document.
    Suite::getSuite(name) is the only way to make a Suite, and it
    does the make_shared and registration calls with a pseudo-private
    ConstructorEnable idiom.
  • Suite->run() returns std::unique_ptr<Result> instead of
    raw `Result*`. It's virtual to support OldStyleSuite behavior.
  • Suite._ran does nothing. Removed.
  • Result.cur does nothing. Removed.
  • Switch to pass-by-value and std::move for most ctor args.
  • Add explicit on 1-arg ctors.
  • Get rid of TestHolder. It's just a 2-field struct.
  • use fmt instead of snprintf
  • TEST and TEST_F macros: generate TEST_TYPE once.
  • TEST and TEST_F macros: inline the _agent variable.
  • Mark _doRun as `override`.
  • Terminology: replace CASE_NAME with SUITE_NAME.
  • rename DeathTestImpl -> DeathTestBase
  • move getDeathTestPattern into the test as a static member function
  • refactor out some repetition from the comparator decl macros
  • use if-constexpr and diamond relops to clean up the
    ComparisonAssertion class.
  • dbtests: conditionally skip some add<T> calls
Comment by Billy Donahue [ 18/Sep/19 ]

https://mongodbcr.appspot.com/489260001/

Generated at Thu Feb 08 05:03:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.