about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2023-02-10 17:13:30 +0100
committerMara Bos <m-ou.se@m-ou.se>2023-02-10 19:02:39 +0100
commit5fefe8b31738b4adf8329222afa50a264ef97d6a (patch)
treec1a61d683375b2ba2698f789bb9532b2d447bb6e
parent145e6a94d6bd9aa360fa7d43e52a2e9aad1752ef (diff)
downloadrust-5fefe8b31738b4adf8329222afa50a264ef97d6a.tar.gz
rust-5fefe8b31738b4adf8329222afa50a264ef97d6a.zip
Add test.
-rw-r--r--tests/ui/suspicious_command_arg_space.rs5
-rw-r--r--tests/ui/suspicious_command_arg_space.stderr25
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/suspicious_command_arg_space.rs b/tests/ui/suspicious_command_arg_space.rs
new file mode 100644
index 00000000000..74b230f430b
--- /dev/null
+++ b/tests/ui/suspicious_command_arg_space.rs
@@ -0,0 +1,5 @@
+fn main() {
+    std::process::Command::new("echo").arg("hello world").spawn().unwrap();
+    std::process::Command::new("echo").arg("-n hello").spawn().unwrap();
+    std::process::Command::new("cat").arg("--number file").spawn().unwrap();
+}
diff --git a/tests/ui/suspicious_command_arg_space.stderr b/tests/ui/suspicious_command_arg_space.stderr
new file mode 100644
index 00000000000..9bc0ca93aec
--- /dev/null
+++ b/tests/ui/suspicious_command_arg_space.stderr
@@ -0,0 +1,25 @@
+error: single argument that looks like it should be multiple arguments
+  --> $DIR/suspicious_command_arg_space.rs:3:44
+   |
+LL |     std::process::Command::new("echo").arg("-n hello").spawn().unwrap();
+   |                                            ^^^^^^^^^^
+   |
+   = note: `-D clippy::suspicious-command-arg-space` implied by `-D warnings`
+help: consider splitting the argument
+   |
+LL |     std::process::Command::new("echo").args(["-n", "hello"]).spawn().unwrap();
+   |                                        ~~~~ ~~~~~~~~~~~~~~~
+
+error: single argument that looks like it should be multiple arguments
+  --> $DIR/suspicious_command_arg_space.rs:4:43
+   |
+LL |     std::process::Command::new("cat").arg("--number file").spawn().unwrap();
+   |                                           ^^^^^^^^^^^^^^^
+   |
+help: consider splitting the argument
+   |
+LL |     std::process::Command::new("cat").args(["--number", "file"]).spawn().unwrap();
+   |                                       ~~~~ ~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to 2 previous errors
+