Skip to content

Allow the specification of env variables for tests. #10

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pub struct Config
pub always_show_stderr: bool,
/// Which shell to use (defaults to 'bash').
pub shell: String,
/// List of environment variables to be used on test invocation.
pub env_variables: HashMap<String, String>,
}

/// A function which can dynamically define newly used variables in a test.
Expand Down Expand Up @@ -154,6 +156,7 @@ impl Default for Config
truncate_output_context_to_number_of_lines: Some(DEFAULT_MAX_OUTPUT_CONTEXT_LINE_COUNT),
extra_executable_search_paths,
shell: "bash".to_string(),
env_variables: HashMap::default(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/run/test_evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ fn build_command(invocation: &Invocation,

let mut cmd = process::Command::new(&config.shell);
cmd.args(&["-c", &command_line]);
cmd.envs(&config.env_variables);

if !config.extra_executable_search_paths.is_empty() {
let os_path_separator = if cfg!(windows) { ";" } else { ":" };
Expand Down