This allows to create custom runtime environment files for tests to use
instead of the common one, to allow testing codepaths which depend on
certain runtime-gathered values.

Signed-off-by: Christoph Heiss <c.he...@proxmox.com>
---
 proxmox-auto-installer/tests/parse-answer.rs | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/proxmox-auto-installer/tests/parse-answer.rs 
b/proxmox-auto-installer/tests/parse-answer.rs
index 39b9401..6d5f228 100644
--- a/proxmox-auto-installer/tests/parse-answer.rs
+++ b/proxmox-auto-installer/tests/parse-answer.rs
@@ -47,7 +47,12 @@ fn setup_test_basic(path: impl AsRef<Path>) -> (SetupInfo, 
LocaleInfo, RuntimeIn
 
 fn run_named_test(name: &str) {
     let resource_path = get_test_resource_path().unwrap();
-    let (setup_info, locales, runtime_info, udev_info) = 
setup_test_basic(&resource_path);
+    let (setup_info, locales, mut runtime_info, udev_info) = 
setup_test_basic(&resource_path);
+
+    let test_run_env_path = 
resource_path.join(format!("parse_answer/{name}.run-env.json"));
+    if test_run_env_path.exists() {
+        runtime_info = read_json(test_run_env_path).unwrap()
+    }
 
     let answer_path = resource_path.join(format!("parse_answer/{name}.toml"));
 
@@ -65,7 +70,12 @@ fn run_named_test(name: &str) {
 
 fn run_named_fail_parse_test(name: &str) {
     let resource_path = get_test_resource_path().unwrap();
-    let (setup_info, locales, runtime_info, udev_info) = 
setup_test_basic(&resource_path);
+    let (setup_info, locales, mut runtime_info, udev_info) = 
setup_test_basic(&resource_path);
+
+    let test_run_env_path = 
resource_path.join(format!("parse_answer_fail/{name}.run-env.json"));
+    if test_run_env_path.exists() {
+        runtime_info = read_json(test_run_env_path).unwrap()
+    }
 
     let answer_path = 
resource_path.join(format!("parse_answer_fail/{name}.toml"));
 
-- 
2.48.1



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to