From 360116030c88d4832481d049f8e776547bc1fd26 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Fri, 13 Dec 2024 09:57:47 -0800 Subject: [PATCH] tests: add --testrunner flag so that column tests dont fail on startup We added a startup panic to prevent users from running as debug mode, our tests are also hitting this. Add a new --testrunner flag which skips this check. We want this separate from the --debug flag so that the tests have a more consistent runtime environment. Signed-off-by: William Casarin --- crates/notedeck/src/args.rs | 7 +++++++ crates/notedeck_chrome/src/app.rs | 2 +- crates/notedeck_chrome/src/notedeck.rs | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/notedeck/src/args.rs b/crates/notedeck/src/args.rs index ed265e13..b9b87bc3 100644 --- a/crates/notedeck/src/args.rs +++ b/crates/notedeck/src/args.rs @@ -7,6 +7,10 @@ pub struct Args { pub keys: Vec, pub light: bool, pub debug: bool, + + /// Enable when running tests so we don't panic on app startup + pub tests: bool, + pub use_keystore: bool, pub dbpath: Option, pub datapath: Option, @@ -20,6 +24,7 @@ impl Args { keys: vec![], light: false, debug: false, + tests: false, use_keystore: true, dbpath: None, datapath: None, @@ -38,6 +43,8 @@ impl Args { res.light = false; } else if arg == "--debug" { res.debug = true; + } else if arg == "--testrunner" { + res.tests = true; } else if arg == "--pub" || arg == "--npub" { i += 1; let pubstr = if let Some(next_arg) = args.get(i) { diff --git a/crates/notedeck_chrome/src/app.rs b/crates/notedeck_chrome/src/app.rs index cee0a55b..35c09551 100644 --- a/crates/notedeck_chrome/src/app.rs +++ b/crates/notedeck_chrome/src/app.rs @@ -55,7 +55,7 @@ impl Notedeck { .unwrap_or(notedeck::ui::is_compiled_as_mobile()); // Some people have been running notedeck in debug, let's catch that! - if !cfg!(test) && cfg!(debug_assertions) && !parsed_args.debug { + if !parsed_args.tests && cfg!(debug_assertions) && !parsed_args.debug { println!("--- WELCOME TO DAMUS NOTEDECK! ---"); println!("It looks like are running notedeck in debug mode, unless you are a developer, this is not likely what you want."); println!("If you are a developer, run `cargo run -- --debug` to skip this message."); diff --git a/crates/notedeck_chrome/src/notedeck.rs b/crates/notedeck_chrome/src/notedeck.rs index 74a8c319..9115e087 100644 --- a/crates/notedeck_chrome/src/notedeck.rs +++ b/crates/notedeck_chrome/src/notedeck.rs @@ -130,6 +130,7 @@ mod tests { let datapath = create_tmp_dir(); let dbpath = create_tmp_dir(); let args: Vec = vec![ + "--testrunner", "--datapath", &datapath.to_str().unwrap(), "--dbpath", @@ -155,6 +156,7 @@ mod tests { let tmpdir = create_tmp_dir(); let npub = "npub1xtscya34g58tk0z605fvr788k263gsu6cy9x0mhnm87echrgufzsevkk5s"; let args: Vec = vec![ + "--testrunner", "--no-keystore", "--pub", npub,