* [pve-devel] [PATCH proxmox] apt: tests: remove output directories before running test
@ 2023-06-05 15:26 Fiona Ebner
2023-09-07 8:30 ` [pve-devel] superseded: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Fiona Ebner @ 2023-06-05 15:26 UTC (permalink / raw)
To: pve-devel
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@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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-07 8:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-05 15:26 [pve-devel] [PATCH proxmox] apt: tests: remove output directories before running test Fiona Ebner
2023-09-07 8:30 ` [pve-devel] superseded: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox