public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH installer] tui: honor test mode flag when starting low-level install session
@ 2023-09-20 11:39 Christoph Heiss
  2023-09-20 14:33 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Heiss @ 2023-09-20 11:39 UTC (permalink / raw)
  To: pve-devel

Even if the installer is run in release mode, the test-mode flag should
be honored on whether to start a test-installation or not.

The test mode is always forced on in debug builds, so the cfg()
conditionals can be dropped.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
 proxmox-tui-installer/src/main.rs | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/proxmox-tui-installer/src/main.rs b/proxmox-tui-installer/src/main.rs
index 23a4ead..3f01713 100644
--- a/proxmox-tui-installer/src/main.rs
+++ b/proxmox-tui-installer/src/main.rs
@@ -727,6 +727,7 @@ fn install_progress_dialog(siv: &mut Cursive) -> InstallerView {
 
     let cb_sink = siv.cb_sink().clone();
     let state = siv.user_data::<InstallerState>().unwrap();
+    let in_test_mode = state.in_test_mode;
     let progress_text = TextContent::new("starting the installation ..");
 
     let progress_task = {
@@ -736,16 +737,15 @@ fn install_progress_dialog(siv: &mut Cursive) -> InstallerView {
             let child = {
                 use std::process::{Command, Stdio};
 
-                #[cfg(not(debug_assertions))]
-                let (path, args, envs): (&str, [&str; 1], [(&str, &str); 0]) =
-                    ("proxmox-low-level-installer", ["start-session"], []);
-
-                #[cfg(debug_assertions)]
-                let (path, args, envs) = (
-                    PathBuf::from("./proxmox-low-level-installer"),
-                    ["-t", "start-session-test"],
-                    [("PERL5LIB", ".")],
-                );
+                let (path, args, envs): (&str, &[&str], Vec<(&str, &str)>) = if in_test_mode {
+                    (
+                        "./proxmox-low-level-installer",
+                        &["-t", "start-session-test"],
+                        vec![("PERL5LIB", ".")],
+                    )
+                } else {
+                    ("proxmox-low-level-installer", &["start-session"], vec![])
+                };
 
                 Command::new(path)
                     .args(args)
-- 
2.41.0





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: [PATCH installer] tui: honor test mode flag when starting low-level install session
  2023-09-20 11:39 [pve-devel] [PATCH installer] tui: honor test mode flag when starting low-level install session Christoph Heiss
@ 2023-09-20 14:33 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-09-20 14:33 UTC (permalink / raw)
  To: Proxmox VE development discussion, Christoph Heiss

Am 20/09/2023 um 13:39 schrieb Christoph Heiss:
> Even if the installer is run in release mode, the test-mode flag should
> be honored on whether to start a test-installation or not.
> 
> The test mode is always forced on in debug builds, so the cfg()
> conditionals can be dropped.
> 
> Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
> ---
>  proxmox-tui-installer/src/main.rs | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
>

applied, thanks!

albeit not sure if returning that tuple is that nice, maybe something like

    let exe = match in_test_mode {
        true => "./proxmox-low-level-installer",
        false => "proxmox-low-level-installer",
    };

    let mut cmd = Command::new(exe);
    if choice {
        cmd.args(&["-t", "start-session"])
            .envs(vec![("PERL5LIB", ".")]);
    } else {
        cmd.args(&["start-session"]);
    };

    cmd.stdin(Stdio::piped()).stdout(Stdio::piped()).spawn();


would be nicer, even if slightly longer (possible it can be even written shorter).
But no hard feelings, it's not like this is complicated code or the like.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-20 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-20 11:39 [pve-devel] [PATCH installer] tui: honor test mode flag when starting low-level install session Christoph Heiss
2023-09-20 14:33 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal