From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox] apt: tests: remove output directories before running test
Date: Mon, 5 Jun 2023 17:26:46 +0200 [thread overview]
Message-ID: <20230605152646.178768-1-f.ebner@proxmox.com> (raw)
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
next reply other threads:[~2023-06-05 15:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-05 15:26 Fiona Ebner [this message]
2023-09-07 8:30 ` [pve-devel] superseded: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230605152646.178768-1-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox