Skip to content

Commit ed16690

Browse files
authored
fix: flaky task test (#1581)
Fix for flaky task test, not using `remove_var` because of: https://doc.rust-lang.org/std/env/fn.remove_var.html > Even though this function is currently not marked as unsafe, it needs to be because invoking it can cause undefined behaviour. The function will be marked unsafe in a future version of Rust. This is tracked in [rust#27970](rust-lang/rust#27970). > This function is safe to call in a single-threaded program. > In multi-threaded programs, you must ensure that are no other threads concurrently writing or reading(!) from the environment through functions other than the ones in this module. You are responsible for figuring out how to achieve this, but we strongly suggest not using set_var or remove_var in multi-threaded programs at all.
1 parent 162ee99 commit ed16690

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/task_tests.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ async fn test_task_with_env() {
219219

220220
pixi.tasks()
221221
.add("env-test".into(), None, FeatureName::Default)
222-
.with_commands(["echo From a $HELLO"])
222+
.with_commands(["echo From a $HELLO_WORLD"])
223223
.with_env(vec![(
224-
String::from("HELLO"),
224+
String::from("HELLO_WORLD"),
225225
String::from("world with spaces"),
226226
)])
227227
.execute()
@@ -246,7 +246,6 @@ async fn test_clean_env() {
246246
pixi.init().without_channels().await.unwrap();
247247

248248
std::env::set_var("HELLO", "world from env");
249-
250249
pixi.tasks()
251250
.add("env-test".into(), None, FeatureName::Default)
252251
.with_commands(["echo Hello is: $HELLO"])
@@ -282,3 +281,6 @@ async fn test_clean_env() {
282281
assert_eq!(result.exit_code, 0);
283282
assert_eq!(result.stdout, "Hello is: world from env\n");
284283
}
284+
285+
// When adding another test with an environment variable, please choose a unique name
286+
// to avoid collisions

0 commit comments

Comments
 (0)