diff --git a/e2e/tests/binds.rs b/e2e/tests/binds.rs index 8ed18440..a550a597 100644 --- a/e2e/tests/binds.rs +++ b/e2e/tests/binds.rs @@ -54,7 +54,7 @@ fn bind_append_and_select() -> Result<()> { let tmux = setup("a\\n\\nb\\nc", &["-m", "--bind", "'ctrl-f:append-and-select'"])?; tmux.send_keys(&[Str("xyz"), Ctrl(&Key('f'))])?; - tmux.until(|l| l[2] == ">>xyz")?; + tmux.until(|l| l.len() > 2 && l[2] == ">>xyz")?; Ok(()) } @@ -70,7 +70,7 @@ fn bind_reload_no_arg() -> Result<()> { tmux.until(|l| l[0].starts_with(">"))?; tmux.send_keys(&[Ctrl(&Key('a'))])?; - tmux.until(|l| l[2] == "> hello")?; + tmux.until(|l| l.len() > 2 && l[2] == "> hello")?; Ok(()) } @@ -79,9 +79,9 @@ fn bind_reload_no_arg() -> Result<()> { fn bind_reload_cmd() -> Result<()> { let tmux = setup("a\\n\\nb\\nc", &["--bind", "'ctrl-a:reload(echo hello)'"])?; - tmux.until(|l| l[2] == "> a")?; + tmux.until(|l| l.len() > 2 && l[2] == "> a")?; tmux.send_keys(&[Ctrl(&Key('a'))])?; - tmux.until(|l| l[2] == "> hello")?; + tmux.until(|l| l.len() > 2 && l[2] == "> hello")?; Ok(()) } diff --git a/e2e/tests/case.rs b/e2e/tests/case.rs index 961ba175..080e8720 100644 --- a/e2e/tests/case.rs +++ b/e2e/tests/case.rs @@ -14,21 +14,21 @@ fn case_smart_lower() -> Result<()> { let tmux = setup("smart")?; tmux.send_keys(&[Str("abc")])?; - tmux.until(|l| l[1].trim().starts_with("1/1")) + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1")) } #[test] fn case_smart_exact() -> Result<()> { let tmux = setup("smart")?; tmux.send_keys(&[Str("aBc")])?; - tmux.until(|l| l[1].trim().starts_with("1/1")) + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1")) } #[test] fn case_smart_no_match() -> Result<()> { let tmux = setup("smart")?; tmux.send_keys(&[Str("Abc")])?; - tmux.until(|l| l[1].trim().starts_with("0/1")) + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1")) } #[test] @@ -36,28 +36,28 @@ fn case_ignore_lower() -> Result<()> { let tmux = setup("ignore")?; tmux.send_keys(&[Str("abc")])?; - tmux.until(|l| l[1].trim().starts_with("1/1")) + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1")) } #[test] fn case_ignore_exact() -> Result<()> { let tmux = setup("ignore")?; tmux.send_keys(&[Str("aBc")])?; - tmux.until(|l| l[1].trim().starts_with("1/1")) + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1")) } #[test] fn case_ignore_different() -> Result<()> { let tmux = setup("ignore")?; tmux.send_keys(&[Str("Abc")])?; - tmux.until(|l| l[1].trim().starts_with("1/1")) + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1")) } #[test] fn case_ignore_no_match() -> Result<()> { let tmux = setup("ignore")?; tmux.send_keys(&[Str("z")])?; - tmux.until(|l| l[1].trim().starts_with("0/1")) + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1")) } #[test] @@ -65,19 +65,19 @@ fn case_respect_lower() -> Result<()> { let tmux = setup("respect")?; tmux.send_keys(&[Str("abc")])?; - tmux.until(|l| l[1].trim().starts_with("0/1")) + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1")) } #[test] fn case_respect_exact() -> Result<()> { let tmux = setup("respect")?; tmux.send_keys(&[Str("aBc")])?; - tmux.until(|l| l[1].trim().starts_with("1/1")) + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1")) } #[test] fn case_respect_no_match() -> Result<()> { let tmux = setup("respect")?; tmux.send_keys(&[Str("Abc")])?; - tmux.until(|l| l[1].trim().starts_with("0/1")) + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1")) } diff --git a/e2e/tests/defaults.rs b/e2e/tests/defaults.rs index 13c2472c..88a7e788 100644 --- a/e2e/tests/defaults.rs +++ b/e2e/tests/defaults.rs @@ -24,8 +24,8 @@ fn default_command() -> Result<()> { let sk_cmd = sk(&outfile, &[]).replace("SKIM_DEFAULT_COMMAND=", "SKIM_DEFAULT_COMMAND='echo hello'"); tmux.send_keys(&[Keys::Str(&sk_cmd), Keys::Enter])?; tmux.until(|l| l[0].starts_with(">"))?; - tmux.until(|l| l[1].starts_with(" 1/1"))?; - tmux.until(|l| l[2] == "> hello")?; + tmux.until(|l| l.len() > 1 && l[1].starts_with(" 1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> hello")?; tmux.send_keys(&[Keys::Enter])?; tmux.until(|l| !l[0].starts_with(">"))?; diff --git a/e2e/tests/keys.rs b/e2e/tests/keys.rs index 91703480..4b886a9c 100644 --- a/e2e/tests/keys.rs +++ b/e2e/tests/keys.rs @@ -15,8 +15,8 @@ fn keys_basic() -> Result<()> { tmux.until(|l| l[0].starts_with(">") && l[1].starts_with(" 100000"))?; tmux.send_keys(&[Str("99")])?; tmux.until(|l| l[0] == "> 99")?; - tmux.until(|l| l[1].starts_with(" 8146/100000"))?; - tmux.until(|l| l[2] == "> 99")?; + tmux.until(|l| l.len() > 1 && l[1].starts_with(" 8146/100000"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> 99")?; Ok(()) } @@ -193,8 +193,8 @@ fn keys_ctrl_k() -> Result<()> { let _ = tmux.start_sk(Some("seq 1 100000"), &[]); tmux.until(|l| l[0].starts_with(">") && l[1].starts_with(" 100000"))?; tmux.send_keys(&[Ctrl(&Key('k'))])?; - tmux.until(|l| l[2] == " 1")?; - tmux.until(|l| l[3] == "> 2")?; + tmux.until(|l| l.len() > 2 && l[2] == " 1")?; + tmux.until(|l| l.len() > 3 && l[3] == "> 2")?; Ok(()) } @@ -205,12 +205,12 @@ fn keys_tab() -> Result<()> { let _ = tmux.start_sk(Some("seq 1 100000"), &[]); tmux.until(|l| l[0].starts_with(">") && l[1].starts_with(" 100000"))?; tmux.send_keys(&[Ctrl(&Key('k'))])?; - tmux.until(|l| l[2] == " 1")?; - tmux.until(|l| l[3] == "> 2")?; + tmux.until(|l| l.len() > 2 && l[2] == " 1")?; + tmux.until(|l| l.len() > 3 && l[3] == "> 2")?; tmux.send_keys(&[Tab])?; - tmux.until(|l| l[2] == "> 1")?; - tmux.until(|l| l[3] == " 2")?; + tmux.until(|l| l.len() > 2 && l[2] == "> 1")?; + tmux.until(|l| l.len() > 3 && l[3] == " 2")?; Ok(()) } @@ -221,8 +221,8 @@ fn keys_btab() -> Result<()> { let _ = tmux.start_sk(Some("seq 1 100000"), &[]); tmux.until(|l| l[0].starts_with(">") && l[1].starts_with(" 100000"))?; tmux.send_keys(&[BTab])?; - tmux.until(|l| l[2] == " 1")?; - tmux.until(|l| l[3] == "> 2")?; + tmux.until(|l| l.len() > 2 && l[2] == " 1")?; + tmux.until(|l| l.len() > 3 && l[3] == "> 2")?; Ok(()) } diff --git a/e2e/tests/keys_interactive.rs b/e2e/tests/keys_interactive.rs index c3920583..107de557 100644 --- a/e2e/tests/keys_interactive.rs +++ b/e2e/tests/keys_interactive.rs @@ -15,8 +15,8 @@ fn keys_interactive_basic() -> Result<()> { tmux.until(|l| l[0].starts_with("c>") && l[1].starts_with(" 100000"))?; tmux.send_keys(&[Str("99")])?; tmux.until(|l| l[0] == "c> 99")?; - tmux.until(|l| l[1].starts_with(" 100000/100000"))?; - tmux.until(|l| l[2] == "> 1")?; + tmux.until(|l| l.len() > 1 && l[1].starts_with(" 100000/100000"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> 1")?; Ok(()) } @@ -193,8 +193,8 @@ fn keys_interactive_ctrl_k() -> Result<()> { let _ = tmux.start_sk(Some("seq 1 100000"), &["-i"]); tmux.until(|l| l[0].starts_with("c>") && l[1].starts_with(" 100000"))?; tmux.send_keys(&[Ctrl(&Key('k'))])?; - tmux.until(|l| l[2] == " 1")?; - tmux.until(|l| l[3] == "> 2")?; + tmux.until(|l| l.len() > 2 && l[2] == " 1")?; + tmux.until(|l| l.len() > 3 && l[3] == "> 2")?; Ok(()) } @@ -205,12 +205,12 @@ fn keys_interactive_tab() -> Result<()> { let _ = tmux.start_sk(Some("seq 1 100000"), &["-i"]); tmux.until(|l| l[0].starts_with("c>") && l[1].starts_with(" 100000"))?; tmux.send_keys(&[Ctrl(&Key('k'))])?; - tmux.until(|l| l[2] == " 1")?; - tmux.until(|l| l[3] == "> 2")?; + tmux.until(|l| l.len() > 2 && l[2] == " 1")?; + tmux.until(|l| l.len() > 3 && l[3] == "> 2")?; tmux.send_keys(&[Tab])?; - tmux.until(|l| l[2] == "> 1")?; - tmux.until(|l| l[3] == " 2")?; + tmux.until(|l| l.len() > 2 && l[2] == "> 1")?; + tmux.until(|l| l.len() > 3 && l[3] == " 2")?; Ok(()) } @@ -221,8 +221,8 @@ fn keys_interactive_btab() -> Result<()> { let _ = tmux.start_sk(Some("seq 1 100000"), &["-i"]); tmux.until(|l| l[0].starts_with("c>") && l[1].starts_with(" 100000"))?; tmux.send_keys(&[BTab])?; - tmux.until(|l| l[2] == " 1")?; - tmux.until(|l| l[3] == "> 2")?; + tmux.until(|l| l.len() > 2 && l[2] == " 1")?; + tmux.until(|l| l.len() > 3 && l[3] == "> 2")?; Ok(()) } diff --git a/e2e/tests/options.rs b/e2e/tests/options.rs index c0aaf646..f8eeb4b5 100644 --- a/e2e/tests/options.rs +++ b/e2e/tests/options.rs @@ -53,7 +53,7 @@ fn opt_with_nth_preview() -> Result<()> { fn opt_with_nth_1() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--with-nth", "1"])?; - tmux.until(|l| l[2] == "> f1,")?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,")?; Ok(()) } @@ -61,7 +61,7 @@ fn opt_with_nth_1() -> Result<()> { fn opt_with_nth_2() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--with-nth", "2"])?; - tmux.until(|l| l[2] == "> f2,")?; + tmux.until(|l| l.len() > 2 && l[2] == "> f2,")?; Ok(()) } @@ -69,7 +69,7 @@ fn opt_with_nth_2() -> Result<()> { fn opt_with_nth_4() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--with-nth", "4"])?; - tmux.until(|l| l[2] == "> f4")?; + tmux.until(|l| l.len() > 2 && l[2] == "> f4")?; Ok(()) } @@ -77,7 +77,7 @@ fn opt_with_nth_4() -> Result<()> { fn opt_with_nth_oob() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--with-nth", "5"])?; - tmux.until(|l| l[2] == ">")?; + tmux.until(|l| l.len() > 2 && l[2] == ">")?; Ok(()) } @@ -85,7 +85,7 @@ fn opt_with_nth_oob() -> Result<()> { fn opt_with_nth_neg_1() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--with-nth=-1"])?; - tmux.until(|l| l[2] == "> f4")?; + tmux.until(|l| l.len() > 2 && l[2] == "> f4")?; Ok(()) } @@ -93,7 +93,7 @@ fn opt_with_nth_neg_1() -> Result<()> { fn opt_with_nth_neg_2() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--with-nth=-2"])?; - tmux.until(|l| l[2] == "> f3,")?; + tmux.until(|l| l.len() > 2 && l[2] == "> f3,")?; Ok(()) } @@ -101,7 +101,7 @@ fn opt_with_nth_neg_2() -> Result<()> { fn opt_with_nth_neg_4() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--with-nth=-4"])?; - tmux.until(|l| l[2] == "> f1,")?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,")?; Ok(()) } @@ -109,7 +109,7 @@ fn opt_with_nth_neg_4() -> Result<()> { fn opt_with_nth_neg_oob() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--with-nth=-5"])?; - tmux.until(|l| l[2] == ">")?; + tmux.until(|l| l.len() > 2 && l[2] == ">")?; Ok(()) } @@ -117,7 +117,7 @@ fn opt_with_nth_neg_oob() -> Result<()> { fn opt_with_nth_range_to_end() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--with-nth", "2.."])?; - tmux.until(|l| l[2] == "> f2,f3,f4")?; + tmux.until(|l| l.len() > 2 && l[2] == "> f2,f3,f4")?; Ok(()) } @@ -125,7 +125,7 @@ fn opt_with_nth_range_to_end() -> Result<()> { fn opt_with_nth_range_from_start() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--with-nth", "..3"])?; - tmux.until(|l| l[2] == "> f1,f2,f3,")?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,")?; Ok(()) } @@ -133,7 +133,7 @@ fn opt_with_nth_range_from_start() -> Result<()> { fn opt_with_nth_range_closed() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--with-nth", "2..3"])?; - tmux.until(|l| l[2] == "> f2,f3,")?; + tmux.until(|l| l.len() > 2 && l[2] == "> f2,f3,")?; Ok(()) } @@ -141,7 +141,7 @@ fn opt_with_nth_range_closed() -> Result<()> { fn opt_with_nth_range_dec() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--with-nth", "3..2"])?; - tmux.until(|l| l[2] == ">")?; + tmux.until(|l| l.len() > 2 && l[2] == ">")?; Ok(()) } @@ -152,15 +152,15 @@ fn opt_nth_1() -> Result<()> { tmux.send_keys(&[Str("1")])?; tmux.until(|l| l[0] == "> 1")?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Ctrl(&Key('w'))])?; tmux.until(|l| l[0] == ">")?; tmux.send_keys(&[Str("2")])?; tmux.until(|l| l[0] == "> 2")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; Ok(()) } @@ -170,15 +170,15 @@ fn opt_nth_2() -> Result<()> { tmux.send_keys(&[Str("2")])?; tmux.until(|l| l[0] == "> 2")?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Ctrl(&Key('w'))])?; tmux.until(|l| l[0] == ">")?; tmux.send_keys(&[Str("1")])?; tmux.until(|l| l[0] == "> 1")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; Ok(()) } @@ -188,15 +188,15 @@ fn opt_nth_4() -> Result<()> { tmux.send_keys(&[Str("4")])?; tmux.until(|l| l[0] == "> 4")?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Ctrl(&Key('w'))])?; tmux.until(|l| l[0] == ">")?; tmux.send_keys(&[Str("1")])?; tmux.until(|l| l[0] == "> 1")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; Ok(()) } @@ -204,12 +204,12 @@ fn opt_nth_4() -> Result<()> { fn opt_nth_oob() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--nth", "5"])?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Str("1")])?; tmux.until(|l| l[0] == "> 1")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; Ok(()) } @@ -219,15 +219,15 @@ fn opt_nth_neg_1() -> Result<()> { tmux.send_keys(&[Str("4")])?; tmux.until(|l| l[0] == "> 4")?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Ctrl(&Key('w'))])?; tmux.until(|l| l[0] == ">")?; tmux.send_keys(&[Str("1")])?; tmux.until(|l| l[0] == "> 1")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; Ok(()) } @@ -237,15 +237,15 @@ fn opt_nth_neg_2() -> Result<()> { tmux.send_keys(&[Str("3")])?; tmux.until(|l| l[0] == "> 3")?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Ctrl(&Key('w'))])?; tmux.until(|l| l[0] == ">")?; tmux.send_keys(&[Str("1")])?; tmux.until(|l| l[0] == "> 1")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; Ok(()) } @@ -255,15 +255,15 @@ fn opt_nth_neg_4() -> Result<()> { tmux.send_keys(&[Str("1")])?; tmux.until(|l| l[0] == "> 1")?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Ctrl(&Key('w'))])?; tmux.until(|l| l[0] == ">")?; tmux.send_keys(&[Str("2")])?; tmux.until(|l| l[0] == "> 2")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; Ok(()) } @@ -271,12 +271,12 @@ fn opt_nth_neg_4() -> Result<()> { fn opt_nth_neg_oob() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--nth=-5"])?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Str("1")])?; tmux.until(|l| l[0] == "> 1")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; Ok(()) } @@ -286,15 +286,15 @@ fn opt_nth_range_to_end() -> Result<()> { tmux.send_keys(&[Str("3")])?; tmux.until(|l| l[0] == "> 3")?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Ctrl(&Key('w'))])?; tmux.until(|l| l[0] == ">")?; tmux.send_keys(&[Str("1")])?; tmux.until(|l| l[0] == "> 1")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; Ok(()) } @@ -304,15 +304,15 @@ fn opt_nth_range_from_start() -> Result<()> { tmux.send_keys(&[Str("1")])?; tmux.until(|l| l[0] == "> 1")?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Ctrl(&Key('w'))])?; tmux.until(|l| l[0] == ">")?; tmux.send_keys(&[Str("4")])?; tmux.until(|l| l[0] == "> 4")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; Ok(()) } @@ -322,42 +322,42 @@ fn opt_nth_range_closed() -> Result<()> { tmux.send_keys(&[Str("2")])?; tmux.until(|l| l[0] == "> 2")?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Ctrl(&Key('w'))])?; tmux.until(|l| l[0] == ">")?; tmux.send_keys(&[Str("3")])?; tmux.until(|l| l[0] == "> 3")?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Ctrl(&Key('w'))])?; tmux.until(|l| l[0] == ">")?; tmux.send_keys(&[Str("1")])?; tmux.until(|l| l[0] == "> 1")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; tmux.send_keys(&[Ctrl(&Key('w'))])?; tmux.until(|l| l[0] == ">")?; tmux.send_keys(&[Str("4")])?; tmux.until(|l| l[0] == "> 4")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; Ok(()) } #[test] fn opt_nth_range_dec() -> Result<()> { let (tmux, _) = setup("f1,f2,f3,f4", &["--delimiter", ",", "--nth", "3..2"])?; - tmux.until(|l| l[1].trim().starts_with("1/1"))?; - tmux.until(|l| l[2] == "> f1,f2,f3,f4")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("1/1"))?; + tmux.until(|l| l.len() > 2 && l[2] == "> f1,f2,f3,f4")?; tmux.send_keys(&[Str("1")])?; tmux.until(|l| l[0] == "> 1")?; - tmux.until(|l| l[1].trim().starts_with("0/1"))?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/1"))?; Ok(()) } @@ -407,7 +407,7 @@ fn opt_print_cmd_and_query() -> Result<()> { fn opt_hscroll_begin() -> Result<()> { let (tmux, _) = setup(&format!("b{}", &["a"; 1000].join("")), &["-q", "b"])?; - tmux.until(|l| l[2].ends_with("..")) + tmux.until(|l| l.len() > 2 && l[2].ends_with("..")) } #[test] fn opt_hscroll_middle() -> Result<()> { @@ -416,41 +416,41 @@ fn opt_hscroll_middle() -> Result<()> { &["-q", "b"], )?; - tmux.until(|l| l[2].ends_with(".."))?; - tmux.until(|l| l[2].starts_with("> ..")) + tmux.until(|l| l.len() > 2 && l[2].ends_with(".."))?; + tmux.until(|l| l.len() > 2 && l[2].starts_with("> ..")) } #[test] fn opt_hscroll_end() -> Result<()> { let (tmux, _) = setup(&format!("{}b", &["a"; 1000].join("")), &["-q", "b"])?; - tmux.until(|l| l[2].starts_with("> ..")) + tmux.until(|l| l.len() > 2 && l[2].starts_with("> ..")) } #[test] fn opt_no_hscroll() -> Result<()> { let (tmux, _) = setup(&format!("{}b", &["a"; 1000].join("")), &["-q", "b", "--no-hscroll"])?; - tmux.until(|l| !l[2].starts_with("> .."))?; - tmux.until(|l| l[2].ends_with("..")) + tmux.until(|l| !l.len() > 2 && l[2].starts_with("> .."))?; + tmux.until(|l| l.len() > 2 && l[2].ends_with("..")) } #[test] fn opt_tabstop_default() -> Result<()> { let (tmux, _) = setup("a\\tb", &[])?; - tmux.until(|l| l[2].trim() == "> a b") + tmux.until(|l| l.len() > 2 && l[2].trim() == "> a b") } #[test] fn opt_tabstop_1() -> Result<()> { let (tmux, _) = setup("a\\tb", &["--tabstop", "1"])?; - tmux.until(|l| l[2].trim() == "> a b") + tmux.until(|l| l.len() > 2 && l[2].trim() == "> a b") } #[test] fn opt_tabstop_3() -> Result<()> { let (tmux, _) = setup("aa\\tb", &["--tabstop", "3"])?; - tmux.until(|l| l[2].trim() == "> aa b") + tmux.until(|l| l.len() > 2 && l[2].trim() == "> aa b") } #[test] @@ -467,13 +467,13 @@ fn opt_inline_info() -> Result<()> { fn opt_header_only() -> Result<()> { let (tmux, _) = setup("a\\nb\\nc", &["--header", "test_header"])?; - tmux.until(|l| l[2].trim() == "test_header") + tmux.until(|l| l.len() > 2 && l[2].trim() == "test_header") } #[test] fn opt_header_inline_info() -> Result<()> { let (tmux, _) = setup("a\\nb\\nc", &["--header", "test_header", "--inline-info"])?; - tmux.until(|l| l[1].trim() == "test_header") + tmux.until(|l| l.len() > 1 && l[1].trim() == "test_header") } #[test] fn opt_header_reverse() -> Result<()> { @@ -505,7 +505,7 @@ fn opt_header_lines_1() -> Result<()> { let (tmux, _) = setup("a\\nb\\nc", &["--header-lines", "1"])?; tmux.until(|l| !l[2].starts_with(">") && l[2].trim() == "a")?; - tmux.until(|l| l[3].starts_with(">")) + tmux.until(|l| l.len() > 3 && l[3].starts_with(">")) } #[test] fn opt_header_lines_all() -> Result<()> { @@ -699,13 +699,13 @@ fn opt_multiple_flags_combined_nth() -> Result<()> { let (tmux, _) = setup("a b c\\nd e f", &["--nth 1,2"])?; tmux.send_keys(&[Key('c')])?; - tmux.until(|l| l[1].contains("0/2")) + tmux.until(|l| l.len() > 1 && l[1].contains("0/2")) } #[test] fn opt_multiple_flags_combined_with_nth() -> Result<()> { let (tmux, _) = setup("a b c\\nd e f", &["--with-nth 1,2"])?; - tmux.until(|l| l[2].ends_with("a b") && l[3].ends_with("d e")) + tmux.until(|l| l.len() > 2 && l[2].ends_with("a b") && l[3].ends_with("d e")) } #[test] @@ -724,7 +724,7 @@ fn opt_ansi_null() -> Result<()> { fn opt_skip_to_pattern() -> Result<()> { let (tmux, _) = setup("a/b/c", &["--skip-to-pattern", "'[^/]*$'"])?; - tmux.until(|l| l[2] == "> ..c") + tmux.until(|l| l.len() > 2 && l[2] == "> ..c") } #[test] @@ -732,7 +732,7 @@ fn opt_multi() -> Result<()> { let (tmux, outfile) = setup("a\\nb\\nc", &["--multi"])?; tmux.send_keys(&[BTab, BTab])?; - tmux.until(|l| l[2] == " >a" && l[3] == " >b")?; + tmux.until(|l| l.len() > 2 && l[2] == " >a" && l[3] == " >b")?; tmux.send_keys(&[Enter])?; let output = tmux.output(&outfile)?; @@ -746,19 +746,19 @@ fn opt_multi() -> Result<()> { #[test] fn opt_pre_select_n() -> Result<()> { let (tmux, _) = setup("a\\nb\\nc", &["-m", "--pre-select-n", "2"])?; - tmux.until(|l| l[2] == ">>a" && l[3] == " >b") + tmux.until(|l| l.len() > 2 && l[2] == ">>a" && l[3] == " >b") } #[test] fn opt_pre_select_items() -> Result<()> { let (tmux, _) = setup("a\\nb\\nc", &["-m", "--pre-select-items", "$'b\\nc'"])?; - tmux.until(|l| l[2] == "> a" && l[3].trim() == ">b" && l[4].trim() == ">c") + tmux.until(|l| l.len() > 2 && l[2] == "> a" && l[3].trim() == ">b" && l[4].trim() == ">c") } #[test] fn opt_pre_select_pat() -> Result<()> { let (tmux, _) = setup("a\\nb\\nc", &["-m", "--pre-select-pat", "'[b|c]'"])?; - tmux.until(|l| l[2] == "> a" && l[3].trim() == ">b" && l[4].trim() == ">c") + tmux.until(|l| l.len() > 2 && l[2] == "> a" && l[3].trim() == ">b" && l[4].trim() == ">c") } #[test] @@ -769,7 +769,7 @@ fn opt_pre_select_file() -> Result<()> { "a\\nb\\nc", &["-m", "--pre-select-file", pre_select_file.path().to_str().unwrap()], )?; - tmux.until(|l| l[2] == "> a" && l[3].trim() == ">b" && l[4].trim() == ">c") + tmux.until(|l| l.len() > 2 && l[2] == "> a" && l[3].trim() == ">b" && l[4].trim() == ">c") } #[test] @@ -784,9 +784,9 @@ fn opt_no_clear_if_empty() -> Result<()> { tmux.send_keys(&[Str("xxxx")])?; tmux.until(|l| l[0] == "c> xxxx")?; - tmux.until(|l| l[1].trim().starts_with("0/0"))?; - tmux.until(|l| l[2].trim() == "> a")?; - tmux.until(|l| l[3].trim() == "b")?; + tmux.until(|l| l.len() > 1 && l[1].trim().starts_with("0/0"))?; + tmux.until(|l| l.len() > 2 && l[2].trim() == "> a")?; + tmux.until(|l| l.len() > 3 && l[3].trim() == "b")?; Ok(()) } diff --git a/e2e/tests/tiebreak.rs b/e2e/tests/tiebreak.rs index 95343283..8d4034d2 100644 --- a/e2e/tests/tiebreak.rs +++ b/e2e/tests/tiebreak.rs @@ -15,74 +15,74 @@ fn setup(input: &str, tiebreak: &str) -> Result { #[test] fn tiebreak_default() -> Result<()> { let tmux = setup("a\\nc\\nab\\nac\\nb", "score,begin,end")?; - tmux.until(|l| l[2].starts_with("> a"))?; + tmux.until(|l| l.len() > 2 && l[2].starts_with("> a"))?; tmux.send_keys(&[Key('b')])?; - tmux.until(|l| l[2].starts_with("> b")) + tmux.until(|l| l.len() > 2 && l[2].starts_with("> b")) } #[test] fn tiebreak_neg_score() -> Result<()> { let tmux = setup("a\\nb\\nc\\nab\\nac", "-score")?; - tmux.until(|l| l[2].starts_with("> a"))?; + tmux.until(|l| l.len() > 2 && l[2].starts_with("> a"))?; tmux.send_keys(&[Key('b')])?; - tmux.until(|l| l[2].starts_with("> ab")) + tmux.until(|l| l.len() > 2 && l[2].starts_with("> ab")) } #[test] fn tiebreak_index() -> Result<()> { let tmux = setup("a\\nc\\nab\\nac\\nb", "index,score")?; - tmux.until(|l| l[2].starts_with("> a"))?; + tmux.until(|l| l.len() > 2 && l[2].starts_with("> a"))?; tmux.send_keys(&[Key('b')])?; - tmux.until(|l| l[2].starts_with("> ab")) + tmux.until(|l| l.len() > 2 && l[2].starts_with("> ab")) } #[test] fn tiebreak_neg_index() -> Result<()> { let tmux = setup("a\\nb\\nc\\nab\\nac", "-index,score")?; - tmux.until(|l| l[2].starts_with("> a"))?; + tmux.until(|l| l.len() > 2 && l[2].starts_with("> a"))?; tmux.send_keys(&[Key('b')])?; - tmux.until(|l| l[2].starts_with("> ab")) + tmux.until(|l| l.len() > 2 && l[2].starts_with("> ab")) } #[test] fn tiebreak_begin() -> Result<()> { let tmux = setup("aaba\\nb\\nc\\naba\\nac", "begin,score")?; - tmux.until(|l| l[2].starts_with("> aaba"))?; + tmux.until(|l| l.len() > 2 && l[2].starts_with("> aaba"))?; tmux.send_keys(&[Str("ba")])?; - tmux.until(|l| l[2].starts_with("> aba")) + tmux.until(|l| l.len() > 2 && l[2].starts_with("> aba")) } #[test] fn tiebreak_neg_begin() -> Result<()> { let tmux = setup("aba\\nb\\nc\\naaba\\nac", "-begin,score")?; - tmux.until(|l| l[2].starts_with("> a"))?; + tmux.until(|l| l.len() > 2 && l[2].starts_with("> a"))?; tmux.send_keys(&[Key('b')])?; - tmux.until(|l| l[2].starts_with("> aaba")) + tmux.until(|l| l.len() > 2 && l[2].starts_with("> aaba")) } #[test] fn tiebreak_end() -> Result<()> { let tmux = setup("aaba\\nb\\nc\\naba\\nac", "end,score")?; - tmux.until(|l| l[2].starts_with("> aaba"))?; + tmux.until(|l| l.len() > 2 && l[2].starts_with("> aaba"))?; tmux.send_keys(&[Str("ba")])?; - tmux.until(|l| l[2].starts_with("> aba")) + tmux.until(|l| l.len() > 2 && l[2].starts_with("> aba")) } #[test] fn tiebreak_neg_end() -> Result<()> { let tmux = setup("aba\\nb\\nc\\naaba\\nac", "-end,score")?; - tmux.until(|l| l[2].starts_with("> a"))?; + tmux.until(|l| l.len() > 2 && l[2].starts_with("> a"))?; tmux.send_keys(&[Str("ba")])?; - tmux.until(|l| l[2].starts_with("> aaba")) + tmux.until(|l| l.len() > 2 && l[2].starts_with("> aaba")) } #[test] fn tiebreak_length() -> Result<()> { let tmux = setup("aaba\\nb\\nc\\naba\\nac", "length,score")?; - tmux.until(|l| l[2].starts_with("> b"))?; + tmux.until(|l| l.len() > 2 && l[2].starts_with("> b"))?; tmux.send_keys(&[Str("ba")])?; - tmux.until(|l| l[2].starts_with("> aba")) + tmux.until(|l| l.len() > 2 && l[2].starts_with("> aba")) } #[test] fn tiebreak_neg_length() -> Result<()> { let tmux = setup("aaba\\nb\\nc\\naba\\nac", "-length,score")?; - tmux.until(|l| l[2].starts_with("> aaba"))?; + tmux.until(|l| l.len() > 2 && l[2].starts_with("> aaba"))?; tmux.send_keys(&[Key('c')])?; - tmux.until(|l| l[2].starts_with("> ac")) + tmux.until(|l| l.len() > 2 && l[2].starts_with("> ac")) }