Skip to content

libtest should set RUST_TEST_THREADS environment variable #74845

@nbaksalyar

Description

@nbaksalyar

We can configure the test runner concurrency by using either the --test-threads parameter, or by setting the environment variable RUST_TEST_THREADS:

let concurrency = opts.test_threads.unwrap_or_else(get_concurrency);

As some tests might need to read the current concurrency configuration, the only way to do this currently is by reading the said environment variable. However, if we use --test-threads, this information is not passed further to tests. I think this behaviour is a bit inconsistent and the env var should be always set to the actual value, e.g.:

let concurrency = opts.test_threads.unwrap_or_else(get_concurrency);
env::set_var("RUST_TEST_THREADS", concurrency.to_string());

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-libtestArea: `#[test]` / the `test` libraryC-feature-requestCategory: A feature request, i.e: not implemented / a PR.S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions