ocamltest: do not overwrite user-defined variables#9633
Conversation
|
Thanks a lot, @nojb.
In principle this looks all very neat and sensible to me. Something
puzzles me, though. As you might have noticed when adapting the tests,
they contained definitions like
```
ocamlrunparam += ",b=1"
```
Mark the "+=" and the comma at the beginning of the string. What was
supposed to happen for a variable like ocamlrunparam is that it should
be initialized by ocamltest with the content of the environment
variable, to which the string should be concatenated.
That may turn useful if you e.g. want to make the GC verbose in
addition, or things like that, which is something we do or at least did
at some point.
What do you think, @nojb ?
|
Indeed! The problem is that the setting If we merge that PR before I will amend this one accordingly. In any case, there is a Travis failure related to the debug runtime that seems related to the proposed change. However, I haven't had time to investigate yet. |
|
Nicolás Ojeda Bär (2020/06/04 02:46 -0700):
Indeed! The problem is that the setting `OCAMLRUNPARAM` to `,b=1` (ie
when not extending anything), does not currently work (but there is a
fix in #9634).
So nice! Thanks!
If we merge that PR before I will amend this one accordingly.
That looks like the right approach to me. thanks again.
|
033ee88 to
b636f97
Compare
|
I rebased the PR on top of #9634 (which is a dependency), and it is ready for a final review. Explanation of the bug/resolution follows:
And with that, the problem is fixed. (The explanation of the fix is longer than the fix itself.) |
|
Rebased on trunk now that #9634 has been merged. |
|
Nicolás Ojeda Bär (2020/06/04 22:48 -0700):
Rebased on trunk now that #9634 has been merged.
Thanks. Won't be able to review before later today but will do ASAP.
|
|
Gosh, so sorry I made things so complicated.
The most frustrating is, I can't remember, several years later, why I
did that.
I guess (I hoope!) I had good reasons but forgot about them.
|
|
I went through the code which looks good to me, thanks. I have one remaining question. Is the modofication of tests still needed? |
I think so. By removing the call to |
|
Thanks for the review @shindere! Do you mind pressing the button to give a formal approval? Thanks! |
|
Nicolás Ojeda Bär (2020/06/08 02:16 -0700):
> I have one remaining question. Is the modofication of tests still needed?
I think so. By removing the call to `Printexc.record_backtrace` they
serve as evidence that the bug fix works. And also, it seems weird to
fix the handling of the `ocamlrunparam` variable and not use it in
those tests that were written with the intent of using it.
Sure! I didn't check that commit, sorry.
|
|
Nicolás Ojeda Bär (2020/06/08 03:13 -0700):
Thanks for the review @shindere! Do you mind pressing the button to
give a formal approval? Thanks!
I think I did it, no?
|
Yes, thanks! |
Fixes a bug discovered when reviewing #9469 : certain user-defined
ocamltestvariables (such asocamlrunparam) will be overwritten by what is defined in the system environment (or set to empty if not set). This problem is present in the testsuite whereocamlrunparam = ...is systematically ignored and was being "fixed" by also callingPrintexc.record_backtrace true.The reason for the bug is that the
ocamltestenvironment is computed in two steps:User-defined variables (as written in the script) are processed:
ocaml/ocamltest/main.ml
Lines 190 to 192 in abb8db4
Certain variables that come from the system environment are also added: see
ocaml/ocamltest/main.ml
Line 193 in abb8db4
Environment.initializeends up callingocaml/ocamltest/ocaml_actions.ml
Lines 1095 to 1122 in abb8db4
which overwrites a number of variables, including
ocamlrunparam.This PR inverts the order of 1. and 2., hopefully fixing the issue.UPDATE: it turns out this doesn't work because inverting the two calls breaks the logic that deals with themodulesvariable (at least). As a minimal fix, I changed it instead so that variables coming from the system environment are added only when the same variable is not already defined by the user.As a test, the explicit calls to
Printexc.record_backtraceare removed from the relevant tests.