Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ zero-copy-pads = "0.2.0"
[dev-dependencies]
build-fs-tree = "0.8.1"
command-extra = "1.0.0"
libc = "0.2"
Comment thread
KSXGitHub marked this conversation as resolved.
Outdated
maplit = "1.0.2"
normalize-path = "0.2.1"
pretty_assertions = "1.4.1"
rand = "0.10.0"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(pdu_test_skip_fs_errors)'] }
13 changes: 13 additions & 0 deletions tests/cli_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ use std::process::{Command, Output, Stdio};
use text_block_macros::text_block;

#[cfg(unix)]
#[cfg(not(pdu_test_skip_fs_errors))]
use maplit::btreeset;
#[cfg(unix)]
#[cfg(not(pdu_test_skip_fs_errors))]
use parallel_disk_usage::{
bytes_format::BytesFormat,
data_tree::DataTree,
Expand All @@ -23,6 +25,7 @@ use parallel_disk_usage::{
visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer},
};
#[cfg(unix)]
#[cfg(not(pdu_test_skip_fs_errors))]
use std::{collections::BTreeSet, path::Path};

fn stdio(command: Command) -> Command {
Expand All @@ -33,6 +36,7 @@ fn stdio(command: Command) -> Command {
}

#[cfg(unix)]
#[cfg(not(pdu_test_skip_fs_errors))]
fn fs_permission(path: impl AsRef<Path>, permission: &'static str, recursive: bool) {
let Output { status, stderr, .. } = Command::new("chmod")
.pipe(|cmd| if recursive { cmd.with_arg("-R") } else { cmd })
Expand Down Expand Up @@ -106,8 +110,17 @@ fn max_depth_0() {
}

#[cfg(unix)]
#[cfg(not(pdu_test_skip_fs_errors))]
#[test]
fn fs_errors() {
if unsafe { libc::geteuid() } == 0 {
Comment thread
KSXGitHub marked this conversation as resolved.
panic!(
"{}\n{}",
"error: This test must not be run as root because running with elevated privileges would affect its accuracy.",
"hint: Either run this test as a non-root user or set `RUSTFLAGS='--cfg pdu_test_skip_fs_errors'` to skip this test.",
);
}

let workspace = SampleWorkspace::default();
fs_permission(workspace.join("empty-dir"), "-r", false);
fs_permission(workspace.join("nested").join("0"), "-r", false);
Expand Down
Loading