tests/env: add unsetting invalid variables test
-// spell-checker:ignore (words) bamf chdir
+// spell-checker:ignore (words) bamf chdir rlimit prlimit
#[cfg(not(windows))]
use std::fs;
@@ -80,6 +80,20 @@ fn test_combined_file_set_unset() {
);
}
+#[test]
+fn test_unset_invalid_variables() {
+ use uucore::display::Quotable;
+
+ // Cannot test input with \0 in it, since output will also contain \0. rlimit::prlimit fails
+ // with this error: Error { kind: InvalidInput, message: "nul byte found in provided data" }
+ for var in &["", "a=b"] {
+ new_ucmd!().arg("-u").arg(var).run().stderr_only(format!(
+ "env: cannot unset {}: Invalid argument",
+ var.quote()
+ ));
+ }
+}
+
#[test]
fn test_single_name_value_pair() {
let out = new_ucmd!().arg("FOO=bar").run();
