Debian Codegraph @

tests/root.rs

raw symbols SCIP
1 mod rootrust-analyzer cargo rust-apt 0.8.0 root/ {
2 use rust_aptrust-analyzer cargo rust-apt 0.8.0 crate/::configrust-analyzer cargo rust-apt 0.8.0 config/::Configrust-analyzer cargo rust-apt 0.8.0 config/Config#;
3 use rust_aptrust-analyzer cargo rust-apt 0.8.0 crate/::new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!;
4 use rust_aptrust-analyzer cargo rust-apt 0.8.0 crate/::progressrust-analyzer cargo rust-apt 0.8.0 progress/::{AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#, DynAcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress#, InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#};
5 use rust_aptrust-analyzer cargo rust-apt 0.8.0 crate/::rawrust-analyzer cargo rust-apt 0.8.0 raw/::{AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#, ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#, ItemStaterust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemState#, PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#};
6 use rust_aptrust-analyzer cargo rust-apt 0.8.0 crate/::utilrust-analyzer cargo rust-apt 0.8.0 util/::*;
7
8 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
9 fn lockrust-analyzer cargo rust-apt 0.8.0 root/lock().() {
10 apt_lockrust-analyzer cargo rust-apt 0.8.0 util/apt_lock().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
11 apt_lockrust-analyzer cargo rust-apt 0.8.0 util/apt_lock().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
12 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(apt_is_lockedrust-analyzer cargo rust-apt 0.8.0 util/apt_is_locked().());
13
14 apt_unlockrust-analyzer cargo rust-apt 0.8.0 util/apt_unlock().();
15 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(apt_is_lockedrust-analyzer cargo rust-apt 0.8.0 util/apt_is_locked().());
16
17 apt_unlockrust-analyzer cargo rust-apt 0.8.0 util/apt_unlock().();
18 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().apt_is_lockedrust-analyzer cargo rust-apt 0.8.0 util/apt_is_locked().());
19 }
20
21 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
22 fn updaterust-analyzer cargo rust-apt 0.8.0 root/update().() {
23 struct Progressrust-analyzer cargo rust-apt 0.8.0 root/Progress# {}
24
25 impl DynAcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/DynAcquireProgress# for Progressrust-analyzer cargo rust-apt 0.8.0 root/Progress# {
26 fn pulse_intervalrust-analyzer cargo rust-apt 0.8.0 root/impl#[Progress][DynAcquireProgress]pulse_interval().(&self) -> usize { 0 }
27
28 fn hitrust-analyzer cargo rust-apt 0.8.0 root/impl#[Progress][DynAcquireProgress]hit().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) {
29 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("\rHit:{} {}", item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().idrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]id().(), item.descriptionrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]description().());
30 }
31
32 fn fetchrust-analyzer cargo rust-apt 0.8.0 root/impl#[Progress][DynAcquireProgress]fetch().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) {
33 let mut string = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("\rGet:{} {}", item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().idrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]id().(), item.descriptionrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]description().());
34
35 let file_size = item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().file_sizerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]file_size().();
36 if file_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().0 {
37 string.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(" [{}]", unit_strrust-analyzer cargo rust-apt 0.8.0 util/unit_str().(file_size, NumSysrust-analyzer cargo rust-apt 0.8.0 util/NumSys#::Decimalrust-analyzer cargo rust-apt 0.8.0 util/NumSys#Decimal#)));
38 }
39
40 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{string}");
41 }
42
43 fn donerust-analyzer cargo rust-apt 0.8.0 root/impl#[Progress][DynAcquireProgress]done().(&mut self, _item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) {}
44
45 fn startrust-analyzer cargo rust-apt 0.8.0 root/impl#[Progress][DynAcquireProgress]start().(&mut self) {}
46
47 fn stoprust-analyzer cargo rust-apt 0.8.0 root/impl#[Progress][DynAcquireProgress]stop().(&mut self, owner: &AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#) {
48 if owner.fetched_bytesrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]fetched_bytes().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().0 {
49 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!(
50 "Fetched {} in {} ({}/s)",
51 unit_strrust-analyzer cargo rust-apt 0.8.0 util/unit_str().(owner.fetched_bytesrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]fetched_bytes().(), NumSysrust-analyzer cargo rust-apt 0.8.0 util/NumSys#::Decimalrust-analyzer cargo rust-apt 0.8.0 util/NumSys#Decimal#),
52 time_strrust-analyzer cargo rust-apt 0.8.0 util/time_str().(owner.elapsed_timerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]elapsed_time().()),
53 unit_strrust-analyzer cargo rust-apt 0.8.0 util/unit_str().(owner.current_cpsrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]current_cps().(), NumSysrust-analyzer cargo rust-apt 0.8.0 util/NumSys#::Decimalrust-analyzer cargo rust-apt 0.8.0 util/NumSys#Decimal#)
54 );
55 } else {
56 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Nothing to fetch.");
57 }
58 }
59
60 fn failrust-analyzer cargo rust-apt 0.8.0 root/impl#[Progress][DynAcquireProgress]fail().(&mut self, item: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) {
61 let mut show_error = true;
62 let error_text = item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().error_textrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]error_text().();
63 let desc = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{} {}", item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().idrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]id().(), item.descriptionrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]description().());
64
65 match item.ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().().statusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]status().() {
66 ItemStaterust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemState#::StatIdlerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemState]StatIdle. | ItemStaterust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemState#::StatDonerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemState]StatDone. => {
67 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("\rIgn: {desc}");
68 if error_text.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().()
69 || Configrust-analyzer cargo rust-apt 0.8.0 config/Config#::newrust-analyzer cargo rust-apt 0.8.0 config/impl#[Config]new().().boolrust-analyzer cargo rust-apt 0.8.0 config/impl#[Config]bool().("Acquire::Progress::Ignore::ShowErrorText", false)
70 {
71 show_error = false;
72 }
73 },
74 _ => {
75 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("\rErr: {desc}");
76 },
77 }
78
79 if show_error {
80 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("\r{error_text}");
81 }
82 }
83
84 fn pulserust-analyzer cargo rust-apt 0.8.0 root/impl#[Progress][DynAcquireProgress]pulse().(&mut self, _status: &AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#, _owner: &PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#) {}
85 }
86
87 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
88
89 // Test the default implementation for it
90 let mut progress = AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#::aptrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]apt().();
91 cache.updaterust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]update().(&mut progress).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
92
93 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
94
95 // Test a new impl for AcquireProgress
96 let mut progress = AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#::newrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]new().(Progressrust-analyzer cargo rust-apt 0.8.0 root/Progress# {});
97 cache.updaterust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]update().(&mut progress).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
98 }
99
100 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
101 fn install_and_removerust-analyzer cargo rust-apt 0.8.0 root/install_and_remove().() {
102 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
103
104 let pkg = cache.getrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]get().("neofetch").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
105
106 pkg.protectrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]protect().();
107 pkg.mark_installrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]mark_install().(true, true);
108 cache.resolverust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]resolve().(false).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
109 dbgrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/dbg!!(pkg.marked_installrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]marked_install().());
110
111 let mut progress = AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#::aptrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]apt().();
112 let mut inst_progress = InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#::aptrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]apt().();
113
114 cache.commitrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]commit().(&mut progress, &mut inst_progress).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
115 // After commit a new cache must be created for more operations
116 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
117
118 // I need to pick a better package. This removes my neofetch every time!
119 let pkg = cache.getrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]get().("neofetch").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
120
121 pkg.mark_deleterust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]mark_delete().(true);
122
123 cache.commitrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]commit().(&mut progress, &mut inst_progress).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
124 }
125
126 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
127 fn install_with_debsrust-analyzer cargo rust-apt 0.8.0 root/install_with_debs().() {
128 let debs = [
129 "tests/files/cache/dep-pkg1_0.0.1.deb",
130 "tests/files/cache/dep-pkg2_0.0.1.deb",
131 ];
132 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!(&debs).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
133
134 let pkg1 = cache.getrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]get().("dep-pkg1").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
135 let pkg2 = cache.getrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]get().("dep-pkg2").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
136
137 pkg1.mark_installrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]mark_install().(true, true);
138 pkg2.mark_installrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]mark_install().(true, true);
139 cache.resolverust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]resolve().(false).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
140
141 let mut progress = AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#::aptrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]apt().();
142 let mut inst_progress = InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#::aptrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]apt().();
143 cache.commitrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]commit().(&mut progress, &mut inst_progress).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
144
145 // You have to get a new cache after using commit.
146 let cache = new_cacherust-analyzer cargo rust-apt 0.8.0 macros/new_cache!!(&debs).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
147
148 // New packages will be required as well.
149 let pkg1 = cache.getrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]get().("dep-pkg1").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
150 let pkg2 = cache.getrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]get().("dep-pkg2").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
151
152 // Leave no trace
153 pkg1.mark_deleterust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]mark_delete().(true);
154 pkg2.mark_deleterust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]mark_delete().(true);
155
156 cache.commitrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]commit().(&mut progress, &mut inst_progress).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
157 }
158 }