| 1 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::{HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#, HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#}; |
| 2 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#; |
| 3 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::atomicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/::AtomicUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicUsize#; |
| 4 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::{Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#, Condvarrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/condvar/Condvar#, Mutexrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/Mutex#, MutexGuardrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/MutexGuard#}; |
| 5 |
|
| 6 |
use lazy_staticrust-analyzer cargo lazy_static 1.4.0 crate/::lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!; |
| •7 |
use sysinforust-analyzer cargo sysinfo 0.39.6 crate/::{Pidrust-analyzer cargo sysinfo 0.39.6 common/system/Pid#, Processrust-analyzer cargo sysinfo 0.39.6 common/system/Process#, ProcessRefreshKindrust-analyzer cargo sysinfo 0.39.6 common/system/ProcessRefreshKind#, ProcessesToUpdaterust-analyzer cargo sysinfo 0.39.6 common/system/ProcessesToUpdate#, UpdateKindrust-analyzer cargo sysinfo 0.39.6 common/system/UpdateKind#}; |
| 8 |
|
| 9 |
use craterust-analyzer cargo git-delta 0.19.2 crate/::utilsrust-analyzer cargo git-delta 0.19.2 utils/::DELTA_ATOMIC_ORDERINGrust-analyzer cargo git-delta 0.19.2 utils/DELTA_ATOMIC_ORDERING.; |
| 10 |
|
| 11 |
pub type DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid# = u32; |
| 12 |
|
| 13 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 14 |
pub enum CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess# { |
| 15 |
GitDiffrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitDiff#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#), |
| 16 |
GitShowrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitShow#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>), // element 2 is filename |
| 17 |
GitLogrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitLog#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#), |
| 18 |
GitReflogrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitReflog#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#), |
| 19 |
GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#), |
| 20 |
GitGreprust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitGrep#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#), |
| 21 |
OtherGreprust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#OtherGrep#, // rg, grep, ag, ack, etc |
| 22 |
Nonerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#None#, // no matching process could be found |
| 23 |
Pendingrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#Pending#, // calling process is currently being determined |
| 24 |
} |
| 25 |
|
| 26 |
// The information where the calling process info comes from *should* be inside |
| 27 |
// `CallingProcess`, but that is handed out (within a MutexGuard) to callers. |
| 28 |
// To keep the interface simple, store it here: |
| 29 |
static CALLER_INFO_SOURCErust-analyzer cargo git-delta 0.19.2 utils/process/CALLER_INFO_SOURCE.: AtomicUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicUsize# = AtomicUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicUsize#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicUsize]new().(CALLER_GUESSEDrust-analyzer cargo git-delta 0.19.2 utils/process/CALLER_GUESSED.); |
| 30 |
const CALLER_GUESSEDrust-analyzer cargo git-delta 0.19.2 utils/process/CALLER_GUESSED.: usize = 1; |
| 31 |
const CALLER_KNOWNrust-analyzer cargo git-delta 0.19.2 utils/process/CALLER_KNOWN.: usize = 2; |
| 32 |
|
| 33 |
impl CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess# { |
| 34 |
pub fn paths_in_input_are_relative_to_cwdrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[CallingProcess]paths_in_input_are_relative_to_cwd().(&self) -> bool { |
| 35 |
match self { |
| 36 |
CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitDiffrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitDiff#(cmd) if cmd.long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().("--relative") => true, |
| 37 |
CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitShowrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitShow#(cmd, _) if cmd.long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().("--relative") => true, |
| 38 |
CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitLogrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitLog#(cmd) if cmd.long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().("--relative") => true, |
| 39 |
CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(_) |
| 40 |
| CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitGreprust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitGrep#(_) |
| 41 |
| CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::OtherGreprust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#OtherGrep# => true, |
| 42 |
_ => false, |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 48 |
pub struct CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 49 |
pub long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 50 |
pub short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 51 |
pub last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 52 |
} |
| 53 |
|
| 54 |
lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! { |
| 55 |
static ref CALLERrust-analyzer cargo git-delta 0.19.2 utils/process/CALLER#: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<(Mutexrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/Mutex#<CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#>, Condvarrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/condvar/Condvar#)> = |
| 56 |
Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().((Mutexrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/Mutex#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`Mutex<T>`]new().(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::Pendingrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#Pending#), Condvarrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/condvar/Condvar#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/condvar/impl#[Condvar]new().())); |
| 57 |
} |
| 58 |
|
| 59 |
// delta was called by this process (or called by something which called delta and it), |
| 60 |
// try looking up this information in the process tree. |
| 61 |
pub fn start_determining_calling_process_in_threadrust-analyzer cargo git-delta 0.19.2 utils/process/start_determining_calling_process_in_thread().() { |
| 62 |
// The handle is neither kept nor returned nor joined but dropped, so the main |
| 63 |
// thread can exit early if it does not need to know its parent process. |
| 64 |
stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::Builderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/builder/Builder#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/builder/impl#[Builder]new().() |
| 65 |
.namerust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/builder/impl#[Builder]name().("find_calling_process".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 66 |
.spawnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/builder/impl#[Builder]spawn().(move || { |
| 67 |
let calling_process = determine_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/determine_calling_process().(); |
| 68 |
|
| 69 |
let (caller_mutex, determine_done) = &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Deref]deref().*rust-analyzer cargo git-delta 0.19.2 utils/process/impl#[CALLER][Deref]deref().CALLERrust-analyzer cargo git-delta 0.19.2 utils/process/CALLER.; |
| 70 |
|
| 71 |
let mut caller = caller_mutex.lockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`Mutex<T>`]lock().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 72 |
|
| 73 |
if CALLER_INFO_SOURCErust-analyzer cargo git-delta 0.19.2 utils/process/CALLER_INFO_SOURCE..loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicUsize]load().(DELTA_ATOMIC_ORDERINGrust-analyzer cargo git-delta 0.19.2 utils/DELTA_ATOMIC_ORDERING.) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().CALLER_GUESSEDrust-analyzer cargo git-delta 0.19.2 utils/process/CALLER_GUESSED. { |
| 74 |
*rust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`MutexGuard<'_, T>`][DerefMut]deref_mut().caller = calling_process; |
| 75 |
} |
| 76 |
|
| 77 |
determine_done.notify_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/condvar/impl#[Condvar]notify_all().(); |
| 78 |
}) |
| 79 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 80 |
} |
| 81 |
|
| 82 |
// delta starts the process, so it is known. |
| 83 |
pub fn set_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/set_calling_process().(args: &[Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#]) { |
| 84 |
if let ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(result) = describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().(args) { |
| 85 |
let (caller_mutex, determine_done) = &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Deref]deref().*rust-analyzer cargo git-delta 0.19.2 utils/process/impl#[CALLER][Deref]deref().CALLERrust-analyzer cargo git-delta 0.19.2 utils/process/CALLER.; |
| 86 |
|
| 87 |
let mut caller = caller_mutex.lockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`Mutex<T>`]lock().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 88 |
*rust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`MutexGuard<'_, T>`][DerefMut]deref_mut().caller = result; |
| 89 |
CALLER_INFO_SOURCErust-analyzer cargo git-delta 0.19.2 utils/process/CALLER_INFO_SOURCE..storerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicUsize]store().(CALLER_KNOWNrust-analyzer cargo git-delta 0.19.2 utils/process/CALLER_KNOWN., DELTA_ATOMIC_ORDERINGrust-analyzer cargo git-delta 0.19.2 utils/DELTA_ATOMIC_ORDERING.); |
| 90 |
determine_done.notify_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/condvar/impl#[Condvar]notify_all().(); |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
#[cfg(not(test))] |
| 95 |
pub fn calling_process() -> MutexGuardrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/MutexGuard#<'static, CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#> { |
| 96 |
let (caller_mutex, determine_done) = &**CALLERrust-analyzer cargo git-delta 0.19.2 utils/process/CALLER#; |
| 97 |
|
| 98 |
determine_done |
| 99 |
.wait_while(caller_mutex.lock().unwrap(), |caller| { |
| 100 |
*caller == CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::Pendingrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#Pending# |
| 101 |
}) |
| 102 |
.unwrap() |
| 103 |
} |
| 104 |
|
| 105 |
// The return value is duck-typed to work in place of a MutexGuard when testing. |
| 106 |
#[cfg(test)] |
| 107 |
pub fn calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/calling_process().() -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#> { |
| 108 |
type _UnusedImportrust-analyzer cargo git-delta 0.19.2 utils/process/_UnusedImport# = MutexGuardrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/MutexGuard#<'static, i8>; |
| 109 |
|
| 110 |
if craterust-analyzer cargo git-delta 0.19.2 crate/::utilsrust-analyzer cargo git-delta 0.19.2 utils/::processrust-analyzer cargo git-delta 0.19.2 utils/process/::testsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/::FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::are_setrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]are_set().() { |
| 111 |
// If the (thread-local) FakeParentArgs are set, then the following command returns |
| 112 |
// these, so the cached global real ones can not be used. |
| 113 |
Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(determine_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/determine_calling_process().()) |
| 114 |
} else { |
| 115 |
let (caller_mutex, _) = &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Deref]deref().*rust-analyzer cargo git-delta 0.19.2 utils/process/impl#[CALLER][Deref]deref().CALLERrust-analyzer cargo git-delta 0.19.2 utils/process/CALLER.; |
| 116 |
|
| 117 |
let mut caller = caller_mutex.lockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`Mutex<T>`]lock().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 118 |
if *rust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`MutexGuard<'_, T>`][Deref]deref().caller rust-analyzer cargo git-delta 0.19.2 utils/process/impl#[CallingProcess][`PartialEq<Self>`]eq().==rust-analyzer cargo git-delta 0.19.2 utils/process/impl#[CallingProcess][`PartialEq<Self>`]eq(). rust-analyzer cargo git-delta 0.19.2 utils/process/impl#[CallingProcess][`PartialEq<Self>`]eq().CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::Pendingrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#Pending# { |
| 119 |
*rust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`MutexGuard<'_, T>`][DerefMut]deref_mut().caller = determine_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/determine_calling_process().(); |
| 120 |
} |
| 121 |
|
| 122 |
Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(caller.clonerust-analyzer cargo git-delta 0.19.2 utils/process/impl#[CallingProcess][Clone]clone().()) |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
fn determine_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/determine_calling_process().() -> CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess# { |
| 127 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(), describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().) |
| 128 |
.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::Nonerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#None#) |
| 129 |
} |
| 130 |
|
| 131 |
// Return value of `extract_args(args: &[String]) -> ProcessArgs<T>` function which is |
| 132 |
// passed to `calling_process_cmdline()`. |
| 133 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 134 |
pub enum ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#<T> { |
| 135 |
// A result has been successfully extracted from args. |
| 136 |
Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(T), |
| 137 |
// The extraction has failed. |
| 138 |
ArgErrorrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#ArgError#, |
| 139 |
// The process does not match, others may be inspected. |
| 140 |
OtherProcessrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#OtherProcess#, |
| 141 |
} |
| 142 |
|
| 143 |
pub fn describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().(args: &[Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#]) -> ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#<CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#> { |
| 144 |
let mut args = args.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()); |
| 145 |
|
| 146 |
fn is_any_ofrust-analyzer cargo git-delta 0.19.2 utils/process/is_any_of().<'a, I>(cmd: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>, others: I) -> bool |
| 147 |
where |
| 148 |
I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = &'a str>, |
| 149 |
{ |
| 150 |
cmd.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|cmd| others.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(|o| o.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().(cmd))) |
| 151 |
.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false) |
| 152 |
} |
| 153 |
|
| 154 |
match args.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().() { |
| 155 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(command) => match Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().(command).file_stemrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]file_stem().() { |
| 156 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) if s.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_str().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(is_git_binaryrust-analyzer cargo git-delta 0.19.2 utils/process/is_git_binary().).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false) => { |
| 157 |
let mut args = args.skip_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#skip_while().(|s| { |
| 158 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne()."diff" |
| 159 |
&& *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne()."show" |
| 160 |
&& *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne()."log" |
| 161 |
&& *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne()."reflog" |
| 162 |
&& *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne()."grep" |
| 163 |
&& *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne()."blame" |
| 164 |
}); |
| 165 |
match args.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/skip_while/impl#[`SkipWhile<I, P>`][Iterator]next().() { |
| 166 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("diff") => { |
| 167 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitDiffrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitDiff#(parse_command_linerust-analyzer cargo git-delta 0.19.2 utils/process/parse_command_line().(args))) |
| 168 |
} |
| 169 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("show") => { |
| 170 |
let command_line = parse_command_linerust-analyzer cargo git-delta 0.19.2 utils/process/parse_command_line().(args); |
| 171 |
let filename = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(last_arg) = &command_line.last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg. { |
| 172 |
match last_arg.split_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_once().(':') { |
| 173 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((_, filename)) => Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().(filename) |
| 174 |
.file_namerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]file_name().() |
| 175 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|f| f.to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 176 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 177 |
} |
| 178 |
} else { |
| 179 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 180 |
}; |
| 181 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitShowrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitShow#(command_line, filename)) |
| 182 |
} |
| 183 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("log") => { |
| 184 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitLogrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitLog#(parse_command_linerust-analyzer cargo git-delta 0.19.2 utils/process/parse_command_line().(args))) |
| 185 |
} |
| 186 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("reflog") => { |
| 187 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitReflogrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitReflog#(parse_command_linerust-analyzer cargo git-delta 0.19.2 utils/process/parse_command_line().(args))) |
| 188 |
} |
| 189 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("grep") => { |
| 190 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitGreprust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitGrep#(parse_command_linerust-analyzer cargo git-delta 0.19.2 utils/process/parse_command_line().(args))) |
| 191 |
} |
| 192 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("blame") => { |
| 193 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(parse_command_linerust-analyzer cargo git-delta 0.19.2 utils/process/parse_command_line().(args))) |
| 194 |
} |
| 195 |
_ => { |
| 196 |
// It's git, but not a subcommand that we parse. Don't |
| 197 |
// look at any more processes. |
| 198 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::ArgErrorrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#ArgError# |
| 199 |
} |
| 200 |
} |
| 201 |
} |
| 202 |
// TODO: parse_style_sections is failing to parse ANSI escape sequences emitted by |
| 203 |
// grep (BSD and GNU), ag, pt. See #794 |
| 204 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) if is_any_ofrust-analyzer cargo git-delta 0.19.2 utils/process/is_any_of().(s.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_str().(), ["rg", "ack", "sift"]) => { |
| 205 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::OtherGreprust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#OtherGrep#) |
| 206 |
} |
| 207 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_) => { |
| 208 |
// It's not git, and it's not another grep tool. Keep |
| 209 |
// looking at other processes. |
| 210 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::OtherProcessrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#OtherProcess# |
| 211 |
} |
| 212 |
_ => { |
| 213 |
// Could not parse file stem (not expected); keep looking at |
| 214 |
// other processes. |
| 215 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::OtherProcessrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#OtherProcess# |
| 216 |
} |
| 217 |
}, |
| 218 |
_ => { |
| 219 |
// Empty arguments (not expected); keep looking. |
| 220 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::OtherProcessrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#OtherProcess# |
| 221 |
} |
| 222 |
} |
| 223 |
} |
| 224 |
|
| 225 |
fn is_git_binaryrust-analyzer cargo git-delta 0.19.2 utils/process/is_git_binary().(git: &str) -> bool { |
| 226 |
// Ignore case, for e.g. NTFS or APFS file systems |
| 227 |
Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().(git) |
| 228 |
.file_stemrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]file_stem().() |
| 229 |
.and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|os_str| os_str.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_str().()) |
| 230 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.eq_ignore_ascii_caserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]eq_ignore_ascii_case().("git")) |
| 231 |
.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false) |
| 232 |
} |
| 233 |
|
| 234 |
// Given `--aa val -bc -d val e f -- ...` return |
| 235 |
// ({"--aa"}, {"-b", "-c", "-d"}) |
| 236 |
fn parse_command_linerust-analyzer cargo git-delta 0.19.2 utils/process/parse_command_line().<'a>(args: impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &'a str>) -> CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 237 |
let mut long_options = HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().(); |
| 238 |
let mut short_options = HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().(); |
| 239 |
let mut last_arg = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 240 |
let mut after_double_dash = false; |
| 241 |
|
| 242 |
for s in args { |
| 243 |
if after_double_dash { |
| 244 |
last_arg = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s); |
| 245 |
} else if s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."--" { |
| 246 |
after_double_dash = true; |
| 247 |
} else if s.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("--") { |
| 248 |
long_options.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(s.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().('=').nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 249 |
} else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(suffix) = s.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().('-') { |
| 250 |
short_options.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(suffix.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|c| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("-{c}"))); |
| 251 |
} else { |
| 252 |
last_arg = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s); |
| 253 |
} |
| 254 |
} |
| 255 |
|
| 256 |
CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 257 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options., |
| 258 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options., |
| 259 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: last_arg.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 260 |
} |
| 261 |
} |
| 262 |
|
| 263 |
struct ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo# { |
| 264 |
inforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#info.: sysinforust-analyzer cargo sysinfo 0.39.6 crate/::Systemrust-analyzer cargo sysinfo 0.39.6 common/system/System#, |
| 265 |
} |
| 266 |
impl ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo# { |
| 267 |
fn newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().() -> Selfrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo] { |
| 268 |
// On Linux sysinfo optimizes for repeated process queries and keeps per-process |
| 269 |
// /proc file descriptors open. This caching is not needed here, so |
| 270 |
// set this to zero (this does nothing on other platforms). |
| 271 |
// Also, there is currently a kernel bug which slows down syscalls when threads are |
| 272 |
// involved (here: the ctrlc handler) and a lot of files are kept open. |
| 273 |
sysinforust-analyzer cargo sysinfo 0.39.6 crate/::set_open_files_limitrust-analyzer cargo sysinfo 0.39.6 set_open_files_limit().(0); |
| 274 |
|
| 275 |
ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo# { |
| 276 |
inforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#info.: sysinforust-analyzer cargo sysinfo 0.39.6 crate/::Systemrust-analyzer cargo sysinfo 0.39.6 common/system/System#::newrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[System]new().(), |
| 277 |
} |
| 278 |
} |
| 279 |
} |
| 280 |
|
| 281 |
trait ProcActionsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions# { |
| •282 |
fn cmdrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#cmd().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>; |
| 283 |
fn parentrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#parent().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#>; |
| 284 |
fn pidrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#pid().(&self) -> DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#; |
| 285 |
fn start_timerust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#start_time().(&self) -> u64; |
| 286 |
} |
| 287 |
|
| •288 |
impl ProcActionsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions# for Processrust-analyzer cargo sysinfo 0.39.6 common/system/Process# { |
| 289 |
fn cmdrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[Process][ProcActions]cmd().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 290 |
Processrust-analyzer cargo sysinfo 0.39.6 common/system/Process#::cmdrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[Process]cmd().(self) |
| 291 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 292 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|arg| arg.to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().().into_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, B>`]into_owned().()) |
| 293 |
.collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 294 |
} |
| 295 |
fn parentrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[Process][ProcActions]parent().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#> { |
| •296 |
Processrust-analyzer cargo sysinfo 0.39.6 common/system/Process#::parentrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[Process]parent().(self).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|p| p.as_u32rust-analyzer cargo sysinfo 0.39.6 common/system/impl#[Pid]as_u32().()) |
| 297 |
} |
| 298 |
fn pidrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[Process][ProcActions]pid().(&self) -> DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid# { |
| •299 |
Processrust-analyzer cargo sysinfo 0.39.6 common/system/Process#::pidrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[Process]pid().(self).as_u32rust-analyzer cargo sysinfo 0.39.6 common/system/impl#[Pid]as_u32().() |
| 300 |
} |
| 301 |
fn start_timerust-analyzer cargo git-delta 0.19.2 utils/process/impl#[Process][ProcActions]start_time().(&self) -> u64 { |
| •302 |
Processrust-analyzer cargo sysinfo 0.39.6 common/system/Process#::start_timerust-analyzer cargo sysinfo 0.39.6 common/system/impl#[Process]start_time().(self) |
| 303 |
} |
| 304 |
} |
| 305 |
|
| 306 |
trait ProcessInterfacerust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface# { |
| 307 |
type Outrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#Out#: ProcActionsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#; |
| 308 |
|
| 309 |
fn my_pidrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#my_pid().(&self) -> DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#; |
| 310 |
|
| 311 |
fn processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#process().(&self, pid: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Self::Outrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#Out#>; |
| 312 |
fn processesrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#processes().(&self) -> &HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Pidrust-analyzer cargo sysinfo 0.39.6 common/system/Pid#, Self::Outrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#Out#>; |
| 313 |
|
| 314 |
fn refresh_processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#refresh_process().(&mut self, pid: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#) -> bool; |
| 315 |
fn refresh_processesrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#refresh_processes().(&mut self); |
| 316 |
|
| 317 |
fn parent_processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#parent_process().(&mut self, pid: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Self::Outrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#Out#> { |
| 318 |
self.refresh_processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#refresh_process().(pid).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 319 |
let parent_pid = self.processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#process().(pid)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch()..parentrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#parent().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 320 |
self.refresh_processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#refresh_process().(parent_pid).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 321 |
self.processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#process().(parent_pid) |
| 322 |
} |
| 323 |
fn naive_sibling_processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#naive_sibling_process().(&mut self, pid: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Self::Outrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#Out#> { |
| 324 |
let sibling_pid = pid rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().1; |
| 325 |
self.refresh_processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#refresh_process().(sibling_pid).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 326 |
self.processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#process().(sibling_pid) |
| 327 |
} |
| 328 |
fn find_sibling_in_refreshed_processesrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#find_sibling_in_refreshed_processes().<F, T>( |
| 329 |
&mut self, |
| 330 |
pid: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#, |
| 331 |
extract_args: &F, |
| 332 |
) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<T> |
| 333 |
where |
| 334 |
F: Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&[Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#]) -> ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#<T>, |
| 335 |
Self: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 336 |
{ |
| 337 |
/* |
| 338 |
|
| 339 |
$ start_blame_of.sh src/main.rs | delta |
| 340 |
|
| 341 |
\_ /usr/bin/some-terminal-emulator |
| 342 |
| \_ common_git_and_delta_ancestor |
| 343 |
| \_ /bin/sh /opt/git/start_blame_of.sh src/main.rs |
| 344 |
| | \_ /bin/sh /opt/some/wrapper git blame src/main.rs |
| 345 |
| | \_ /usr/bin/git blame src/main.rs |
| 346 |
| \_ /bin/sh /opt/some/wrapper delta |
| 347 |
| \_ delta |
| 348 |
|
| 349 |
Walk up the process tree of delta and of every matching other process, counting the steps |
| 350 |
along the way. |
| 351 |
Find the common ancestor processes, calculate the distance, and select the one with the shortest. |
| 352 |
|
| 353 |
*/ |
| 354 |
|
| 355 |
let this_start_time = self.processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#process().(pid)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch()..start_timerust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#start_time().(); |
| 356 |
|
| 357 |
let mut pid_distances = HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::<DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#, usize>::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(); |
| 358 |
let mut collect_parent_pids = |pid, distance| { |
| 359 |
pid_distances.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(pid, distance); |
| 360 |
}; |
| 361 |
|
| 362 |
iter_parentsrust-analyzer cargo git-delta 0.19.2 utils/process/iter_parents().(self, pid, &mut collect_parent_pids); |
| 363 |
|
| 364 |
let process_start_time_difference_less_than_3s = |a, b| (a as i64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().b as i64).absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]abs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt().3; |
| 365 |
|
| 366 |
let cmdline_of_closest_matching_process = self |
| 367 |
.processesrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#processes().() |
| 368 |
.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().() |
| 369 |
.filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|(_, proc)| { |
| 370 |
process_start_time_difference_less_than_3s(this_start_time, proc.start_timerust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#start_time().()) |
| 371 |
}) |
| •372 |
.filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|(&pid, proc)| match extract_args(&proc.cmdrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#cmd().()) { |
| 373 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(args) => { |
| 374 |
let mut length_of_process_chain = usize::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]MAX.; |
| 375 |
|
| 376 |
let mut sum_distance = |pid, distance| { |
| 377 |
if length_of_process_chain rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().usize::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]MAX. { |
| 378 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(distance_to_first_common_parent) = pid_distances.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&pid) { |
| 379 |
length_of_process_chain = |
| 380 |
distance_to_first_common_parent rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&usize`][`Add<usize>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&usize`][`Add<usize>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&usize`][`Add<usize>`]add().distance; |
| 381 |
} |
| 382 |
} |
| 383 |
}; |
| 384 |
iter_parentsrust-analyzer cargo git-delta 0.19.2 utils/process/iter_parents().(self, pid.as_u32rust-analyzer cargo sysinfo 0.39.6 common/system/impl#[Pid]as_u32().(), &mut sum_distance); |
| 385 |
|
| 386 |
if length_of_process_chain rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().usize::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]MAX. { |
| 387 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 388 |
} else { |
| 389 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((length_of_process_chain, args)) |
| 390 |
} |
| 391 |
} |
| 392 |
_ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 393 |
}) |
| 394 |
.min_by_keyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#min_by_key().(|(distance, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().distance) |
| 395 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(_, result)| result); |
| 396 |
|
| 397 |
cmdline_of_closest_matching_process |
| 398 |
} |
| 399 |
} |
| 400 |
|
| 401 |
impl ProcessInterfacerust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface# for ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo# { |
| 402 |
type Outrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo][ProcessInterface]Out# = Processrust-analyzer cargo sysinfo 0.39.6 common/system/Process#; |
| 403 |
|
| 404 |
fn my_pidrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo][ProcessInterface]my_pid().(&self) -> DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid# { |
| 405 |
stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::processrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/::idrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/id().() |
| 406 |
} |
| 407 |
fn refresh_processrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo][ProcessInterface]refresh_process().(&mut self, pid: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#) -> bool { |
| •408 |
self.inforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#info..refresh_processes_specificsrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[System]refresh_processes_specifics().( |
| 409 |
ProcessesToUpdaterust-analyzer cargo sysinfo 0.39.6 common/system/ProcessesToUpdate#::Somerust-analyzer cargo sysinfo 0.39.6 common/system/ProcessesToUpdate#Some#(&[Pidrust-analyzer cargo sysinfo 0.39.6 common/system/Pid#::from_u32rust-analyzer cargo sysinfo 0.39.6 common/system/impl#[Pid]from_u32().(pid)]), |
| 410 |
true, |
| 411 |
ProcessRefreshKindrust-analyzer cargo sysinfo 0.39.6 common/system/ProcessRefreshKind#::nothingrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[ProcessRefreshKind]nothing().().with_cmdrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[ProcessRefreshKind]with_cmd().(UpdateKindrust-analyzer cargo sysinfo 0.39.6 common/system/UpdateKind#::Alwaysrust-analyzer cargo sysinfo 0.39.6 common/system/UpdateKind#Always#), |
| 412 |
) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 |
| 413 |
} |
| 414 |
fn processrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo][ProcessInterface]process().(&self, pid: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Selfrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo][ProcessInterface]::Outrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#Out#> { |
| 415 |
self.inforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#info..processrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[System]process().(Pidrust-analyzer cargo sysinfo 0.39.6 common/system/Pid#::from_u32rust-analyzer cargo sysinfo 0.39.6 common/system/impl#[Pid]from_u32().(pid)) |
| 416 |
} |
| 417 |
fn processesrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo][ProcessInterface]processes().(&self) -> &HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Pidrust-analyzer cargo sysinfo 0.39.6 common/system/Pid#, Selfrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo][ProcessInterface]::Outrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#Out#> { |
| 418 |
self.inforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#info..processesrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[System]processes().() |
| 419 |
} |
| 420 |
fn refresh_processesrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo][ProcessInterface]refresh_processes().(&mut self) { |
| •421 |
self.inforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#info..refresh_processes_specificsrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[System]refresh_processes_specifics().( |
| 422 |
ProcessesToUpdaterust-analyzer cargo sysinfo 0.39.6 common/system/ProcessesToUpdate#::Allrust-analyzer cargo sysinfo 0.39.6 common/system/ProcessesToUpdate#All#, |
| 423 |
true, |
| 424 |
ProcessRefreshKindrust-analyzer cargo sysinfo 0.39.6 common/system/ProcessRefreshKind#::nothingrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[ProcessRefreshKind]nothing().().with_cmdrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[ProcessRefreshKind]with_cmd().(UpdateKindrust-analyzer cargo sysinfo 0.39.6 common/system/UpdateKind#::Alwaysrust-analyzer cargo sysinfo 0.39.6 common/system/UpdateKind#Always#), |
| 425 |
); |
| 426 |
} |
| 427 |
} |
| 428 |
|
| 429 |
fn calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().<P, F, T>(mut info: P, extract_args: F) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<T> |
| 430 |
where |
| 431 |
P: ProcessInterfacerust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#, |
| 432 |
F: Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&[Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#]) -> ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#<T>, |
| 433 |
{ |
| 434 |
#[cfg(test)] |
| 435 |
{ |
| 436 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(args) = testsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/::FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::getrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]get().() { |
| 437 |
match extract_args(&args) { |
| 438 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(result) => return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(result), |
| 439 |
_ => return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 440 |
} |
| 441 |
} |
| 442 |
} |
| 443 |
|
| 444 |
let my_pid = info.my_pidrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#my_pid().(); |
| 445 |
|
| 446 |
// 1) Try the parent process(es). If delta is set as the pager in git, then git is the parent process. |
| 447 |
// If delta is started by a script check the parent's parent as well. |
| 448 |
let mut current_pid = my_pid; |
| 449 |
'parent_iter: for depth in [1, 2, 3] { |
| 450 |
let parent = match info.parent_processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#parent_process().(current_pid) { |
| 451 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 452 |
break 'parent_iter; |
| 453 |
} |
| 454 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parent) => parent, |
| 455 |
}; |
| 456 |
let parent_pid = parent.pidrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#pid().(); |
| 457 |
|
| •458 |
match extract_args(&parent.cmdrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#cmd().()) { |
| 459 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(result) => return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(result), |
| 460 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::ArgErrorrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#ArgError# => return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 461 |
|
| 462 |
// 2) The 1st parent process was something else, this can happen if git output is piped into delta, e.g. |
| 463 |
// `git blame foo.txt | delta`. When the shell sets up the pipe it creates the two processes, the pids |
| 464 |
// are usually consecutive, so naively check if the process with `my_pid - 1` matches. |
| 465 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::OtherProcessrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#OtherProcess# if depth rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().1 => { |
| 466 |
let sibling = info.naive_sibling_processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#naive_sibling_process().(current_pid); |
| 467 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(proc) = sibling { |
| •468 |
if let ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(result) = extract_args(&proc.cmdrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#cmd().()) { |
| 469 |
return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(result); |
| 470 |
} |
| 471 |
} |
| 472 |
} |
| 473 |
// This check is not done for the parent's parent etc. |
| 474 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::OtherProcessrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#OtherProcess# => {} |
| 475 |
} |
| 476 |
current_pid = parent_pid; |
| 477 |
} |
| 478 |
|
| 479 |
/* |
| 480 |
3) Neither parent(s) nor the direct sibling were a match. |
| 481 |
The most likely case is that the input program of the pipe wrote all its data and exited before delta |
| 482 |
started, so no command line can be parsed. Same if the data was piped from an input file. |
| 483 |
|
| 484 |
There might also be intermediary scripts in between or piped input with a gap in pids or (rarely) |
| 485 |
randomized pids, so check processes for the closest match in the process tree. |
| 486 |
The size of this process tree can be reduced by only refreshing selected processes. |
| 487 |
|
| 488 |
100 /usr/bin/some-terminal-emulator |
| 489 |
124 \_ -shell |
| 490 |
301 | \_ /usr/bin/git blame src/main.rs |
| 491 |
302 | \_ wraps_delta.sh |
| 492 |
303 | \_ delta |
| 493 |
304 | \_ less --RAW-CONTROL-CHARS --quit-if-one-screen |
| 494 |
125 \_ -shell |
| 495 |
800 | \_ /usr/bin/git blame src/main.rs |
| 496 |
200 | \_ delta |
| 497 |
400 | \_ less --RAW-CONTROL-CHARS --quit-if-one-screen |
| 498 |
126 \_ -shell |
| 499 |
501 | \_ /bin/sh /wrapper/for/git blame src/main.rs |
| 500 |
555 | | \_ /usr/bin/git blame src/main.rs |
| 501 |
502 | \_ delta |
| 502 |
567 | \_ less --RAW-CONTROL-CHARS --quit-if-one-screen |
| 503 |
|
| 504 |
*/ |
| 505 |
|
| 506 |
// Also `add` because `A_has_pid101 | delta_has_pid102`, but if A is a wrapper which then calls |
| 507 |
// git (no `exec`), then the final pid of the git process might be 103 or greater. |
| 508 |
let pid_range = my_pid.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]saturating_sub().(10)..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#my_pid.saturating_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]saturating_add().(10); |
| 509 |
for p in pid_range { |
| 510 |
// Processes which were not refreshed do not exist for sysinfo, so by selectively |
| 511 |
// letting it know about processes the `find_sibling..` function will only |
| 512 |
// consider these. |
| 513 |
if info.processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#process().(p).is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 514 |
info.refresh_processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#refresh_process().(p); |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
match info.find_sibling_in_refreshed_processesrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#find_sibling_in_refreshed_processes().(my_pid, &extract_args) { |
| 519 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 520 |
#[cfg(not(target_os = "linux"))] |
| 521 |
let full_scan = true; |
| 522 |
|
| 523 |
// The full scan is expensive on Linux and rarely successful, so disable it by default. |
| 524 |
#[cfg(target_os = "linux")] |
| 525 |
let full_scan = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("DELTA_CALLING_PROCESS_QUERY_ALL") |
| 526 |
.is_ok_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok_and().(|v| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().["0", "false", "no"].iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|&n| n rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`&str`][`PartialEq<String>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`&str`][`PartialEq<String>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`&str`][`PartialEq<String>`]eq().v)); |
| 527 |
|
| 528 |
if full_scan { |
| 529 |
info.refresh_processesrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#refresh_processes().(); |
| 530 |
info.find_sibling_in_refreshed_processesrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#find_sibling_in_refreshed_processes().(my_pid, &extract_args) |
| 531 |
} else { |
| 532 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 533 |
} |
| 534 |
} |
| 535 |
some => some, |
| 536 |
} |
| 537 |
} |
| 538 |
|
| 539 |
// Walk up the process tree, calling `f` with the pid and the distance to `starting_pid`. |
| 540 |
// Prerequisite: `info.refresh_processes()` has been called. |
| 541 |
fn iter_parentsrust-analyzer cargo git-delta 0.19.2 utils/process/iter_parents().<P, F>(info: &P, starting_pid: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#, f: F) |
| 542 |
where |
| 543 |
P: ProcessInterfacerust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#, |
| 544 |
F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#, usize), |
| 545 |
{ |
| 546 |
fn inner_iter_parentsrust-analyzer cargo git-delta 0.19.2 utils/process/inner_iter_parents().<P, F>(info: &P, pid: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#, mut f: F, distance: usize) |
| 547 |
where |
| 548 |
P: ProcessInterfacerust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#, |
| 549 |
F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(u32, usize), |
| 550 |
{ |
| 551 |
// Probably bad input, not a tree: |
| 552 |
if distance rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().2000 { |
| 553 |
return; |
| 554 |
} |
| 555 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(proc) = info.processrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#process().(pid) { |
| 556 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pid) = proc.parentrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions#parent().() { |
| 557 |
f(pid, distance); |
| 558 |
inner_iter_parentsrust-analyzer cargo git-delta 0.19.2 utils/process/inner_iter_parents().(info, pid, f, distance rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) |
| 559 |
} |
| 560 |
} |
| 561 |
} |
| 562 |
inner_iter_parentsrust-analyzer cargo git-delta 0.19.2 utils/process/inner_iter_parents().(info, starting_pid, f, 1) |
| 563 |
} |
| 564 |
|
| 565 |
#[cfg(test)] |
| 566 |
pub mod testsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/ { |
| 567 |
|
| 568 |
use superrust-analyzer cargo git-delta 0.19.2 utils/process/::*; |
| 569 |
|
| 570 |
use itertoolsrust-analyzer cargo itertools 0.14.0 crate/::Itertoolsrust-analyzer cargo itertools 0.14.0 Itertools#; |
| 571 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/::RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#; |
| 572 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#; |
| 573 |
|
| 574 |
thread_localrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/local/thread_local!! { |
| 575 |
static FAKE_ARGSrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FAKE_ARGS.: RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>> = const { RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]new().(TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Nonerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#None#) }; |
| 576 |
} |
| 577 |
|
| 578 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 579 |
enum TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#<T> { |
| 580 |
Oncerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Once#(T), |
| 581 |
Scoperust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Scope#(T), |
| 582 |
Withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#With#(usize, Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T>>), |
| 583 |
Nonerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#None#, |
| 584 |
Invalidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Invalid#, |
| 585 |
ErrorAlreadyHandledrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#ErrorAlreadyHandled#, |
| 586 |
} |
| 587 |
|
| 588 |
// When calling `FakeParentArgs::get()`, it can return `Some(values)` which were set earlier |
| 589 |
// during in the #[test]. Otherwise returns None. |
| 590 |
// This value can be valid once: `FakeParentArgs::once(val)`, for the entire scope: |
| 591 |
// `FakeParentArgs::for_scope(val)`, or can be different values every time `get()` is called: |
| 592 |
// `FakeParentArgs::with([val1, val2, val3])`. |
| 593 |
// It is an error if `once` or `with` values remain unused, or are overused. |
| 594 |
// Note: The values are stored per-thread, so the expectation is that no thread boundaries are |
| 595 |
// crossed. |
| 596 |
pub struct FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs# {} |
| 597 |
impl FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs# { |
| 598 |
pub fn oncerust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]once().(args: &str) -> Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs] { |
| 599 |
Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]::newrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]new().(args, TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Oncerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Once#, "once") |
| 600 |
} |
| 601 |
pub fn for_scoperust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]for_scope().(args: &str) -> Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs] { |
| 602 |
Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]::newrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]new().(args, TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Scoperust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Scope#, "for_scope") |
| 603 |
} |
| 604 |
fn newrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]new().<F>(args: &str, initial: F, from_: &str) -> Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs] |
| 605 |
where |
| 606 |
F: Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) -> TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>, |
| 607 |
{ |
| 608 |
let string_vec = args.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(' ').maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(str::to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 609 |
if FAKE_ARGSrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FAKE_ARGS..withrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/local/impl#[`LocalKey<T>`]with().(|a| a.replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]replace().(initial(string_vec))) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Nonerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#None# { |
| 610 |
Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]::errorrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]error().(from_); |
| 611 |
} |
| 612 |
FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs# {} |
| 613 |
} |
| 614 |
pub fn withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]with().(args: &[&str]) -> Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs] { |
| 615 |
let with = TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#With#( |
| 616 |
0, |
| 617 |
Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T>`]new().( |
| 618 |
args.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 619 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|a| a.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(' ').maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(str::to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()) |
| 620 |
.collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 621 |
), |
| 622 |
); |
| 623 |
if FAKE_ARGSrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FAKE_ARGS..withrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/local/impl#[`LocalKey<T>`]with().(|a| a.replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]replace().(with)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Nonerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#None# || args.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() { |
| 624 |
Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]::errorrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]error().("with creation"); |
| 625 |
} |
| 626 |
FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs# {} |
| 627 |
} |
| 628 |
pub fn getrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]get().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>> { |
| 629 |
FAKE_ARGSrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FAKE_ARGS..withrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/local/impl#[`LocalKey<T>`]with().(|a| { |
| 630 |
let old_value = a.replace_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]replace_with().(|old_value| match old_value { |
| 631 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Oncerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Once#(_) => TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Invalidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Invalid#, |
| 632 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Scoperust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Scope#(args) => TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Scoperust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Scope#(args.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().()), |
| 633 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#With#(n, args) => TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#With#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1, Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Clone]clone().(args)), |
| 634 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Nonerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#None# => TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Nonerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#None#, |
| 635 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Invalidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Invalid# => TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Invalidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Invalid#, |
| 636 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::ErrorAlreadyHandledrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#ErrorAlreadyHandled# => TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::ErrorAlreadyHandledrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#ErrorAlreadyHandled#, |
| 637 |
}); |
| 638 |
|
| 639 |
match old_value { |
| 640 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Oncerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Once#(args) | TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Scoperust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Scope#(args) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(args), |
| 641 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#With#(n, args) if n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().args.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(args[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().n]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().()), |
| 642 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Nonerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#None# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 643 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Invalidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Invalid# | TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#With#(_, _) | TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::ErrorAlreadyHandledrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#ErrorAlreadyHandled# => { |
| 644 |
Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]::errorrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]error().("get"); |
| 645 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 646 |
} |
| 647 |
} |
| 648 |
}) |
| 649 |
} |
| 650 |
pub fn are_setrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]are_set().() -> bool { |
| 651 |
FAKE_ARGSrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FAKE_ARGS..withrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/local/impl#[`LocalKey<T>`]with().(|a| { |
| 652 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Ref<'_, T>`][Deref]deref().a.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Nonerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#None# && *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Ref<'_, T>`][Deref]deref().a.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::ErrorAlreadyHandledrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#ErrorAlreadyHandled# |
| 653 |
}) |
| 654 |
} |
| 655 |
fn errorrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]error().(where_: &str) { |
| 656 |
FAKE_ARGSrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FAKE_ARGS..withrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/local/impl#[`LocalKey<T>`]with().(|a| { |
| 657 |
let old_value = a.replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]replace().(TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::ErrorAlreadyHandledrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#ErrorAlreadyHandled#); |
| 658 |
|
| 659 |
match old_value { |
| 660 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::ErrorAlreadyHandledrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#ErrorAlreadyHandled# => (), |
| 661 |
_ => { |
| 662 |
panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!( |
| 663 |
"test logic error (in {}): wrong FakeParentArgs scope?", |
| 664 |
where_ |
| 665 |
); |
| 666 |
} |
| 667 |
} |
| 668 |
}); |
| 669 |
} |
| 670 |
} |
| 671 |
impl Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs# { |
| 672 |
fn droprust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs][Drop]drop().(&mut self) { |
| 673 |
// Clears an Invalid state and tests if a Once or With value has been used. |
| 674 |
FAKE_ARGSrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FAKE_ARGS..withrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/local/impl#[`LocalKey<T>`]with().(|a| { |
| 675 |
let old_value = a.replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]replace().(TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Nonerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#None#); |
| 676 |
match old_value { |
| 677 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#With#(n, args) => { |
| 678 |
if n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().args.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() { |
| 679 |
Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs][Drop]::errorrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]error().("drop with") |
| 680 |
} |
| 681 |
} |
| 682 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Oncerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Once#(_) | TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Nonerust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#None# => Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs][Drop]::errorrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]error().("drop"), |
| 683 |
TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Scoperust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Scope#(_) | TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::Invalidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#Invalid# | TlsStaterust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#::ErrorAlreadyHandledrust-analyzer cargo git-delta 0.19.2 utils/process/tests/TlsState#ErrorAlreadyHandled# => {} |
| 684 |
} |
| 685 |
}); |
| 686 |
} |
| 687 |
} |
| 688 |
|
| 689 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 690 |
struct FakeProcrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc# { |
| 691 |
#[allow(dead_code)] |
| 692 |
pidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#pid.: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#, |
| 693 |
start_timerust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#start_time.: u64, |
| 694 |
cmdrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#cmd.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 695 |
ppidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#ppid.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#>, |
| 696 |
} |
| 697 |
impl FakeProcrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc# { |
| 698 |
fn newrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeProc]new().(pid: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#, start_time: u64, cmd: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, ppid: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#>) -> Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeProc] { |
| 699 |
FakeProcrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc# { |
| 700 |
pidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#pid., |
| 701 |
start_timerust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#start_time., |
| 702 |
cmdrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#cmd., |
| 703 |
ppidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#ppid., |
| 704 |
} |
| 705 |
} |
| 706 |
} |
| 707 |
|
| 708 |
impl ProcActionsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcActions# for FakeProcrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc# { |
| •709 |
fn cmdrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeProc][ProcActions]cmd().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 710 |
self.cmdrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#cmd..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().() |
| 711 |
} |
| 712 |
fn parentrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeProc][ProcActions]parent().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#> { |
| 713 |
self.ppidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#ppid. |
| 714 |
} |
| 715 |
fn pidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeProc][ProcActions]pid().(&self) -> DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid# { |
| 716 |
self.pidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#pid. |
| 717 |
} |
| 718 |
fn start_timerust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeProc][ProcActions]start_time().(&self) -> u64 { |
| 719 |
self.start_timerust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#start_time. |
| 720 |
} |
| 721 |
} |
| 722 |
|
| 723 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 724 |
struct MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo# { |
| 725 |
delta_pidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#delta_pid.: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#, |
| 726 |
inforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#info.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Pidrust-analyzer cargo sysinfo 0.39.6 common/system/Pid#, FakeProcrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#>, |
| 727 |
} |
| 728 |
impl MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo# { |
| 729 |
fn withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(processes: &[(DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#, u64, &str, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#>)]) -> Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo] { |
| 730 |
MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo# { |
| 731 |
delta_pidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#delta_pid.: processes.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|p| p.0).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(1), |
| 732 |
inforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#info.: processes |
| 733 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 734 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(pid, start_time, cmd, ppid)| { |
| 735 |
let cmd_vec = cmd.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(' ').maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(str::to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 736 |
( |
| 737 |
Pidrust-analyzer cargo sysinfo 0.39.6 common/system/Pid#::from_u32rust-analyzer cargo sysinfo 0.39.6 common/system/impl#[Pid]from_u32().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().pid), |
| 738 |
FakeProcrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#::newrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeProc]new().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().pid, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().start_time, cmd_vec, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ppid), |
| 739 |
) |
| 740 |
}) |
| 741 |
.collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 742 |
} |
| 743 |
} |
| 744 |
} |
| 745 |
|
| 746 |
impl ProcessInterfacerust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface# for MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo# { |
| 747 |
type Outrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo][ProcessInterface]Out# = FakeProcrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeProc#; |
| 748 |
|
| 749 |
fn my_pidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo][ProcessInterface]my_pid().(&self) -> DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid# { |
| 750 |
self.delta_pidrust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#delta_pid. |
| 751 |
} |
| 752 |
fn processrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo][ProcessInterface]process().(&self, pid: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo][ProcessInterface]::Outrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#Out#> { |
| 753 |
self.inforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#info..getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&Pidrust-analyzer cargo sysinfo 0.39.6 common/system/Pid#::from_u32rust-analyzer cargo sysinfo 0.39.6 common/system/impl#[Pid]from_u32().(pid)) |
| 754 |
} |
| 755 |
fn processesrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo][ProcessInterface]processes().(&self) -> &HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Pidrust-analyzer cargo sysinfo 0.39.6 common/system/Pid#, Selfrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo][ProcessInterface]::Outrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessInterface#Out#> { |
| 756 |
&self.inforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#info. |
| 757 |
} |
| 758 |
fn refresh_processesrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo][ProcessInterface]refresh_processes().(&mut self) {} |
| 759 |
fn refresh_processrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo][ProcessInterface]refresh_process().(&mut self, _pid: DeltaPidrust-analyzer cargo git-delta 0.19.2 utils/process/DeltaPid#) -> bool { |
| 760 |
true |
| 761 |
} |
| 762 |
} |
| 763 |
|
| 764 |
fn setrust-analyzer cargo git-delta 0.19.2 utils/process/tests/set().(arg1: &[&str]) -> HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 765 |
arg1.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|&s| s.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 766 |
} |
| 767 |
|
| 768 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 769 |
fn test_process_testingrust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_process_testing().() { |
| 770 |
{ |
| 771 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::oncerust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]once().("git blame hello"); |
| 772 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 773 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(), describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 774 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 775 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 776 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 777 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("hello".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 778 |
})) |
| 779 |
); |
| 780 |
} |
| 781 |
{ |
| 782 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::oncerust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]once().("git blame world.txt"); |
| 783 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 784 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(), describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 785 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 786 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 787 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 788 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("world.txt".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 789 |
})) |
| 790 |
); |
| 791 |
} |
| 792 |
{ |
| 793 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::for_scoperust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]for_scope().("git blame hello world.txt"); |
| 794 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 795 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(), describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 796 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 797 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 798 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 799 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("world.txt".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 800 |
})) |
| 801 |
); |
| 802 |
} |
| 803 |
} |
| 804 |
|
| 805 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 806 |
#[should_panic(expected = "test logic error (in get): wrong FakeParentArgs scope?")] |
| 807 |
fn test_process_testing_assertrust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_process_testing_assert().() { |
| 808 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::oncerust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]once().("git blame do.not.panic"); |
| 809 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 810 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(), describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 811 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 812 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 813 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 814 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("do.not.panic".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 815 |
})) |
| 816 |
); |
| 817 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(), describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().); |
| 818 |
} |
| 819 |
|
| 820 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 821 |
#[should_panic(expected = "test logic error (in drop): wrong FakeParentArgs scope?")] |
| 822 |
fn test_process_testing_assert_once_never_usedrust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_process_testing_assert_once_never_used().() { |
| 823 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::oncerust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]once().("never used"); |
| 824 |
} |
| 825 |
|
| 826 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 827 |
#[should_panic(expected = "test logic error (in once): wrong FakeParentArgs scope?")] |
| 828 |
fn test_process_testing_assert_for_scope_never_usedrust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_process_testing_assert_for_scope_never_used().() { |
| 829 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::for_scoperust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]for_scope().(&"never used"); |
| 830 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::oncerust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]once().(&"never used"); |
| 831 |
} |
| 832 |
|
| 833 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 834 |
#[should_panic(expected = "test logic error (in for_scope): wrong FakeParentArgs scope?")] |
| 835 |
fn test_process_testing_assert_once_never_used2rust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_process_testing_assert_once_never_used2().() { |
| 836 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::oncerust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]once().(&"never used"); |
| 837 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::for_scoperust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]for_scope().(&"never used"); |
| 838 |
} |
| 839 |
|
| 840 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 841 |
fn test_process_testing_scope_can_remain_unusedrust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_process_testing_scope_can_remain_unused().() { |
| 842 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::for_scoperust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]for_scope().("never used"); |
| 843 |
} |
| 844 |
|
| 845 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 846 |
fn test_process_testing_n_timesrust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_process_testing_n_times().() { |
| 847 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]with().(&["git blame once", "git blame twice"]); |
| 848 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 849 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(), describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 850 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 851 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 852 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 853 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("once".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 854 |
})) |
| 855 |
); |
| 856 |
|
| 857 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 858 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(), describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 859 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 860 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 861 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 862 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("twice".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 863 |
})) |
| 864 |
); |
| 865 |
} |
| 866 |
|
| 867 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 868 |
#[should_panic(expected = "test logic error (in drop with): wrong FakeParentArgs scope?")] |
| 869 |
fn test_process_testing_n_times_unusedrust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_process_testing_n_times_unused().() { |
| 870 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]with().(&["git blame once", "git blame twice"]); |
| 871 |
} |
| 872 |
|
| 873 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 874 |
#[should_panic(expected = "test logic error (in drop with): wrong FakeParentArgs scope?")] |
| 875 |
fn test_process_testing_n_times_underusedrust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_process_testing_n_times_underused().() { |
| 876 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]with().(&["git blame once", "git blame twice"]); |
| 877 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 878 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(), describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 879 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 880 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 881 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 882 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("once".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 883 |
})) |
| 884 |
); |
| 885 |
} |
| 886 |
|
| 887 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 888 |
#[should_panic(expected = "test logic error (in get): wrong FakeParentArgs scope?")] |
| 889 |
fn test_process_testing_n_times_overusedrust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_process_testing_n_times_overused().() { |
| 890 |
let _args = FakeParentArgsrust-analyzer cargo git-delta 0.19.2 utils/process/tests/FakeParentArgs#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[FakeParentArgs]with().(&["git blame once"]); |
| 891 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 892 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(), describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 893 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 894 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 895 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 896 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("once".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 897 |
})) |
| 898 |
); |
| 899 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(), describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().); |
| 900 |
} |
| 901 |
|
| 902 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 903 |
fn test_describe_calling_process_blamerust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_describe_calling_process_blame().() { |
| 904 |
let no_processes = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[]); |
| 905 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 906 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(no_processes, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 907 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 908 |
); |
| 909 |
|
| 910 |
let two_trees = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 911 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 912 |
(3, 100, "git blame src/main.rs", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 913 |
(4, 100, "call_delta.sh", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 914 |
(5, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4)), |
| 915 |
]); |
| 916 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 917 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(two_trees, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 918 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 919 |
); |
| 920 |
|
| 921 |
let no_options_command_line = CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 922 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 923 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 924 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("hello.txt".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 925 |
}; |
| 926 |
let parent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 927 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 928 |
(3, 100, "git blame hello.txt", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 929 |
(4, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 930 |
]); |
| 931 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 932 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(parent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 933 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(no_options_command_line.clonerust-analyzer cargo git-delta 0.19.2 utils/process/impl#[CommandLine][Clone]clone().())) |
| 934 |
); |
| 935 |
|
| 936 |
let parent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 937 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 938 |
(3, 100, "git blame -- hello.txt", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 939 |
(4, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 940 |
]); |
| 941 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 942 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(parent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 943 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(no_options_command_line.clonerust-analyzer cargo git-delta 0.19.2 utils/process/impl#[CommandLine][Clone]clone().())) |
| 944 |
); |
| 945 |
|
| 946 |
let parent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 947 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 948 |
(3, 100, "git blame -- --not.an.argument", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 949 |
(4, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 950 |
]); |
| 951 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 952 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(parent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 953 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 954 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 955 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 956 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("--not.an.argument".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 957 |
})) |
| 958 |
); |
| 959 |
|
| 960 |
let parent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 961 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 962 |
(3, 100, "git blame --help.txt", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 963 |
(4, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 964 |
]); |
| 965 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 966 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(parent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 967 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 968 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: ["--help.txt".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 969 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 970 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 971 |
})) |
| 972 |
); |
| 973 |
|
| 974 |
let parent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 975 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 976 |
(3, 100, "git blame --", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 977 |
(4, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 978 |
]); |
| 979 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 980 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(parent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 981 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 982 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 983 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 984 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 985 |
})) |
| 986 |
); |
| 987 |
|
| 988 |
let parent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 989 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 990 |
(3, 100, "Git.exe blame hello.txt", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 991 |
(4, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 992 |
]); |
| 993 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 994 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(parent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 995 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(no_options_command_line.clonerust-analyzer cargo git-delta 0.19.2 utils/process/impl#[CommandLine][Clone]clone().())) |
| 996 |
); |
| 997 |
|
| 998 |
let git_blame_command = |
| 999 |
"git -c a=b blame -fnb --incremental -t --color-by-age -M --since=3.weeks --contents annotation.txt -C -C2 hello.txt"; |
| 1000 |
|
| 1001 |
// here -C2 is parsed as -C and -2. It doesn't really matters because we only use last_arg from options |
| 1002 |
// to determine the file type. |
| 1003 |
let expected_result = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 1004 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: setrust-analyzer cargo git-delta 0.19.2 utils/process/tests/set().(&["--incremental", "--color-by-age", "--since", "--contents"]), |
| 1005 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: setrust-analyzer cargo git-delta 0.19.2 utils/process/tests/set().(&["-f", "-n", "-b", "-t", "-M", "-C", "-2"]), |
| 1006 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("hello.txt".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 1007 |
})); |
| 1008 |
|
| 1009 |
let parent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 1010 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1011 |
(3, 100, git_blame_command, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 1012 |
(4, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1013 |
]); |
| 1014 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1015 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(parent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 1016 |
expected_result |
| 1017 |
); |
| 1018 |
|
| 1019 |
let grandparent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 1020 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1021 |
(3, 100, git_blame_command, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 1022 |
(4, 100, "call_delta.sh", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1023 |
(5, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4)), |
| 1024 |
]); |
| 1025 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1026 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(grandparent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 1027 |
expected_result |
| 1028 |
); |
| 1029 |
|
| 1030 |
let sibling = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 1031 |
(2, 100, "-xterm", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1032 |
(3, 100, "-shell", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 1033 |
(4, 100, "git blame src/main.rs", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1034 |
(5, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1035 |
]); |
| 1036 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1037 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(sibling, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 1038 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 1039 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 1040 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 1041 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("src/main.rs".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 1042 |
})) |
| 1043 |
); |
| 1044 |
|
| 1045 |
let indirect_sibling = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 1046 |
(2, 100, "-xterm", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1047 |
(3, 100, "-shell", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 1048 |
(4, 100, "Git.exe blame --correct src/main.abc", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1049 |
( |
| 1050 |
10, |
| 1051 |
100, |
| 1052 |
"Git.exe blame --ignored-child src/main.def", |
| 1053 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4), |
| 1054 |
), |
| 1055 |
(5, 100, "delta.sh", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1056 |
(20, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5)), |
| 1057 |
]); |
| 1058 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1059 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(indirect_sibling, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 1060 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 1061 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: setrust-analyzer cargo git-delta 0.19.2 utils/process/tests/set().(&["--correct"]), |
| 1062 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 1063 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("src/main.abc".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 1064 |
})) |
| 1065 |
); |
| 1066 |
|
| 1067 |
let indirect_sibling2 = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 1068 |
(2, 100, "-xterm", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1069 |
(3, 100, "-shell", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 1070 |
(4, 100, "git wrap src/main.abc", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1071 |
(10, 100, "git blame src/main.def", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4)), |
| 1072 |
(5, 100, "delta.sh", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1073 |
(20, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5)), |
| 1074 |
]); |
| 1075 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1076 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(indirect_sibling2, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 1077 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 1078 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 1079 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 1080 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("src/main.def".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 1081 |
})) |
| 1082 |
); |
| 1083 |
|
| 1084 |
// 3 blame processes, 2 with matching start times, pick the one with lower |
| 1085 |
// distance but larger start time difference. |
| 1086 |
let indirect_sibling_start_times = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 1087 |
(2, 100, "-xterm", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1088 |
(3, 100, "-shell", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 1089 |
(4, 109, "git wrap src/main.abc", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1090 |
(10, 109, "git blame src/main.def", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4)), |
| 1091 |
(20, 100, "git wrap1 src/main.abc", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1092 |
(21, 100, "git wrap2 src/main.def", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(20)), |
| 1093 |
(22, 101, "git blame src/main.not", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(21)), |
| 1094 |
(23, 102, "git blame src/main.this", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(20)), |
| 1095 |
(5, 100, "delta.sh", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1096 |
(20, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5)), |
| 1097 |
]); |
| 1098 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1099 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(indirect_sibling_start_times, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 1100 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitBlamerust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitBlame#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 1101 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 1102 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 1103 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("src/main.this".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 1104 |
})) |
| 1105 |
); |
| 1106 |
} |
| 1107 |
|
| 1108 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1109 |
fn test_describe_calling_process_greprust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_describe_calling_process_grep().() { |
| 1110 |
let no_processes = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[]); |
| 1111 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1112 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(no_processes, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 1113 |
Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 1114 |
); |
| 1115 |
|
| 1116 |
let empty_command_line = CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 1117 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 1118 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: [].intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 1119 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("hello.txt".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 1120 |
}; |
| 1121 |
let parent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 1122 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1123 |
(3, 100, "git grep pattern hello.txt", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 1124 |
(4, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1125 |
]); |
| 1126 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1127 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(parent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 1128 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitGreprust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitGrep#(empty_command_line.clonerust-analyzer cargo git-delta 0.19.2 utils/process/impl#[CommandLine][Clone]clone().())) |
| 1129 |
); |
| 1130 |
|
| 1131 |
let parent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 1132 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1133 |
(3, 100, "Git.exe grep pattern hello.txt", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 1134 |
(4, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1135 |
]); |
| 1136 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1137 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(parent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 1138 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitGreprust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitGrep#(empty_command_line)) |
| 1139 |
); |
| 1140 |
|
| 1141 |
for grep_command in &[ |
| 1142 |
"/usr/local/bin/rg pattern hello.txt", |
| 1143 |
"RG.exe pattern hello.txt", |
| 1144 |
"/usr/local/bin/ack pattern hello.txt", |
| 1145 |
"ack.exe pattern hello.txt", |
| 1146 |
] { |
| 1147 |
let parent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 1148 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1149 |
(3, 100, grep_command, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 1150 |
(4, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1151 |
]); |
| 1152 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1153 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(parent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 1154 |
Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::OtherGreprust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#OtherGrep#) |
| 1155 |
); |
| 1156 |
} |
| 1157 |
|
| 1158 |
let git_grep_command = |
| 1159 |
"git grep -ab --function-context -n --show-function -W --foo=val pattern hello.txt"; |
| 1160 |
|
| 1161 |
let expected_result = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitGreprust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitGrep#(CommandLinerust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine# { |
| 1162 |
long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options.: setrust-analyzer cargo git-delta 0.19.2 utils/process/tests/set().(&["--function-context", "--show-function", "--foo"]), |
| 1163 |
short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options.: setrust-analyzer cargo git-delta 0.19.2 utils/process/tests/set().(&["-a", "-b", "-n", "-W"]), |
| 1164 |
last_argrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#last_arg.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("hello.txt".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 1165 |
})); |
| 1166 |
|
| 1167 |
let parent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 1168 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1169 |
(3, 100, git_grep_command, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 1170 |
(4, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1171 |
]); |
| 1172 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1173 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(parent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 1174 |
expected_result |
| 1175 |
); |
| 1176 |
|
| 1177 |
let grandparent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 1178 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1179 |
(3, 100, git_grep_command, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 1180 |
(4, 100, "call_delta.sh", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1181 |
(5, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4)), |
| 1182 |
]); |
| 1183 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1184 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(grandparent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().), |
| 1185 |
expected_result |
| 1186 |
); |
| 1187 |
} |
| 1188 |
|
| 1189 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1190 |
fn test_describe_calling_process_git_showrust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_describe_calling_process_git_show().() { |
| 1191 |
for (command, expected_extension) in [ |
| 1192 |
( |
| 1193 |
"/usr/local/bin/git show --abbrev-commit -w 775c3b84:./src/hello.rs", |
| 1194 |
"hello.rs", |
| 1195 |
), |
| 1196 |
( |
| 1197 |
"/usr/local/bin/git show --abbrev-commit -w HEAD~1:Makefile", |
| 1198 |
"Makefile", |
| 1199 |
), |
| 1200 |
( |
| 1201 |
"git -c x.y=z show --abbrev-commit -w 775c3b84:./src/hello.bye.R", |
| 1202 |
"hello.bye.R", |
| 1203 |
), |
| 1204 |
] { |
| 1205 |
let parent = MockProcInforust-analyzer cargo git-delta 0.19.2 utils/process/tests/MockProcInfo#::withrust-analyzer cargo git-delta 0.19.2 utils/process/tests/impl#[MockProcInfo]with().(&[ |
| 1206 |
(2, 100, "-shell", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 1207 |
(3, 100, command, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), |
| 1208 |
(4, 100, "delta", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), |
| 1209 |
]); |
| 1210 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CallingProcessrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#::GitShowrust-analyzer cargo git-delta 0.19.2 utils/process/CallingProcess#GitShow#(cmd_line, filename)) = |
| 1211 |
calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(parent, describe_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/describe_calling_process().) |
| 1212 |
{ |
| 1213 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd_line.long_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#long_options., setrust-analyzer cargo git-delta 0.19.2 utils/process/tests/set().(&["--abbrev-commit"])); |
| 1214 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd_line.short_optionsrust-analyzer cargo git-delta 0.19.2 utils/process/CommandLine#short_options., setrust-analyzer cargo git-delta 0.19.2 utils/process/tests/set().(&["-w"])); |
| 1215 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(filename, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(expected_extension.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 1216 |
} else { |
| 1217 |
unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(); |
| 1218 |
} |
| 1219 |
} |
| 1220 |
} |
| 1221 |
|
| 1222 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1223 |
fn test_process_calling_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/tests/test_process_calling_cmdline().() { |
| 1224 |
// GitHub runs CI tests for arm under qemu where sysinfo can not find the parent process. |
| 1225 |
if stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/vars().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(|(key, _)| key rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."CROSS_RUNNER" || key rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."QEMU_LD_PREFIX") { |
| 1226 |
return; |
| 1227 |
} |
| 1228 |
|
| 1229 |
let mut info = ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(); |
| 1230 |
info.refresh_processesrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo][ProcessInterface]refresh_processes().(); |
| 1231 |
let mut ppid_distance = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 1232 |
|
| 1233 |
iter_parentsrust-analyzer cargo git-delta 0.19.2 utils/process/iter_parents().(&info, stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::processrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/::idrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/id().(), |pid, distance| { |
| 1234 |
ppid_distance.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(pid as i32); |
| 1235 |
ppid_distance.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(distance as i32) |
| 1236 |
}); |
| 1237 |
|
| 1238 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(ppid_distance[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). == 1); |
| 1239 |
|
| 1240 |
fn find_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/tests/find_calling_process().(args: &[Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#], want: &[&str]) -> ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#<()> { |
| 1241 |
if args.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|have| want.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|want| want rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().have)) { |
| 1242 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::Argsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#Args#(()) |
| 1243 |
} else { |
| 1244 |
ProcessArgsrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#::ArgErrorrust-analyzer cargo git-delta 0.19.2 utils/process/ProcessArgs#ArgError# |
| 1245 |
} |
| 1246 |
} |
| 1247 |
|
| 1248 |
// Tests that caller is something like "cargo test" or "cargo tarpaulin" |
| 1249 |
let find_test = |args: &[Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#]| find_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/tests/find_calling_process().(args, &["t", "test", "tarpaulin"]); |
| 1250 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(info, find_test), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(())); |
| 1251 |
|
| 1252 |
let nonsense = ppid_distance |
| 1253 |
.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 1254 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|i| i.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 1255 |
.joinrust-analyzer cargo itertools 0.14.0 Itertools#join().("Y40ii4RihK6lHiK4BDsGSx"); |
| 1256 |
|
| 1257 |
let find_nothing = |args: &[Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#]| find_calling_processrust-analyzer cargo git-delta 0.19.2 utils/process/tests/find_calling_process().(args, &[&nonsense]); |
| 1258 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(calling_process_cmdlinerust-analyzer cargo git-delta 0.19.2 utils/process/calling_process_cmdline().(ProcInforust-analyzer cargo git-delta 0.19.2 utils/process/ProcInfo#::newrust-analyzer cargo git-delta 0.19.2 utils/process/impl#[ProcInfo]new().(), find_nothing), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1259 |
} |
| 1260 |
} |