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

Runnable env #5202

Merged
merged 7 commits into from
Jul 3, 2020
Merged

Runnable env #5202

merged 7 commits into from
Jul 3, 2020

Conversation

vsrs
Copy link
Contributor

@vsrs vsrs commented Jul 3, 2020

This PR adds on option to specify (in the settings.json) environment variables passed to the runnable.
The simplest way for all runnables in a bunch:

    "rust-analyzer.runnableEnv": {
        "RUN_SLOW_TESTS": "1"
    }

Or it is possible to specify vars more granularly:

    "rust-analyzer.runnableEnv": [
        {
            // "mask": null, // null mask means that this rule will be applied for all runnables
            env: {
                 "APP_ID": "1",
                 "APP_DATA": "asdf"
            }
        },
        {
            "mask": "test_name",
            "env": {
                 "APP_ID": "2", // overwrites only APP_ID
            }
        }
    ]

You can use any valid RegExp as a mask. Also note that a full runnable name is something like run bin_or_example_name, test some::mod::test_name or test-mod some::mod, so it is possible to distinguish binaries, single tests, and test modules with this masks: "^run", "^test " (the trailing space matters!), and "^test-mod" respectively.

Fixes #4450

I suppose this info should be somewhere in the docs, but unsure where is the best place.

@matklad
Copy link
Member

matklad commented Jul 3, 2020

I suppose this info should be somewhere in the docs, but unsure where is the best place.

I think we need top-level section in manual.adoc for this:

== Editor Features
==== VS Code

@vsrs
Copy link
Contributor Author

vsrs commented Jul 3, 2020

@matklad I added the doc section.

@matklad
Copy link
Member

matklad commented Jul 3, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 3, 2020

@bors bors bot merged commit 8489145 into rust-lang:master Jul 3, 2020
@vsrs vsrs deleted the runnable_env branch July 3, 2020 14:11
@adaszko
Copy link
Contributor

adaszko commented Feb 2, 2021

Are those environment variables also applied when clicking the "Debug" code lens over a unit test in VSCode?

@vsrs
Copy link
Contributor Author

vsrs commented Feb 2, 2021

Yes, they are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Environment variables when running tests
3 participants