##// END OF EJS Templates
tests: use sha256line.py instead of /dev/random in test-censor.t (issue6858)...
tests: use sha256line.py instead of /dev/random in test-censor.t (issue6858) Sometimes the systems that run our test suite don't have enough entropy and they cannot produce target file of the expected size using /dev/random, which results in test failures. Switching to /dev/urandom would give us way more available data at the cost of it being less "random", but we don't really need to use entropy for this task at all, since we only care if the file size after compression is big enough to not be stored inline in the revlog. So let's use something that we already have used to generate this kind of data in other tests.

File last commit:

r50809:58074252 default
r52255:e7be2ddf stable
Show More
debugrhgsparse.rs
49 lines | 1.5 KiB | application/rls-services+xml | RustLexer
/ rust / rhg / src / commands / debugrhgsparse.rs
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 use std::{
ffi::{OsStr, OsString},
os::unix::prelude::OsStrExt,
};
Raphaël Gomès
rhg: add debugrhgsparse command to help figure out bugs in rhg
r50379
use crate::error::CommandError;
use hg::{self, utils::hg_path::HgPath};
pub const HELP_TEXT: &str = "";
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 pub fn args() -> clap::Command {
clap::command!("debugrhgsparse")
Raphaël Gomès
rhg: add debugrhgsparse command to help figure out bugs in rhg
r50379 .arg(
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 clap::Arg::new("files")
.value_name("FILES")
Raphaël Gomès
rhg: add debugrhgsparse command to help figure out bugs in rhg
r50379 .required(true)
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 .num_args(1..)
.value_parser(clap::value_parser!(std::ffi::OsString))
Raphaël Gomès
rhg: add debugrhgsparse command to help figure out bugs in rhg
r50379 .help("Files to check against sparse profile"),
)
.about(HELP_TEXT)
}
pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
let repo = invocation.repo?;
Raphaël Gomès
rust: run `cargo clippy`...
r50809 let (matcher, _warnings) = hg::sparse::matcher(repo).unwrap();
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 let files = invocation.subcommand_args.get_many::<OsString>("files");
Raphaël Gomès
rhg: add debugrhgsparse command to help figure out bugs in rhg
r50379 if let Some(files) = files {
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 let files: Vec<&OsStr> = files
.filter(|s| !s.is_empty())
.map(|s| s.as_os_str())
.collect();
Raphaël Gomès
rhg: add debugrhgsparse command to help figure out bugs in rhg
r50379 for file in files {
invocation.ui.write_stdout(b"matches: ")?;
invocation.ui.write_stdout(
if matcher.matches(HgPath::new(file.as_bytes())) {
b"yes"
} else {
b"no"
},
)?;
invocation.ui.write_stdout(b" | file: ")?;
invocation.ui.write_stdout(file.as_bytes())?;
invocation.ui.write_stdout(b"\n")?;
}
}
Ok(())
}