Skip to content

Commit 9f1b592

Browse files
authored
Retry flaky compile_invalid_pyc_invalidation_mode test (#4043)
Retry the flaky `compile_invalid_pyc_invalidation_mode` if it fails. I don't understand why this happening in the first place (we have code that should catch those cases, but also those cases shouldn't be happening at all) and this is terrible hack, but it fixes the test flakes. Fixes #2672
1 parent a241f14 commit 9f1b592

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

crates/uv/tests/pip_sync.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use url::Url;
1616
use common::{create_venv, uv_snapshot, venv_to_interpreter};
1717
use uv_fs::Simplified;
1818

19-
use crate::common::{copy_dir_all, get_bin, TestContext, EXCLUDE_NEWER};
19+
use crate::common::{copy_dir_all, get_bin, run_and_format, TestContext, EXCLUDE_NEWER};
2020

2121
mod common;
2222

@@ -3192,10 +3192,6 @@ fn compile() -> Result<()> {
31923192

31933193
/// Test that the `PYC_INVALIDATION_MODE` option is recognized and that the error handling works.
31943194
#[test]
3195-
#[cfg_attr(
3196-
target_os = "macos",
3197-
ignore = "The bytecode trace is spuriously different on macOS"
3198-
)]
31993195
fn compile_invalid_pyc_invalidation_mode() -> Result<()> {
32003196
let context = TestContext::new("3.12");
32013197

@@ -3214,11 +3210,24 @@ fn compile_invalid_pyc_invalidation_mode() -> Result<()> {
32143210
])
32153211
.collect();
32163212

3217-
uv_snapshot!(filters, sync_without_exclude_newer(&context)
3218-
.arg("requirements.txt")
3219-
.arg("--compile")
3220-
.arg("--strict")
3221-
.env("PYC_INVALIDATION_MODE", "bogus"), @r###"
3213+
// Retry test if we run into a broken pipe (https://github.com/astral-sh/uv/issues/2672).
3214+
// TODO(konsti): Why is this happening in the first place?
3215+
let run_test = || {
3216+
let mut command = sync_without_exclude_newer(&context);
3217+
command
3218+
.arg("requirements.txt")
3219+
.arg("--compile")
3220+
.arg("--strict")
3221+
.env("PYC_INVALIDATION_MODE", "bogus");
3222+
let (snapshot, _output) = run_and_format(command, filters.clone(), function_name!(), None);
3223+
snapshot
3224+
};
3225+
let mut snapshot = run_test();
3226+
if snapshot.contains("Failed to write to Python stdin") {
3227+
snapshot = run_test();
3228+
}
3229+
3230+
::insta::assert_snapshot!(snapshot, @r###"
32223231
success: false
32233232
exit_code: 2
32243233
----- stdout -----

0 commit comments

Comments
 (0)