Skip to content

Commit dbc1090

Browse files
committed
update
1 parent b2f2cf4 commit dbc1090

File tree

2 files changed

+98
-11
lines changed

2 files changed

+98
-11
lines changed

crates/uv/tests/it/common/mod.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,63 @@ impl TestContext {
144144
self
145145
}
146146

147+
/// Set the "concurrent builds" for all commands in this context.
148+
pub fn with_concurrent_builds(mut self, concurrent_builds: &str) -> Self {
149+
self.extra_env.push((
150+
EnvVars::UV_CONCURRENT_BUILDS.into(),
151+
concurrent_builds.into(),
152+
));
153+
self
154+
}
155+
156+
/// Set the "concurrent downloads" for all commands in this context.
157+
pub fn with_concurrent_downloads(mut self, concurrent_downloads: &str) -> Self {
158+
self.extra_env.push((
159+
EnvVars::UV_CONCURRENT_DOWNLOADS.into(),
160+
concurrent_downloads.into(),
161+
));
162+
self
163+
}
164+
165+
/// Set the "link mode" for all commands in this context.
166+
pub fn with_link_mode(mut self, link_mode: &str) -> Self {
167+
self.extra_env
168+
.push((EnvVars::UV_LINK_MODE.into(), link_mode.into()));
169+
self
170+
}
171+
172+
/// Set the "http retries" for all commands in this context.
173+
pub fn with_http_retries(mut self, http_retries: &str) -> Self {
174+
self.extra_env
175+
.push((EnvVars::UV_HTTP_RETRIES.into(), http_retries.into()));
176+
self
177+
}
178+
179+
/// Set the "color" preference for all commands in this context.
180+
pub fn with_color(mut self, color: &str) -> Self {
181+
// Color is controlled by NO_COLOR, FORCE_COLOR, and CLICOLOR_FORCE environment variables
182+
// See: crates/uv/src/settings.rs GlobalSettings::resolve
183+
match color.to_lowercase().as_str() {
184+
"never" => {
185+
self.extra_env.push((EnvVars::NO_COLOR.into(), "1".into()));
186+
}
187+
"always" => {
188+
self.extra_env.push((EnvVars::FORCE_COLOR.into(), "1".into()));
189+
}
190+
"auto" => {
191+
// Auto is the default behavior, but we explicitly remove color-related env vars
192+
// to ensure consistent behavior across environments
193+
self.extra_env.push((EnvVars::NO_COLOR.into(), "".into()));
194+
self.extra_env.push((EnvVars::FORCE_COLOR.into(), "".into()));
195+
self.extra_env.push((EnvVars::CLICOLOR_FORCE.into(), "".into()));
196+
}
197+
_ => {
198+
panic!("Invalid color value: {color}. Use 'never', 'always', or 'auto'");
199+
}
200+
}
201+
self
202+
}
203+
147204
/// Add extra standard filtering for messages like "Resolved 10 packages" which
148205
/// can differ between platforms.
149206
///

crates/uv/tests/it/show_settings.rs

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8502,7 +8502,12 @@ fn preview_features() {
85028502
ignore = "Configuration tests are not yet supported on Windows"
85038503
)]
85048504
fn preview_features_from_pyproject_toml() {
8505-
let context = TestContext::new("3.12");
8505+
let context = TestContext::new("3.12")
8506+
.with_concurrent_builds("12")
8507+
.with_concurrent_installs("12")
8508+
.with_link_mode("clone")
8509+
.with_http_retries("3")
8510+
.with_color("never");
85068511

85078512
let pyproject_toml = context.temp_dir.child("pyproject.toml");
85088513
pyproject_toml
@@ -8520,7 +8525,7 @@ fn preview_features_from_pyproject_toml() {
85208525
required_version: None,
85218526
quiet: 0,
85228527
verbose: 0,
8523-
color: Auto,
8528+
color: Never,
85248529
network_settings: NetworkSettings {
85258530
connectivity: Online,
85268531
native_tls: false,
@@ -8638,7 +8643,12 @@ fn preview_features_from_pyproject_toml() {
86388643
ignore = "Configuration tests are not yet supported on Windows"
86398644
)]
86408645
fn preview_features_from_uv_toml() {
8641-
let context = TestContext::new("3.12");
8646+
let context = TestContext::new("3.12")
8647+
.with_concurrent_builds("12")
8648+
.with_concurrent_installs("12")
8649+
.with_link_mode("clone")
8650+
.with_http_retries("3")
8651+
.with_color("never");
86428652

86438653
let uv_toml = context.temp_dir.child("uv.toml");
86448654
uv_toml
@@ -8655,7 +8665,7 @@ fn preview_features_from_uv_toml() {
86558665
required_version: None,
86568666
quiet: 0,
86578667
verbose: 0,
8658-
color: Auto,
8668+
color: Never,
86598669
network_settings: NetworkSettings {
86608670
connectivity: Online,
86618671
native_tls: false,
@@ -8773,7 +8783,12 @@ fn preview_features_from_uv_toml() {
87738783
ignore = "Configuration tests are not yet supported on Windows"
87748784
)]
87758785
fn preview_features_precedence_command_line_over_config() {
8776-
let context = TestContext::new("3.12");
8786+
let context = TestContext::new("3.12")
8787+
.with_concurrent_builds("12")
8788+
.with_concurrent_installs("12")
8789+
.with_link_mode("clone")
8790+
.with_http_retries("3")
8791+
.with_color("never");
87778792

87788793
let pyproject_toml = context.temp_dir.child("pyproject.toml");
87798794
pyproject_toml
@@ -8792,7 +8807,7 @@ fn preview_features_precedence_command_line_over_config() {
87928807
required_version: None,
87938808
quiet: 0,
87948809
verbose: 0,
8795-
color: Auto,
8810+
color: Never,
87968811
network_settings: NetworkSettings {
87978812
connectivity: Online,
87988813
native_tls: false,
@@ -8910,7 +8925,12 @@ fn preview_features_precedence_command_line_over_config() {
89108925
ignore = "Configuration tests are not yet supported on Windows"
89118926
)]
89128927
fn preview_features_precedence_command_line_over_env() {
8913-
let context = TestContext::new("3.12");
8928+
let context = TestContext::new("3.12")
8929+
.with_concurrent_builds("12")
8930+
.with_concurrent_installs("12")
8931+
.with_link_mode("clone")
8932+
.with_http_retries("3")
8933+
.with_color("auto");
89148934

89158935
// Command line should override environment variable
89168936
uv_snapshot!(context.filters(), context.version().arg("--show-settings").arg("--preview-features").arg("add-bounds").env(EnvVars::UV_PREVIEW_FEATURES, "json-output,format"), @r#"
@@ -9039,7 +9059,12 @@ fn preview_features_precedence_command_line_over_env() {
90399059
ignore = "Configuration tests are not yet supported on Windows"
90409060
)]
90419061
fn preview_boolean_still_works() {
9042-
let context = TestContext::new("3.12");
9062+
let context = TestContext::new("3.12")
9063+
.with_concurrent_builds("12")
9064+
.with_concurrent_installs("12")
9065+
.with_link_mode("clone")
9066+
.with_http_retries("3")
9067+
.with_color("never");
90439068

90449069
let pyproject_toml = context.temp_dir.child("pyproject.toml");
90459070
pyproject_toml
@@ -9057,7 +9082,7 @@ fn preview_boolean_still_works() {
90579082
required_version: None,
90589083
quiet: 0,
90599084
verbose: 0,
9060-
color: Auto,
9085+
color: Never,
90619086
network_settings: NetworkSettings {
90629087
connectivity: Online,
90639088
native_tls: false,
@@ -9175,7 +9200,12 @@ fn preview_boolean_still_works() {
91759200
ignore = "Configuration tests are not yet supported on Windows"
91769201
)]
91779202
fn no_preview_overrides_everything() {
9178-
let context = TestContext::new("3.12");
9203+
let context = TestContext::new("3.12")
9204+
.with_concurrent_builds("12")
9205+
.with_concurrent_installs("12")
9206+
.with_link_mode("clone")
9207+
.with_http_retries("3")
9208+
.with_color("never");
91799209

91809210
let pyproject_toml = context.temp_dir.child("pyproject.toml");
91819211
pyproject_toml
@@ -9195,7 +9225,7 @@ fn no_preview_overrides_everything() {
91959225
required_version: None,
91969226
quiet: 0,
91979227
verbose: 0,
9198-
color: Auto,
9228+
color: Never,
91999229
network_settings: NetworkSettings {
92009230
connectivity: Online,
92019231
native_tls: false,

0 commit comments

Comments
 (0)