Skip to content

refactor(dfpt): replace the stru fixture base class with a free-function test tool - #8283

Merged
mohanchen merged 6 commits into
deepmodeling:developfrom
Zanthoxylum:refactor-dfpt-stru-tool
Nov 4, 2026
Merged

mohanchen merged 6 commits into
deepmodeling:developfrom
Zanthoxylum:refactor-dfpt-stru-tool

Conversation

@Zanthoxylum

@Zanthoxylum Zanthoxylum commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

DFPTStruTestFixture (the shared fixture base class and its header on
the MPI-side test directory, test/dfpt_stru_fixture.{h,cpp}) is
replaced by a free-function test tool — the same pattern as #8270's
serial-side dfpt_test_tool and the established module_pw test/test_tool:

  • test/dfpt_stru_tool.{h,cpp}: the structure-table types
    (atomtype_ / stru_), the default cubic-carbon table
    (cubic_carbon_stru()) and construct_ucell(UnitCell&, const stru_&)
    as free functions — bodies moved verbatim from the fixture.
  • dfpt_pw_data_test.cpp / dfpt_pw_run_test.cpp derive their
    fixtures directly from ::testing::Test, own their UnitCell and
    call the utilities; the atoms cleanup is inline (delete[] ucell.atoms).
  • CMakeLists.txt swaps dfpt_stru_fixture.cpp for
    dfpt_stru_tool.cpp in both targets.

After this PR the MPI-side test directory has no shared fixture base
class and no fixture header
: every test file there is self-contained
in gtest style, and its shared facility is this free-function utility
pair (plus the dfpt_test_mocks link stubs). The serial-side
counterpart (dfpt_test_tool, removing dfpt_serial_fixture) is the
pending #8270 — until it lands, test_serial/ still carries its own
fixture; the two removals are independent.

No dependency on the open PRs: zero file overlap with #8268 /
#8270 / #8262 (they touch the test_serial/ side and module_pw only).

Verification

cmake --build build-gcc13 --target MODULE_DFPT_pw_data_test \
  MODULE_DFPT_pw_run_test -j 20
ctest --test-dir build-gcc13 -R "MODULE_DFPT"      # 10/10 targets Passed
  • Both reworked targets rebuilt from deleted binaries (make exit
    code 0).
  • Case counts conserved: pw_data 6 / pw_run 3 (identical case names).
  • Full MODULE_DFPT suite: 10/10.

Documentation

No docs change needed: test-only refactor with no INPUT, interface, or
behavior change.

…ion test tool

DFPTStruTestFixture and its header are removed in favor of
dfpt_stru_tool.{h,cpp} (the same free-function pattern as the serial
side's dfpt_test_tool and module_pw's test_tool): the structure-table
types (atomtype_ / stru_), the default cubic carbon table
(cubic_carbon_stru) and construct_ucell as free functions. The two
consumers derive their fixtures directly from ::testing::Test, own
their UnitCell and call the utilities; the cleanup deletes the atoms
array inline. CMakeLists swaps dfpt_stru_fixture.cpp for
dfpt_stru_tool.cpp in both targets. After this the module has no
shared fixture base classes or fixture headers anywhere (test_serial
and test alike). Both targets rebuilt from deleted binaries (make
rc=0); case counts conserved (pw_data 6 / pw_run 3); full MODULE_DFPT
ctest 10/10.
@Zanthoxylum Zanthoxylum added Refactor Refactor ABACUS codes Tests/Examples Issues/PR related to unit tests and integrate tests DFPT Density Functional Perturbation Theory labels Nov 4, 2026

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review of 00d1f832: two nonblocking suggestions. No builds or tests were run.

… the tool-header claim

Per review: both consumers store cubic_carbon_stru() in a named const
dfpt_test::stru_ local before calling construct_ucell (rule 14), and the
tool header no longer references test_serial/dfpt_test_tool, which is
not on develop at this head -- it now cites module_pw's test/test_tool
pattern and marks the serial-side counterpart as pending review, with
the no-shared-fixture claim scoped to this directory. Both targets
rebuilt from deleted binaries; full MODULE_DFPT ctest 10/10.

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static re-review of dfe20479 found no new issues. No builds or tests were run.

@mohanchen
mohanchen merged commit e239ab0 into deepmodeling:develop Nov 4, 2026
18 checks passed
@Zanthoxylum
Zanthoxylum deleted the refactor-dfpt-stru-tool branch November 5, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DFPT Density Functional Perturbation Theory Refactor Refactor ABACUS codes Tests/Examples Issues/PR related to unit tests and integrate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants