[pve-devel] [PATCH proxmox] apt: tests: remove output directories before running test
Fiona Ebner
f.ebner at proxmox.com
Mon Jun 5 17:26:46 CEST 2023
I blindly assumed that cargo would re-create the TMPDIR before each
test run, but that doesn't seem to be the case and the test_digest
test now fails the second time when running 'cargo test' twice.
So partially revert 9b7c533 ("apt: tests: create temporary test
directories in CARGO_TARGET_TMPDIR") and re-introduce the
remove-before-test logic.
Fixes: 9b7c533 ("apt: tests: create temporary test directories in CARGO_TARGET_TMPDIR")
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
proxmox-apt/tests/repositories.rs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/proxmox-apt/tests/repositories.rs b/proxmox-apt/tests/repositories.rs
index be6aaff..64ecdbb 100644
--- a/proxmox-apt/tests/repositories.rs
+++ b/proxmox-apt/tests/repositories.rs
@@ -24,6 +24,11 @@ fn test_parse_write_dir(read_dir: &str) -> Result<(), Error> {
let write_dir = tmp_dir.join("sources.list.d.actual");
let expected_dir = test_dir.join("sources.list.d.expected");
+ if write_dir.is_dir() {
+ std::fs::remove_dir_all(&write_dir)
+ .map_err(|err| format_err!("unable to remove dir {:?} - {}", write_dir, err))?;
+ }
+
std::fs::create_dir_all(&write_dir)
.map_err(|err| format_err!("unable to create dir {:?} - {}", write_dir, err))?;
@@ -92,6 +97,11 @@ fn test_digest() -> Result<(), Error> {
let read_dir = test_dir.join("sources.list.d");
let write_dir = tmp_dir.join("sources.list.d.digest");
+ if write_dir.is_dir() {
+ std::fs::remove_dir_all(&write_dir)
+ .map_err(|err| format_err!("unable to remove dir {:?} - {}", write_dir, err))?;
+ }
+
std::fs::create_dir_all(&write_dir)
.map_err(|err| format_err!("unable to create dir {:?} - {}", write_dir, err))?;
--
2.39.2
More information about the pve-devel
mailing list