From 9f39f1d75b05da4fb85fbfa9fee84428bbc7d466 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Tue, 1 Mar 2022 00:46:23 -0700 Subject: [PATCH] Add tests for multiple execs --- tests/tests.rs | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/tests/tests.rs b/tests/tests.rs index ec95a9c..3436437 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1383,6 +1383,67 @@ fn test_exec() { } } +#[test] +fn test_exec_multi() { + // TODO test for windows + if cfg!(windows) { + return; + } + let (te, abs_path) = get_test_env_with_abs_path(DEFAULT_DIRS, DEFAULT_FILES); + + te.assert_output( + &[ + "--absolute-path", + "foo", + "--exec", + "echo", + ";", + "--exec", + "echo", + "test", + "{/}", + ], + &format!( + "{abs_path}/a.foo + {abs_path}/one/b.foo + {abs_path}/one/two/C.Foo2 + {abs_path}/one/two/c.foo + {abs_path}/one/two/three/d.foo + {abs_path}/one/two/three/directory_foo + test a.foo + test b.foo + test C.Foo2 + test c.foo + test d.foo + test directory_foo", + abs_path = &abs_path + ), + ); + + te.assert_output( + &[ + "e1", "--exec", "echo", "{.}", ";", "--exec", "echo", "{/}", ";", "--exec", "echo", + "{//}", ";", "--exec", "echo", "{/.}", + ], + "e1 e2 + e1 e2 + . + e1 e2", + ); + + te.assert_output( + &[ + "foo", "--exec", "echo", "-n", "{/}: ", ";", "--exec", "echo", "{//}", + ], + "a.foo: . + b.foo: ./one + C.Foo2: ./one/two + c.foo: ./one/two + d.foo: ./one/two/three + directory_foo: ./one/two/three", + ); +} + #[test] fn test_exec_batch() { let (te, abs_path) = get_test_env_with_abs_path(DEFAULT_DIRS, DEFAULT_FILES); @@ -1435,6 +1496,21 @@ fn test_exec_batch() { } } +#[test] +fn test_exec_batch_multi() { + // TODO test for windows + if cfg!(windows) { + return; + } + let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES); + + te.assert_output( + &["foo", "--exec-batch", "echo", "{}", ";", "--exec-batch", "echo", "{/}"], + "./a.foo ./one/b.foo ./one/two/C.Foo2 ./one/two/c.foo ./one/two/three/d.foo ./one/two/three/directory_foo + a.foo b.foo C.Foo2 c.foo d.foo directory_foo", + ); +} + #[test] fn test_exec_batch_with_limit() { // TODO Test for windows