Skip to content

Commit

Permalink
time: Add smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
fox0 committed Oct 15, 2024
1 parent a452351 commit 02fa19e
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion datetime/tests/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::{
process::{Command, Output, Stdio},
};

use plib::TestPlan;
use plib::testing::TestPlan;

fn run_test_base(cmd: &str, args: &Vec<String>, stdin_data: &[u8]) -> Output {
let relpath = if cfg!(debug_assertions) {
Expand Down Expand Up @@ -67,11 +67,36 @@ fn run_test_time(
expected_exit_code,
});

let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);

assert_eq!(stdout, expected_output);
assert!(stderr.contains(expected_error));
}

#[test]
fn test_smoke_help() {
run_test_time(
&["--help"],
"\
time - time a simple command or give resource usage
Usage: time [OPTIONS] <UTILITY> [ARGUMENT]...
Arguments:
<UTILITY> The utility to be invoked
[ARGUMENT]... Arguments for the utility
Options:
-p, --posix Write timing output to standard error in POSIX format
-h, --help Print help
-V, --version Print version
",
"",
0,
);
}

#[test]
fn simple_test() {
run_test_time(&["--", "ls", "-l"], "", "User time", 0);
Expand Down

0 comments on commit 02fa19e

Please sign in to comment.