Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-pass environment variable resolution #2322

Merged
merged 11 commits into from
Jul 24, 2018

Conversation

john-patterson
Copy link
Contributor

Per issue #2057.

This allows a user to nest environment tags, or define tags based on the definition of other environment variables. If the result of a resolution still contains a ${...} tag, we will continue to scan the input until we reach a steady state where the variable expansion results in the same input.

This should allow the following forms which were previously not possible in the environment definition:

  • Dependent variable definition
"env": {
    "envRoot": "apps/tool/builldenv",
    "arm6.include": "${envRoot}/arm6/include"
},
...
"some_config": "${arm6.include}
  • Nested variable definition of any degree
"env": {
    "root": "apps/tool",
    "armVersion": "${config:armVersion}",
    "arm5.include": "${root}/legacy/arm/include",
    "arm6.include": "${root}/arm/include",
    "armTestPath": "${arm${armVersion}.include}/test"
}
  • Additionally, this fixes an open bug that was not reported. If a variable contained "env", "config", or "workspaceFolder" it would not be parsed correctly. If you used a variable ${envRoot} it would match "envR" as the type and "oot" as the variable. This has been resolved.

John Patterson and others added 9 commits July 24, 2018 09:27
We were passing the root of the test folder instead of the unitTests
specific folder into the runner, so it wasn't finding unit tests.
If a variable had env, config, or workspaceFolder as substring, it was
being treated as an environment variable lookup on the reminder of the
string minus the character immediately following the substring. For
instance: envRoot was being looked up as "oot" in the configuarion
environment block.

The issue is that the regex to match the env., config., and
workspaceFolder. patterns used . instead of \.
This gets rid of linting errors and adopts a more BDD literate assert style.
@@ -24,7 +24,7 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
"--extensionTestsPath=${workspaceFolder}/out/test/unitTests"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, that's interesting...I guess we don't Launch Tests very much :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks good so far. I'm not done reviewing yet...

@john-patterson
Copy link
Contributor Author

@bobbrow Raised a good point in that this a lot of added complexity for nesting variable, and the case that this is a useful feature for customers is a nebulous prospect at best. With that in might, I pushed a change which simplifies this feature at the expense of nested variables.

newValue = process.env[name];
}
break;
let regexp: () => RegExp = () => /\$\{((env|config|workspaceFolder)(\.|:))?(.*?)\}/g;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch 👍

Copy link
Collaborator

@sean-mcmanus sean-mcmanus left a comment

Choose a reason for hiding this comment

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

Seems good to me. Bob will probably want to finish reviewing as well.

@sean-mcmanus
Copy link
Collaborator

Do you know what's up with the Travis CI failure?

@john-patterson
Copy link
Contributor Author

These tests should pass in the future. I added the fix for Travis CI.

@john-patterson john-patterson self-assigned this Jul 24, 2018
@bobbrow bobbrow merged commit 7947dd8 into microsoft:master Jul 24, 2018
john-patterson pushed a commit to john-patterson/vscode-cpptools that referenced this pull request Jul 25, 2018
Realized I had left out the CHANGELOG update. For [PR
2322](microsoft#2322).
john-patterson added a commit to john-patterson/vscode-cpptools that referenced this pull request Jul 25, 2018
Realized I had left out the CHANGELOG update. For [PR
2322](microsoft#2322).
john-patterson added a commit to john-patterson/vscode-cpptools that referenced this pull request Jul 25, 2018
Realized I had left out the CHANGELOG update. For [PR
2322](microsoft#2322).
bobbrow pushed a commit that referenced this pull request Jul 27, 2018
Realized I had left out the CHANGELOG update. For [PR
2322](#2322).
@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants