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

Proper "ignore test depending on env" handling #139

Open
crepererum opened this issue May 24, 2022 · 1 comment
Open

Proper "ignore test depending on env" handling #139

crepererum opened this issue May 24, 2022 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@crepererum
Copy link
Collaborator

Abstract

We want to skip tests if certain environment variables are NOT set (e.g. SOCKS_PROXY) so that developers do not need to provide a full-blown integration test infrastructure if they only work on a subset of the features.

ACs

  • tests are skipped when environment variables are NOT set
  • tests are skipped at runtime, NOT at compile time
  • skipped tests are marked as "ignored"
  • tests skipping requires little code (ideally a single line in form of a decorator, a function call, a macro call)

Current Situation

We currently use macros like this:

/// Get the Socks Proxy environment variable.
///
/// If `SOCKS_PROXY` is not set, fail the tests and provide
/// guidance for setting `SOCKS_PROXY`.
#[macro_export]
macro_rules! maybe_skip_SOCKS_PROXY {
() => {{
use std::env;
dotenv::dotenv().ok();
match (env::var("SOCKS_PROXY").ok()) {
Some(proxy) => proxy,
_ => {
eprintln!("skipping integration tests with Proxy - set SOCKS_PROXY to run");
return;
}
}
}};
}

This fulfills all ACs except for skipped tests are marked as "ignored".

References

@crepererum crepererum added the help wanted Extra attention is needed label May 24, 2022
@crepererum
Copy link
Collaborator Author

@mario-s volunteered to work on this 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant