Skip to content

Commit

Permalink
Merge branch 'main' into feature/nohup_improve_test_coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
cre4ture authored Jan 20, 2024
2 parents 0498c16 + 746a7b1 commit c43d85e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
shell: bash
run: |
RUSTDOCFLAGS="-Dwarnings" cargo doc ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --no-deps --workspace --document-private-items
- uses: DavidAnson/markdownlint-cli2-action@v14
- uses: DavidAnson/markdownlint-cli2-action@v15
with:
fix: "true"
globs: |
Expand Down
9 changes: 8 additions & 1 deletion src/uu/tsort/src/tsort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
stdin_buf = stdin();
&mut stdin_buf as &mut dyn Read
} else {
file_buf = File::open(Path::new(&input)).map_err_context(|| input.to_string())?;
let path = Path::new(&input);
if path.is_dir() {
return Err(USimpleError::new(
1,
format!("{}: read error: Is a directory", input),
));
}
file_buf = File::open(path).map_err_context(|| input.to_string())?;
&mut file_buf as &mut dyn Read
});

Expand Down
9 changes: 9 additions & 0 deletions tests/by-util/test_tsort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,12 @@ fn test_multiple_arguments() {
.fails()
.stderr_contains("unexpected argument 'invalid_file' found");
}

#[test]
fn test_error_on_dir() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir("tsort_test_dir");
ucmd.arg("tsort_test_dir")
.fails()
.stderr_contains("tsort: tsort_test_dir: read error: Is a directory");
}

0 comments on commit c43d85e

Please sign in to comment.