Skip to content

Commit

Permalink
tests: add --testrunner flag so that column tests dont fail on startup
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jb55 committed Dec 13, 2024
1 parent 3999ab4 commit 3601160
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions crates/notedeck/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ pub struct Args {
pub keys: Vec<Keypair>,
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<String>,
pub datapath: Option<String>,
Expand All @@ -20,6 +24,7 @@ impl Args {
keys: vec![],
light: false,
debug: false,
tests: false,
use_keystore: true,
dbpath: None,
datapath: None,
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion crates/notedeck_chrome/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
2 changes: 2 additions & 0 deletions crates/notedeck_chrome/src/notedeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ mod tests {
let datapath = create_tmp_dir();
let dbpath = create_tmp_dir();
let args: Vec<String> = vec![
"--testrunner",
"--datapath",
&datapath.to_str().unwrap(),
"--dbpath",
Expand All @@ -155,6 +156,7 @@ mod tests {
let tmpdir = create_tmp_dir();
let npub = "npub1xtscya34g58tk0z605fvr788k263gsu6cy9x0mhnm87echrgufzsevkk5s";
let args: Vec<String> = vec![
"--testrunner",
"--no-keystore",
"--pub",
npub,
Expand Down

0 comments on commit 3601160

Please sign in to comment.