Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-79573

add IWYU export pragmas to unittest.h

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Service Arch

      I just noticed a test (itoa_test.cpp in this case) was modified from its include of

      #include "mongo/unittest/unittest.h"

      to now use the granular includes of the components of the unittest library:

      #include "mongo/unittest/assert.h"
      #include "mongo/unittest/framework.h"

      This is a downgrade, as the unittest.h header is designed as an umbrella header for the API.
      These smaller more granular headers are basically implementation details designed to break dependency cycles when necessary.
      But unit tests without special dependency considerations should be using the unittest/unittest.h header and not the subcomponents.

      The unit tests affected by this migration should have their includes of unittest/unittest.h restored.

      There's an IWYU pragma that can be added to unittest.h to prevent future IWYU passes from doing this again.


      We'd make unittest/unittest.h look like this:

      #pragma once
      // IWYU pragma: begin_exports
      #include "mongo/unittest/assert.h"
      #include "mongo/unittest/assert_that.h"
      #include "mongo/unittest/bson_test_util.h"
      #include "mongo/unittest/framework.h"
      // IWYU pragma: end_exports

            backlog-server-servicearch [DO NOT USE] Backlog - Service Architecture
            billy.donahue@mongodb.com Billy Donahue
            0 Vote for this issue
            5 Start watching this issue