Test required script argument

This commit is contained in:
Diomidis Spinellis
2025-03-03 17:01:54 +02:00
parent 1d8fe2457d
commit a9395f56be
2 changed files with 20 additions and 2 deletions
+4
View File
@@ -4,6 +4,8 @@
// file that was distributed with this source code.
use clap::{arg, Arg, Command};
//use clap::builder::OsStr;
use std::ffi::OsString;
use std::path::PathBuf;
use uucore::{error::UResult, format_usage};
@@ -12,6 +14,8 @@ const USAGE: &str = "sed [OPTION]... {singular-script} [input-file]...";
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// Skip binary name
let args: Vec<OsString> = args.skip(1).collect();
// TODO remove underscore prefix when var is used
let _matches = uu_app().try_get_matches_from(args)?;
// TODO
+16 -2
View File
@@ -11,6 +11,20 @@ fn test_invalid_arg() {
}
#[test]
fn test_sed() {
new_ucmd!().succeeds();
fn test_debug() {
new_ucmd!().arg("--debug").arg("").succeeds();
}
#[test]
fn test_missing_script_argument() {
new_ucmd!()
.fails()
.code_is(1)
.stderr_contains("the following required arguments were not provided")
.stderr_contains("<script>");
}
#[test]
fn test_required_script_argument() {
new_ucmd!().arg("").succeeds().code_is(0);
}