Skip to content

ocamltest: explicitly set OCAML_ERROR_STYLE#2271

Merged
gasche merged 1 commit intoocaml:trunkfrom
Armael:testsuite-env-vars
Feb 27, 2019
Merged

ocamltest: explicitly set OCAML_ERROR_STYLE#2271
gasche merged 1 commit intoocaml:trunkfrom
Armael:testsuite-env-vars

Conversation

@Armael
Copy link
Copy Markdown
Member

@Armael Armael commented Feb 27, 2019

Explicitly set OCAML_ERROR_STYLE to its default value when running tests,
instead of inheriting the one coming from the outside environment.

This should fix the concern raised by @mshinwell in #2096 .

NB: in theory an other way of doing that would be to unset the environment variable (so that the compiler uses the default value), but to my knowledge we do not bind unsetenv(3) (and would there be a windows counterpart?), so it's not possible to do that.
So we have to explicitly get and set the environment variable to the default value, which involves a bit of plumbing.

Copy link
Copy Markdown
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

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

The code generally looks good, but see comments for a small change suggestion.

error_style_reader.env_var
(error_style_reader.print Misc.Error_style.default_setting)
in
[| "TERM=dumb"; error_style |]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would generalize this logic to deal with Error_style and Color uniformly.

let env_setting env_reader default_setting = ...
let ocaml_env = [|
  "TERM=dumb";
  env_setting Clflags.error_style_reader Misc.Error_style.default_setting;
  env_setting Clflags.color_reader Misc.Color.default_setting
|]

Today I think that this is unnecessary because TERM=dumb implies the default color setting, but this shape of code (being careful to list all those touchy environment-decided options) scales better to the potential addition of new readers in the future.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also I think that default_ocaml_env would be a better variable name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Indeed, you're completely right. I just implemented your suggestion.

Explicitly set OCAML_ERROR_STYLE to its default value when running tests,
instead of inheriting the one coming from the outside environment.
@Armael Armael force-pushed the testsuite-env-vars branch from e47289e to 00411d4 Compare February 27, 2019 14:14
@gasche gasche merged commit d200181 into ocaml:trunk Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants