Skip to content

Conversation

@jkoritzinsky
Copy link
Member

@jkoritzinsky jkoritzinsky commented Aug 26, 2021

Introduce support into corerun for providing a "dotenv" file based on the format supported by python-dotenv that corerun will use to set environment variables before loading CoreCLR.

This can be used to set various different stress modes by just editing a text file with a single format instead of having to edit a script which you then have to run.

The file can be provided to corerun with the -e or --env flags.

For example, diagnosing #57915 took setting and regularly changing 5+ environment variables, which was error prone.

TODO:

  • Docs
  • Update the bash/batch scripts for tests to support dotenv files.
  • Investigation into updating "scenario" Helix runs for corerun-based testing to use this.

@ghost ghost added the area-Host label Aug 26, 2021
@ghost
Copy link

ghost commented Aug 26, 2021

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

Issue Details

Introduce support into corerun for providing a "dotenv" file based on the format supported by python-dotenv that corerun will use to set environment variables before loading CoreCLR.

This can be used to set various different stress modes by just editing a text file with a single format instead of having to edit a script which you then have to run.

The file can be provided to corerun with the -e or --env flags.

TODO:

  • Docs
  • Update the bash/batch scripts for tests to support dotenv files.
  • Investigation into updating "scenario" Helix runs for corerun-based testing to use this.
Author: jkoritzinsky
Assignees: -
Labels:

area-Host

Milestone: -

@jkoritzinsky
Copy link
Member Author

Also, another fun feature that comes with this: GCStress can now be enabled when testing with WinDbgNext without having to use child process debugging through a batch file!

@am11
Copy link
Member

am11 commented Aug 27, 2021

format supported by python-dotenv that corerun will use to set environment variables before loading CoreCLR.

dotenv is a specific format that allows extra stuff, which typically is not allowed in the shell. e.g. spaces before/after =.
Is it the full implementation of dotenv format, or just to the extent we need, i.e. dotenv-like? If it is partial support, do we know what are the limitations? If it is a full implementation does -st pass, e.g., these conformance tests: https://github.com/motdotla/dotenv/tree/master/tests?

@jkoritzinsky
Copy link
Member Author

It's meant to support the same level of dotenv support that the python-dotenv project provides (trimming spaces around the equals, comments, quoting and multi-line support, etc). I've seen various different rules for the format between python, nodejs, Ruby, etc. implementations, so I picked one to use as my base.

@jkoritzinsky
Copy link
Member Author

Skimming through those tests, the only case that I don't already test (and doesn't work) is '\r'-only line ending parsing.

Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

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

return { buffer.get() };
}
string_t get_exe_path()
inline void setenv(const char_t* var, string_t value)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of string_t value, why not const char_t* value?

Copy link
Member Author

Choose a reason for hiding this comment

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

I used string_t here for parity with pal::getenv which returns a string_t.

@am11
Copy link
Member

am11 commented Aug 27, 2021

dotenv support that the python-dotenv project provides

Nice. It includes variable expansion https://pypi.org/project/python-dotenv/#variable-expansion as well?
I was just thinking whether it is too much to add a full blown dotenv format support, when all we really need is reading a .txt file line-by-line with KEY=VALUE pair (plus some error handling).

@jkoritzinsky
Copy link
Member Author

Yep it has variable expansion too! It first looks in env vars previously specified in the file. If it's not found there, then it looks in the environment. If it's not defined anywhere, it substitutes with an empty string.

@jkoritzinsky
Copy link
Member Author

cc: @elinor-fung

@jkoritzinsky
Copy link
Member Author

Only test failure is the xunit test harness collection issue.

Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

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

Thanks!

Co-authored-by: Aaron Robinson <arobins@microsoft.com>
@ghost
Copy link

ghost commented Sep 2, 2021

Hello @jkoritzinsky!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit f3c705e into dotnet:main Sep 3, 2021
@jkoritzinsky jkoritzinsky deleted the dotenv-corerun branch September 28, 2021 00:03
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants