From 23f73592b1e5fe7c40bdb68f2350aa47c38bd84d Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 21 Jan 2024 19:53:58 -0500 Subject: [PATCH] Add test to avoid invalidating virtualenv (#1031) ## Summary I think if we used symlinks (instead of hardlinks), this test would fail -- so it's worth including. --- crates/puffin/tests/pip_sync.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/puffin/tests/pip_sync.rs b/crates/puffin/tests/pip_sync.rs index 3f2684a672d5..b84ebfc1667e 100644 --- a/crates/puffin/tests/pip_sync.rs +++ b/crates/puffin/tests/pip_sync.rs @@ -1,8 +1,8 @@ #![cfg(all(feature = "python", feature = "pypi"))] -use std::iter; use std::path::Path; use std::process::Command; +use std::{fs, iter}; use anyhow::{Context, Result}; use assert_cmd::prelude::*; @@ -121,6 +121,11 @@ fn install() -> Result<()> { check_command(&venv, "import markupsafe", &temp_dir); + // Removing the cache shouldn't invalidate the virtual environment. + fs::remove_dir_all(cache_dir.path())?; + + check_command(&venv, "import markupsafe", &temp_dir); + Ok(()) } @@ -163,6 +168,11 @@ fn install_copy() -> Result<()> { check_command(&venv, "import markupsafe", &temp_dir); + // Removing the cache shouldn't invalidate the virtual environment. + fs::remove_dir_all(cache_dir.path())?; + + check_command(&venv, "import markupsafe", &temp_dir); + Ok(()) } @@ -205,6 +215,11 @@ fn install_hardlink() -> Result<()> { check_command(&venv, "import markupsafe", &temp_dir); + // Removing the cache shouldn't invalidate the virtual environment. + fs::remove_dir_all(cache_dir.path())?; + + check_command(&venv, "import markupsafe", &temp_dir); + Ok(()) }