Add ignore-online-tests feature

Since these tests require internet access, they are undesirable in
reproducible builds [1] (and in general, I guess). The overall goal is
to shrink this list to a minimum. At some point we might remove the
feature again and ignore online tests by default. Before putting much
thought into refactoring the remaining tests, we should wait until we
have introduced the `updates.archive_url` option. Then, we could run a
local webserver that serves a known file. Until then, having the feature
already helps discourage using `--update` in tests that don't need it
and allows for quicker test execution locally if wanted.

- [1]: edf04b75c1/pkgs/by-name/te/tealdeer/package.nix (L34-L44)
This commit is contained in:
Niklas Mohrin 2025-01-01 23:17:49 +01:00
commit fc19206029
No known key found for this signature in database
GPG key ID: 0ACD89A5C1DEB3EB
2 changed files with 10 additions and 2 deletions

View file

@ -60,6 +60,8 @@ native-roots = ["reqwest/rustls-tls-native-roots"]
webpki-roots = ["reqwest/rustls-tls-webpki-roots"]
native-tls = ["reqwest/native-tls"]
ignore-online-tests = []
[profile.release]
strip = true
opt-level = 3

View file

@ -186,6 +186,7 @@ fn test_missing_cache() {
.stderr(contains("Page cache not found. Please run `tldr --update`"));
}
#[cfg_attr(feature = "ignore-online-tests", ignore = "online test")]
#[test]
fn test_update_cache_default_features() {
let testenv = TestEnv::new();
@ -207,6 +208,7 @@ fn test_update_cache_default_features() {
testenv.command().args(["sl"]).assert().success();
}
#[cfg_attr(feature = "ignore-online-tests", ignore = "online test")]
#[test]
fn test_update_cache_rustls_webpki() {
let testenv = TestEnv::new()
@ -230,6 +232,7 @@ fn test_update_cache_rustls_webpki() {
testenv.command().args(["sl"]).assert().success();
}
#[cfg_attr(feature = "ignore-online-tests", ignore = "online test")]
#[test]
fn test_quiet_cache() {
let testenv = TestEnv::new();
@ -285,6 +288,7 @@ fn test_quiet_old_cache() {
.stderr(contains("The cache hasn't been updated for ").not());
}
#[cfg_attr(feature = "ignore-online-tests", ignore = "online test")]
#[test]
fn test_create_cache_directory_path() {
let testenv = TestEnv::new();
@ -297,7 +301,7 @@ fn test_create_cache_directory_path() {
assert!(!internal_cache_dir.exists());
command
.arg("-u")
.arg("--update")
.assert()
.success()
.stderr(contains(format!(
@ -309,6 +313,7 @@ fn test_create_cache_directory_path() {
assert!(internal_cache_dir.is_dir());
}
#[cfg_attr(feature = "ignore-online-tests", ignore = "online test")]
#[test]
fn test_cache_location_not_a_directory() {
let testenv = TestEnv::new();
@ -320,7 +325,7 @@ fn test_cache_location_not_a_directory() {
command.env(CACHE_DIR_ENV_VAR, internal_file.to_str().unwrap());
command
.arg("-u")
.arg("--update")
.assert()
.failure()
.stderr(contains(format!(
@ -743,6 +748,7 @@ fn test_multi_platform_list_flag_rendering() {
.stdout("common\ndel\ndir\nls\nrm\nwinux\n");
}
#[cfg_attr(feature = "ignore-online-tests", ignore = "online test")]
#[test]
fn test_autoupdate_cache() {
let testenv = TestEnv::new();