Commit 96117d1
abacus_fixer
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
185 | 188 | | |
186 | 189 | | |
187 | 190 | | |
| |||
0 commit comments