Skip to content

Commit 96117d1

Browse files
author
abacus_fixer
committed
fix(relax): fix Test_RELAX failure after removing PARAM global dependency
Symptom: MODULE_RELAX_relax_new_relax failed. relax_step did nothing and all taud/latvec values stayed at their initial values. Root cause: Commit 977855a replaced the global PARAM.input in Test_RELAX with a local Input_para inp member, but missed three parameters that had been silently inherited from the global state. The inheritance worked because GoogleTest runs test suites in definition order: Test_SETGRAD runs first and leaves the following values in the global PARAM.input, which Test_RELAX reused without setting them: - calculation = cell-relax - force_thr = 0.001 - fixed_axes = a After the commit each test class has its own local inp, so this hidden sharing was lost: - calculation defaults to scf, so setup_gradient returns true immediately and relax_step does nothing. - force_thr defaults to -1, which changes line_search convergence behavior. - fixed_axes defaults to None, which skips the stress constraint branch and changes cell movement. Fix: Explicitly set the three previously-inherited parameters in Test_RELAX::SetUp(): inp.calculation = cell-relax; inp.force_thr = 0.001; inp.fixed_axes = a; Lessons learned: When removing a global-variable dependency, audit every field read by the code under test, including fields implicitly left behind by other test suites. Each test should be self-contained and not rely on inter-test-suite execution order.
1 parent cd035f8 commit 96117d1

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

source/source_relax/test/relax_test.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ class Test_RELAX : public testing::Test
182182
int nstep = 3;
183183
int nat = 5;
184184
double energy;
185+
inp.calculation = "cell-relax";
186+
inp.force_thr = 0.001;
187+
inp.fixed_axes = "a";
185188
inp.stress_thr = 0.01;
186189
inp.fixed_ibrav = false;
187190

0 commit comments

Comments
 (0)