|
0 |
Index: grcov/src/defs.rs
|
|
1 |
===================================================================
|
|
2 |
--- grcov.orig/src/defs.rs
|
|
3 |
+++ grcov/src/defs.rs
|
|
4 |
@@ -1,4 +1,4 @@
|
|
5 |
-use crossbeam::sync::MsQueue;
|
|
6 |
+use crossbeam::channel::{Receiver, Sender};
|
|
7 |
use std::collections::{BTreeMap, HashMap};
|
|
8 |
use std::path::PathBuf;
|
|
9 |
use std::sync::Mutex;
|
|
10 |
@@ -45,7 +45,8 @@ pub struct WorkItem {
|
|
11 |
pub name: String,
|
|
12 |
}
|
|
13 |
|
|
14 |
-pub type WorkQueue = MsQueue<Option<WorkItem>>;
|
|
15 |
+pub type JobReceiver = Receiver<Option<WorkItem>>;
|
|
16 |
+pub type JobSender = Sender<Option<WorkItem>>;
|
|
17 |
|
|
18 |
pub type CovResultMap = HashMap<String, CovResult>;
|
|
19 |
pub type SyncCovResultMap = Mutex<CovResultMap>;
|
|
20 |
Index: grcov/src/lib.rs
|
|
21 |
===================================================================
|
|
22 |
--- grcov.orig/src/lib.rs
|
|
23 |
+++ grcov/src/lib.rs
|
|
24 |
@@ -135,12 +135,16 @@ pub fn consumer(
|
|
25 |
working_dir: &PathBuf,
|
|
26 |
source_dir: &Option<PathBuf>,
|
|
27 |
result_map: &SyncCovResultMap,
|
|
28 |
- queue: &WorkQueue,
|
|
29 |
+ receiver: JobReceiver,
|
|
30 |
branch_enabled: bool,
|
|
31 |
) {
|
|
32 |
let mut gcov_type = GcovType::Unknown;
|
|
33 |
|
|
34 |
- while let Some(work_item) = queue.pop() {
|
|
35 |
+ while let Ok(work_item) = receiver.recv() {
|
|
36 |
+ if work_item.is_none() {
|
|
37 |
+ break;
|
|
38 |
+ }
|
|
39 |
+ let work_item = work_item.unwrap();
|
|
40 |
let new_results = match work_item.format {
|
|
41 |
ItemFormat::GCNO => {
|
|
42 |
match work_item.item {
|
|
43 |
Index: grcov/src/main.rs
|
|
44 |
===================================================================
|
|
45 |
--- grcov.orig/src/main.rs
|
|
46 |
+++ grcov/src/main.rs
|
|
47 |
@@ -4,7 +4,7 @@ extern crate num_cpus;
|
|
48 |
extern crate serde_json;
|
|
49 |
extern crate tempfile;
|
|
50 |
|
|
51 |
-use crossbeam::sync::MsQueue;
|
|
52 |
+use crossbeam::crossbeam_channel::unbounded;
|
|
53 |
use serde_json::Value;
|
|
54 |
use std::alloc::System;
|
|
55 |
use std::collections::HashMap;
|
|
56 |
@@ -245,11 +245,11 @@ fn main() {
|
|
57 |
assert!(tmp_path.exists());
|
|
58 |
|
|
59 |
let result_map: Arc<SyncCovResultMap> = Arc::new(Mutex::new(HashMap::with_capacity(20_000)));
|
|
60 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
61 |
+ let (sender, receiver) = unbounded();
|
|
62 |
let path_mapping: Arc<Mutex<Option<Value>>> = Arc::new(Mutex::new(None));
|
|
63 |
|
|
64 |
let producer = {
|
|
65 |
- let queue = Arc::clone(&queue);
|
|
66 |
+ let sender: JobSender = sender.clone();
|
|
67 |
let tmp_path = tmp_path.clone();
|
|
68 |
let path_mapping_file = path_mapping_file.to_owned();
|
|
69 |
let path_mapping = Arc::clone(&path_mapping);
|
|
70 |
@@ -258,7 +258,7 @@ fn main() {
|
|
71 |
let producer_path_mapping_buf = producer(
|
|
72 |
&tmp_path,
|
|
73 |
&paths,
|
|
74 |
- &queue,
|
|
75 |
+ &sender,
|
|
76 |
filter_option.is_some() && filter_option.unwrap(),
|
|
77 |
is_llvm,
|
|
78 |
);
|
|
79 |
@@ -278,7 +278,7 @@ fn main() {
|
|
80 |
let mut parsers = Vec::new();
|
|
81 |
|
|
82 |
for i in 0..num_threads {
|
|
83 |
- let queue = Arc::clone(&queue);
|
|
84 |
+ let receiver = receiver.clone();
|
|
85 |
let result_map = Arc::clone(&result_map);
|
|
86 |
let working_dir = tmp_path.join(format!("{}", i));
|
|
87 |
let source_root = source_root.clone();
|
|
88 |
@@ -289,7 +289,7 @@ fn main() {
|
|
89 |
&working_dir,
|
|
90 |
&source_root,
|
|
91 |
&result_map,
|
|
92 |
- &queue,
|
|
93 |
+ receiver,
|
|
94 |
branch_enabled,
|
|
95 |
);
|
|
96 |
}).unwrap();
|
|
97 |
@@ -302,9 +302,9 @@ fn main() {
|
|
98 |
process::exit(1);
|
|
99 |
}
|
|
100 |
|
|
101 |
- // Poison the queue, now that the producer is finished.
|
|
102 |
+ // Poison the receiver, now that the producer is finished.
|
|
103 |
for _ in 0..num_threads {
|
|
104 |
- queue.push(None);
|
|
105 |
+ sender.send(None).unwrap();
|
|
106 |
}
|
|
107 |
|
|
108 |
for parser in parsers {
|
|
109 |
Index: grcov/src/producer.rs
|
|
110 |
===================================================================
|
|
111 |
--- grcov.orig/src/producer.rs
|
|
112 |
+++ grcov/src/producer.rs
|
|
113 |
@@ -295,15 +295,15 @@ fn gcno_gcda_producer(
|
|
114 |
tmp_dir: &Path,
|
|
115 |
gcno_stem_archives: &HashMap<GCNOStem, &Archive>,
|
|
116 |
gcda_stem_archives: &HashMap<String, Vec<&Archive>>,
|
|
117 |
- queue: &WorkQueue,
|
|
118 |
+ sender: &JobSender,
|
|
119 |
ignore_orphan_gcno: bool,
|
|
120 |
) {
|
|
121 |
- let push_to_queue = |item, name| {
|
|
122 |
- queue.push(Some(WorkItem {
|
|
123 |
+ let send_job = |item, name| {
|
|
124 |
+ sender.send(Some(WorkItem {
|
|
125 |
format: ItemFormat::GCNO,
|
|
126 |
item: item,
|
|
127 |
name: name,
|
|
128 |
- }))
|
|
129 |
+ })).unwrap()
|
|
130 |
};
|
|
131 |
|
|
132 |
for (gcno_stem, gcno_archive) in gcno_stem_archives {
|
|
133 |
@@ -324,7 +324,7 @@ fn gcno_gcda_producer(
|
|
134 |
gcda_buffers.push(gcda_buf);
|
|
135 |
}
|
|
136 |
}
|
|
137 |
- push_to_queue(
|
|
138 |
+ send_job(
|
|
139 |
ItemType::Buffers(GcnoBuffers {
|
|
140 |
stem: stem.clone(),
|
|
141 |
gcno_buf: gcno_buffer,
|
|
142 |
@@ -349,7 +349,7 @@ fn gcno_gcda_producer(
|
|
143 |
if gcda_archive.extract(&gcda, &gcda_path)
|
|
144 |
|| (num == 0 && !ignore_orphan_gcno)
|
|
145 |
{
|
|
146 |
- push_to_queue(
|
|
147 |
+ send_job(
|
|
148 |
ItemType::Path(gcno_path),
|
|
149 |
gcda_archive.get_name().to_string(),
|
|
150 |
);
|
|
151 |
@@ -365,7 +365,7 @@ fn gcno_gcda_producer(
|
|
152 |
let mut buffer: Vec<u8> = Vec::new();
|
|
153 |
gcno_archive.read_in_buffer(&gcno, &mut buffer);
|
|
154 |
|
|
155 |
- push_to_queue(
|
|
156 |
+ send_job(
|
|
157 |
ItemType::Buffers(GcnoBuffers {
|
|
158 |
stem: stem.clone(),
|
|
159 |
gcno_buf: buffer,
|
|
160 |
@@ -376,7 +376,7 @@ fn gcno_gcda_producer(
|
|
161 |
} else {
|
|
162 |
let physical_gcno_path = tmp_dir.join(format!("{}_{}.gcno", stem, 1));
|
|
163 |
if gcno_archive.extract(&gcno, &physical_gcno_path) {
|
|
164 |
- push_to_queue(
|
|
165 |
+ send_job(
|
|
166 |
ItemType::Path(physical_gcno_path),
|
|
167 |
gcno_archive.get_name().to_string(),
|
|
168 |
);
|
|
169 |
@@ -390,18 +390,18 @@ fn gcno_gcda_producer(
|
|
170 |
|
|
171 |
fn file_content_producer(
|
|
172 |
files: &HashMap<String, Vec<&Archive>>,
|
|
173 |
- queue: &WorkQueue,
|
|
174 |
+ sender: &JobSender,
|
|
175 |
item_format: ItemFormat,
|
|
176 |
) {
|
|
177 |
for (name, archives) in files {
|
|
178 |
for archive in archives {
|
|
179 |
let mut buffer = Vec::new();
|
|
180 |
archive.read_in_buffer(name, &mut buffer);
|
|
181 |
- queue.push(Some(WorkItem {
|
|
182 |
+ sender.send(Some(WorkItem {
|
|
183 |
format: item_format,
|
|
184 |
item: ItemType::Content(buffer),
|
|
185 |
name: archive.get_name().to_string(),
|
|
186 |
- }));
|
|
187 |
+ })).unwrap();
|
|
188 |
}
|
|
189 |
}
|
|
190 |
}
|
|
191 |
@@ -426,7 +426,7 @@ fn open_archive(path: &str) -> ZipArchiv
|
|
192 |
pub fn producer(
|
|
193 |
tmp_dir: &Path,
|
|
194 |
paths: &[String],
|
|
195 |
- queue: &WorkQueue,
|
|
196 |
+ sender: &JobSender,
|
|
197 |
ignore_orphan_gcno: bool,
|
|
198 |
is_llvm: bool,
|
|
199 |
) -> Option<Vec<u8>> {
|
|
200 |
@@ -498,13 +498,13 @@ pub fn producer(
|
|
201 |
"No input files found"
|
|
202 |
);
|
|
203 |
|
|
204 |
- file_content_producer(&infos.into_inner(), queue, ItemFormat::INFO);
|
|
205 |
- file_content_producer(&xmls.into_inner(), queue, ItemFormat::JACOCO_XML);
|
|
206 |
+ file_content_producer(&infos.into_inner(), sender, ItemFormat::INFO);
|
|
207 |
+ file_content_producer(&xmls.into_inner(), sender, ItemFormat::JACOCO_XML);
|
|
208 |
gcno_gcda_producer(
|
|
209 |
tmp_dir,
|
|
210 |
&gcno_stems_archives.into_inner(),
|
|
211 |
&gcda_stems_archives.into_inner(),
|
|
212 |
- queue,
|
|
213 |
+ sender,
|
|
214 |
ignore_orphan_gcno,
|
|
215 |
);
|
|
216 |
|
|
217 |
@@ -514,23 +514,18 @@ pub fn producer(
|
|
218 |
#[cfg(test)]
|
|
219 |
mod tests {
|
|
220 |
use super::*;
|
|
221 |
- use crossbeam::queue::MsQueue;
|
|
222 |
+ use crossbeam::crossbeam_channel::unbounded;
|
|
223 |
use serde_json::{self, Value};
|
|
224 |
- use std::sync::Arc;
|
|
225 |
|
|
226 |
fn check_produced(
|
|
227 |
directory: PathBuf,
|
|
228 |
- queue: &WorkQueue,
|
|
229 |
+ receiver: &JobReceiver,
|
|
230 |
expected: Vec<(ItemFormat, bool, &str, bool)>,
|
|
231 |
) {
|
|
232 |
let mut vec: Vec<Option<WorkItem>> = Vec::new();
|
|
233 |
|
|
234 |
- loop {
|
|
235 |
- let elem = queue.try_pop();
|
|
236 |
- if elem.is_none() {
|
|
237 |
- break;
|
|
238 |
- }
|
|
239 |
- vec.push(elem.unwrap());
|
|
240 |
+ while let Ok(elem) = receiver.try_recv() {
|
|
241 |
+ vec.push(elem);
|
|
242 |
}
|
|
243 |
|
|
244 |
for elem in &expected {
|
|
245 |
@@ -601,11 +596,11 @@ mod tests {
|
|
246 |
|
|
247 |
#[test]
|
|
248 |
fn test_dir_producer() {
|
|
249 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
250 |
+ let (sender, receiver) = unbounded();
|
|
251 |
|
|
252 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
253 |
let tmp_path = tmp_dir.path().to_owned();
|
|
254 |
- let mapping = producer(&tmp_path, &["test".to_string()], &queue, false, false);
|
|
255 |
+ let mapping = producer(&tmp_path, &["test".to_string()], &sender, false, false);
|
|
256 |
|
|
257 |
let expected = vec![
|
|
258 |
(ItemFormat::GCNO, true, "Platform_1.gcno", true),
|
|
259 |
@@ -694,7 +689,7 @@ mod tests {
|
|
260 |
),
|
|
261 |
];
|
|
262 |
|
|
263 |
- check_produced(tmp_path, &queue, expected);
|
|
264 |
+ check_produced(tmp_path, &receiver, expected);
|
|
265 |
assert!(mapping.is_some());
|
|
266 |
let mapping: Value = serde_json::from_slice(&mapping.unwrap()).unwrap();
|
|
267 |
assert_eq!(
|
|
268 |
@@ -709,14 +704,14 @@ mod tests {
|
|
269 |
|
|
270 |
#[test]
|
|
271 |
fn test_dir_producer_multiple_directories() {
|
|
272 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
273 |
+ let (sender, receiver) = unbounded();
|
|
274 |
|
|
275 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
276 |
let tmp_path = tmp_dir.path().to_owned();
|
|
277 |
let mapping = producer(
|
|
278 |
&tmp_path,
|
|
279 |
&["test/sub".to_string(), "test/sub2".to_string()],
|
|
280 |
- &queue,
|
|
281 |
+ &sender,
|
|
282 |
false,
|
|
283 |
false,
|
|
284 |
);
|
|
285 |
@@ -726,40 +721,40 @@ mod tests {
|
|
286 |
(ItemFormat::GCNO, true, "prova2_1.gcno", true),
|
|
287 |
];
|
|
288 |
|
|
289 |
- check_produced(tmp_path, &queue, expected);
|
|
290 |
+ check_produced(tmp_path, &receiver, expected);
|
|
291 |
assert!(mapping.is_none());
|
|
292 |
}
|
|
293 |
|
|
294 |
#[test]
|
|
295 |
fn test_dir_producer_directory_with_gcno_symlinks() {
|
|
296 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
297 |
+ let (sender, receiver) = unbounded();
|
|
298 |
|
|
299 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
300 |
let tmp_path = tmp_dir.path().to_owned();
|
|
301 |
let mapping = producer(
|
|
302 |
&tmp_path,
|
|
303 |
&["test/gcno_symlink/gcda".to_string()],
|
|
304 |
- &queue,
|
|
305 |
+ &sender,
|
|
306 |
false,
|
|
307 |
false,
|
|
308 |
);
|
|
309 |
|
|
310 |
let expected = vec![(ItemFormat::GCNO, true, "main_1.gcno", true)];
|
|
311 |
|
|
312 |
- check_produced(tmp_path, &queue, expected);
|
|
313 |
+ check_produced(tmp_path, &receiver, expected);
|
|
314 |
assert!(mapping.is_none());
|
|
315 |
}
|
|
316 |
|
|
317 |
#[test]
|
|
318 |
fn test_dir_producer_directory_with_no_gcda() {
|
|
319 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
320 |
+ let (sender, receiver) = unbounded();
|
|
321 |
|
|
322 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
323 |
let tmp_path = tmp_dir.path().to_owned();
|
|
324 |
let mapping = producer(
|
|
325 |
&tmp_path,
|
|
326 |
&["test/only_one_gcda".to_string()],
|
|
327 |
- &queue,
|
|
328 |
+ &sender,
|
|
329 |
false,
|
|
330 |
false,
|
|
331 |
);
|
|
332 |
@@ -769,33 +764,33 @@ mod tests {
|
|
333 |
(ItemFormat::GCNO, true, "orphan_1.gcno", false),
|
|
334 |
];
|
|
335 |
|
|
336 |
- check_produced(tmp_path, &queue, expected);
|
|
337 |
+ check_produced(tmp_path, &receiver, expected);
|
|
338 |
assert!(mapping.is_none());
|
|
339 |
}
|
|
340 |
|
|
341 |
#[test]
|
|
342 |
fn test_dir_producer_directory_with_no_gcda_ignore_orphan_gcno() {
|
|
343 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
344 |
+ let (sender, receiver) = unbounded();
|
|
345 |
|
|
346 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
347 |
let tmp_path = tmp_dir.path().to_owned();
|
|
348 |
let mapping = producer(
|
|
349 |
&tmp_path,
|
|
350 |
&["test/only_one_gcda".to_string()],
|
|
351 |
- &queue,
|
|
352 |
+ &sender,
|
|
353 |
true,
|
|
354 |
false,
|
|
355 |
);
|
|
356 |
|
|
357 |
let expected = vec![(ItemFormat::GCNO, true, "main_1.gcno", true)];
|
|
358 |
|
|
359 |
- check_produced(tmp_path, &queue, expected);
|
|
360 |
+ check_produced(tmp_path, &receiver, expected);
|
|
361 |
assert!(mapping.is_none());
|
|
362 |
}
|
|
363 |
|
|
364 |
#[test]
|
|
365 |
fn test_zip_producer_with_gcda_dir() {
|
|
366 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
367 |
+ let (sender, receiver) = unbounded();
|
|
368 |
|
|
369 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
370 |
let tmp_path = tmp_dir.path().to_owned();
|
|
371 |
@@ -805,7 +800,7 @@ mod tests {
|
|
372 |
"test/zip_dir/gcno.zip".to_string(),
|
|
373 |
"test/zip_dir".to_string(),
|
|
374 |
],
|
|
375 |
- &queue,
|
|
376 |
+ &sender,
|
|
377 |
false,
|
|
378 |
false,
|
|
379 |
);
|
|
380 |
@@ -829,7 +824,7 @@ mod tests {
|
|
381 |
(ItemFormat::GCNO, true, "nsGnomeModule_1.gcno", true),
|
|
382 |
];
|
|
383 |
|
|
384 |
- check_produced(tmp_path, &queue, expected);
|
|
385 |
+ check_produced(tmp_path, &receiver, expected);
|
|
386 |
assert!(mapping.is_some());
|
|
387 |
let mapping: Value = serde_json::from_slice(&mapping.unwrap()).unwrap();
|
|
388 |
assert_eq!(
|
|
389 |
@@ -845,7 +840,7 @@ mod tests {
|
|
390 |
// Test extracting multiple gcda archives.
|
|
391 |
#[test]
|
|
392 |
fn test_zip_producer_multiple_gcda_archives() {
|
|
393 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
394 |
+ let (sender, receiver) = unbounded();
|
|
395 |
|
|
396 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
397 |
let tmp_path = tmp_dir.path().to_owned();
|
|
398 |
@@ -856,7 +851,7 @@ mod tests {
|
|
399 |
"test/gcda1.zip".to_string(),
|
|
400 |
"test/gcda2.zip".to_string(),
|
|
401 |
],
|
|
402 |
- &queue,
|
|
403 |
+ &sender,
|
|
404 |
false,
|
|
405 |
false,
|
|
406 |
);
|
|
407 |
@@ -889,7 +884,7 @@ mod tests {
|
|
408 |
(ItemFormat::GCNO, true, "sub/prova2_2.gcno", true),
|
|
409 |
];
|
|
410 |
|
|
411 |
- check_produced(tmp_path, &queue, expected);
|
|
412 |
+ check_produced(tmp_path, &receiver, expected);
|
|
413 |
assert!(mapping.is_some());
|
|
414 |
let mapping: Value = serde_json::from_slice(&mapping.unwrap()).unwrap();
|
|
415 |
assert_eq!(
|
|
416 |
@@ -905,7 +900,7 @@ mod tests {
|
|
417 |
// Test extracting gcno with no path mapping.
|
|
418 |
#[test]
|
|
419 |
fn test_zip_producer_gcno_with_no_path_mapping() {
|
|
420 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
421 |
+ let (sender, receiver) = unbounded();
|
|
422 |
|
|
423 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
424 |
let tmp_path = tmp_dir.path().to_owned();
|
|
425 |
@@ -915,7 +910,7 @@ mod tests {
|
|
426 |
"test/gcno_no_path_mapping.zip".to_string(),
|
|
427 |
"test/gcda1.zip".to_string(),
|
|
428 |
],
|
|
429 |
- &queue,
|
|
430 |
+ &sender,
|
|
431 |
false,
|
|
432 |
false,
|
|
433 |
);
|
|
434 |
@@ -939,14 +934,14 @@ mod tests {
|
|
435 |
(ItemFormat::GCNO, true, "nsGnomeModule_1.gcno", true),
|
|
436 |
];
|
|
437 |
|
|
438 |
- check_produced(tmp_path, &queue, expected);
|
|
439 |
+ check_produced(tmp_path, &receiver, expected);
|
|
440 |
assert!(mapping.is_none());
|
|
441 |
}
|
|
442 |
|
|
443 |
// Test calling zip_producer with a different order of zip files.
|
|
444 |
#[test]
|
|
445 |
fn test_zip_producer_different_order_of_zip_files() {
|
|
446 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
447 |
+ let (sender, receiver) = unbounded();
|
|
448 |
|
|
449 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
450 |
let tmp_path = tmp_dir.path().to_owned();
|
|
451 |
@@ -957,7 +952,7 @@ mod tests {
|
|
452 |
"test/gcno.zip".to_string(),
|
|
453 |
"test/gcda2.zip".to_string(),
|
|
454 |
],
|
|
455 |
- &queue,
|
|
456 |
+ &sender,
|
|
457 |
false,
|
|
458 |
false,
|
|
459 |
);
|
|
460 |
@@ -990,20 +985,20 @@ mod tests {
|
|
461 |
(ItemFormat::GCNO, true, "sub/prova2_2.gcno", true),
|
|
462 |
];
|
|
463 |
|
|
464 |
- check_produced(tmp_path, &queue, expected);
|
|
465 |
+ check_produced(tmp_path, &receiver, expected);
|
|
466 |
}
|
|
467 |
|
|
468 |
// Test extracting info files.
|
|
469 |
#[test]
|
|
470 |
fn test_zip_producer_info_files() {
|
|
471 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
472 |
+ let (sender, receiver) = unbounded();
|
|
473 |
|
|
474 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
475 |
let tmp_path = tmp_dir.path().to_owned();
|
|
476 |
producer(
|
|
477 |
&tmp_path,
|
|
478 |
&["test/info1.zip".to_string(), "test/info2.zip".to_string()],
|
|
479 |
- &queue,
|
|
480 |
+ &sender,
|
|
481 |
false,
|
|
482 |
false,
|
|
483 |
);
|
|
484 |
@@ -1023,13 +1018,13 @@ mod tests {
|
|
485 |
(ItemFormat::INFO, false, "1494603973-2977-7_1.info", true),
|
|
486 |
];
|
|
487 |
|
|
488 |
- check_produced(tmp_path, &queue, expected);
|
|
489 |
+ check_produced(tmp_path, &receiver, expected);
|
|
490 |
}
|
|
491 |
|
|
492 |
// Test extracting jacoco report XML files.
|
|
493 |
#[test]
|
|
494 |
fn test_zip_producer_jacoco_xml_files() {
|
|
495 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
496 |
+ let (sender, receiver) = unbounded();
|
|
497 |
|
|
498 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
499 |
let tmp_path = tmp_dir.path().to_owned();
|
|
500 |
@@ -1039,7 +1034,7 @@ mod tests {
|
|
501 |
"test/jacoco1.zip".to_string(),
|
|
502 |
"test/jacoco2.zip".to_string(),
|
|
503 |
],
|
|
504 |
- &queue,
|
|
505 |
+ &sender,
|
|
506 |
false,
|
|
507 |
false,
|
|
508 |
);
|
|
509 |
@@ -1054,13 +1049,13 @@ mod tests {
|
|
510 |
(ItemFormat::JACOCO_XML, false, "inner-classes.xml", true),
|
|
511 |
];
|
|
512 |
|
|
513 |
- check_produced(tmp_path, &queue, expected);
|
|
514 |
+ check_produced(tmp_path, &receiver, expected);
|
|
515 |
}
|
|
516 |
|
|
517 |
// Test extracting both jacoco xml and info files.
|
|
518 |
#[test]
|
|
519 |
fn test_zip_producer_both_info_and_jacoco_xml() {
|
|
520 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
521 |
+ let (sender, receiver) = unbounded();
|
|
522 |
|
|
523 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
524 |
let tmp_path = tmp_dir.path().to_owned();
|
|
525 |
@@ -1072,7 +1067,7 @@ mod tests {
|
|
526 |
"test/info1.zip".to_string(),
|
|
527 |
"test/info2.zip".to_string(),
|
|
528 |
],
|
|
529 |
- &queue,
|
|
530 |
+ &sender,
|
|
531 |
false,
|
|
532 |
false,
|
|
533 |
);
|
|
534 |
@@ -1099,13 +1094,13 @@ mod tests {
|
|
535 |
(ItemFormat::INFO, false, "1494603973-2977-7_1.info", true),
|
|
536 |
];
|
|
537 |
|
|
538 |
- check_produced(tmp_path, &queue, expected);
|
|
539 |
+ check_produced(tmp_path, &receiver, expected);
|
|
540 |
}
|
|
541 |
|
|
542 |
// Test extracting both info and gcno/gcda files.
|
|
543 |
#[test]
|
|
544 |
fn test_zip_producer_both_info_and_gcnogcda_files() {
|
|
545 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
546 |
+ let (sender, receiver) = unbounded();
|
|
547 |
|
|
548 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
549 |
let tmp_path = tmp_dir.path().to_owned();
|
|
550 |
@@ -1117,7 +1112,7 @@ mod tests {
|
|
551 |
"test/info1.zip".to_string(),
|
|
552 |
"test/info2.zip".to_string(),
|
|
553 |
],
|
|
554 |
- &queue,
|
|
555 |
+ &sender,
|
|
556 |
false,
|
|
557 |
false,
|
|
558 |
);
|
|
559 |
@@ -1153,13 +1148,13 @@ mod tests {
|
|
560 |
(ItemFormat::INFO, false, "1494603973-2977-7_1.info", true),
|
|
561 |
];
|
|
562 |
|
|
563 |
- check_produced(tmp_path, &queue, expected);
|
|
564 |
+ check_produced(tmp_path, &receiver, expected);
|
|
565 |
}
|
|
566 |
|
|
567 |
// Test extracting gcno with no associated gcda.
|
|
568 |
#[test]
|
|
569 |
fn test_zip_producer_gcno_with_no_associated_gcda() {
|
|
570 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
571 |
+ let (sender, receiver) = unbounded();
|
|
572 |
|
|
573 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
574 |
let tmp_path = tmp_dir.path().to_owned();
|
|
575 |
@@ -1169,21 +1164,21 @@ mod tests {
|
|
576 |
"test/no_gcda/main.gcno.zip".to_string(),
|
|
577 |
"test/no_gcda/empty.gcda.zip".to_string(),
|
|
578 |
],
|
|
579 |
- &queue,
|
|
580 |
+ &sender,
|
|
581 |
false,
|
|
582 |
false,
|
|
583 |
);
|
|
584 |
|
|
585 |
let expected = vec![(ItemFormat::GCNO, true, "main_1.gcno", false)];
|
|
586 |
|
|
587 |
- check_produced(tmp_path, &queue, expected);
|
|
588 |
+ check_produced(tmp_path, &receiver, expected);
|
|
589 |
assert!(mapping.is_none());
|
|
590 |
}
|
|
591 |
|
|
592 |
// Test extracting gcno with an associated gcda file in only one zip file.
|
|
593 |
#[test]
|
|
594 |
fn test_zip_producer_gcno_with_associated_gcda_in_only_one_archive() {
|
|
595 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
596 |
+ let (sender, receiver) = unbounded();
|
|
597 |
|
|
598 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
599 |
let tmp_path = tmp_dir.path().to_owned();
|
|
600 |
@@ -1194,14 +1189,14 @@ mod tests {
|
|
601 |
"test/no_gcda/empty.gcda.zip".to_string(),
|
|
602 |
"test/no_gcda/main.gcda.zip".to_string(),
|
|
603 |
],
|
|
604 |
- &queue,
|
|
605 |
+ &sender,
|
|
606 |
false,
|
|
607 |
false,
|
|
608 |
);
|
|
609 |
|
|
610 |
let expected = vec![(ItemFormat::GCNO, true, "main_1.gcno", true)];
|
|
611 |
|
|
612 |
- check_produced(tmp_path, &queue, expected);
|
|
613 |
+ check_produced(tmp_path, &receiver, expected);
|
|
614 |
assert!(mapping.is_none());
|
|
615 |
}
|
|
616 |
|
|
617 |
@@ -1209,14 +1204,14 @@ mod tests {
|
|
618 |
#[test]
|
|
619 |
#[should_panic]
|
|
620 |
fn test_zip_producer_with_gcda_archive_and_no_gcno_archive() {
|
|
621 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
622 |
+ let (sender, _) = unbounded();
|
|
623 |
|
|
624 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
625 |
let tmp_path = tmp_dir.path().to_owned();
|
|
626 |
producer(
|
|
627 |
&tmp_path,
|
|
628 |
&["test/no_gcda/main.gcda.zip".to_string()],
|
|
629 |
- &queue,
|
|
630 |
+ &sender,
|
|
631 |
false,
|
|
632 |
false,
|
|
633 |
);
|
|
634 |
@@ -1225,14 +1220,14 @@ mod tests {
|
|
635 |
// Test extracting gcno/gcda archives, where a gcno file exist with no matching gcda file.
|
|
636 |
#[test]
|
|
637 |
fn test_zip_producer_no_matching_gcno() {
|
|
638 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
639 |
+ let (sender, receiver) = unbounded();
|
|
640 |
|
|
641 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
642 |
let tmp_path = tmp_dir.path().to_owned();
|
|
643 |
producer(
|
|
644 |
&tmp_path,
|
|
645 |
&["test/gcno.zip".to_string(), "test/gcda2.zip".to_string()],
|
|
646 |
- &queue,
|
|
647 |
+ &sender,
|
|
648 |
false,
|
|
649 |
false,
|
|
650 |
);
|
|
651 |
@@ -1256,14 +1251,14 @@ mod tests {
|
|
652 |
(ItemFormat::GCNO, true, "nsGnomeModule_1.gcno", true),
|
|
653 |
];
|
|
654 |
|
|
655 |
- check_produced(tmp_path, &queue, expected);
|
|
656 |
+ check_produced(tmp_path, &receiver, expected);
|
|
657 |
}
|
|
658 |
|
|
659 |
// Test extracting gcno/gcda archives, where a gcno file exist with no matching gcda file.
|
|
660 |
// The gcno file should be produced only once, not twice.
|
|
661 |
#[test]
|
|
662 |
fn test_zip_producer_no_matching_gcno_two_gcda_archives() {
|
|
663 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
664 |
+ let (sender, receiver) = unbounded();
|
|
665 |
|
|
666 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
667 |
let tmp_path = tmp_dir.path().to_owned();
|
|
668 |
@@ -1274,7 +1269,7 @@ mod tests {
|
|
669 |
"test/gcda2.zip".to_string(),
|
|
670 |
"test/gcda2.zip".to_string(),
|
|
671 |
],
|
|
672 |
- &queue,
|
|
673 |
+ &sender,
|
|
674 |
false,
|
|
675 |
false,
|
|
676 |
);
|
|
677 |
@@ -1307,20 +1302,20 @@ mod tests {
|
|
678 |
(ItemFormat::GCNO, true, "nsGnomeModule_2.gcno", true),
|
|
679 |
];
|
|
680 |
|
|
681 |
- check_produced(tmp_path, &queue, expected);
|
|
682 |
+ check_produced(tmp_path, &receiver, expected);
|
|
683 |
}
|
|
684 |
|
|
685 |
// Test extracting gcno/gcda archives, where a gcno file exist with no matching gcda file and ignore orphan gcno files.
|
|
686 |
#[test]
|
|
687 |
fn test_zip_producer_no_matching_gcno_ignore_orphan_gcno() {
|
|
688 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
689 |
+ let (sender, receiver) = unbounded();
|
|
690 |
|
|
691 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
692 |
let tmp_path = tmp_dir.path().to_owned();
|
|
693 |
producer(
|
|
694 |
&tmp_path,
|
|
695 |
&["test/gcno.zip".to_string(), "test/gcda2.zip".to_string()],
|
|
696 |
- &queue,
|
|
697 |
+ &sender,
|
|
698 |
true,
|
|
699 |
false,
|
|
700 |
);
|
|
701 |
@@ -1337,13 +1332,13 @@ mod tests {
|
|
702 |
(ItemFormat::GCNO, true, "nsGnomeModule_1.gcno", true),
|
|
703 |
];
|
|
704 |
|
|
705 |
- check_produced(tmp_path, &queue, expected);
|
|
706 |
+ check_produced(tmp_path, &receiver, expected);
|
|
707 |
}
|
|
708 |
|
|
709 |
// Test extracting gcno/gcda archives, where a gcno file exist with no matching gcda file and ignore orphan gcno files.
|
|
710 |
#[test]
|
|
711 |
fn test_zip_producer_no_matching_gcno_two_gcda_archives_ignore_orphan_gcno() {
|
|
712 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
713 |
+ let (sender, receiver) = unbounded();
|
|
714 |
|
|
715 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
716 |
let tmp_path = tmp_dir.path().to_owned();
|
|
717 |
@@ -1354,7 +1349,7 @@ mod tests {
|
|
718 |
"test/gcda2.zip".to_string(),
|
|
719 |
"test/gcda2.zip".to_string(),
|
|
720 |
],
|
|
721 |
- &queue,
|
|
722 |
+ &sender,
|
|
723 |
true,
|
|
724 |
false,
|
|
725 |
);
|
|
726 |
@@ -1380,12 +1375,12 @@ mod tests {
|
|
727 |
(ItemFormat::GCNO, true, "nsGnomeModule_2.gcno", true),
|
|
728 |
];
|
|
729 |
|
|
730 |
- check_produced(tmp_path, &queue, expected);
|
|
731 |
+ check_produced(tmp_path, &receiver, expected);
|
|
732 |
}
|
|
733 |
|
|
734 |
#[test]
|
|
735 |
fn test_zip_producer_llvm_buffers() {
|
|
736 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
737 |
+ let (sender, receiver) = unbounded();
|
|
738 |
|
|
739 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
740 |
let tmp_path = tmp_dir.path().to_owned();
|
|
741 |
@@ -1396,7 +1391,7 @@ mod tests {
|
|
742 |
"test/llvm/gcda1.zip".to_string(),
|
|
743 |
"test/llvm/gcda2.zip".to_string(),
|
|
744 |
],
|
|
745 |
- &queue,
|
|
746 |
+ &sender,
|
|
747 |
true,
|
|
748 |
true,
|
|
749 |
);
|
|
750 |
@@ -1425,12 +1420,8 @@ mod tests {
|
|
751 |
0, 0, 0, 0, 0, 0, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
752 |
];
|
|
753 |
|
|
754 |
- loop {
|
|
755 |
- let elem = queue.try_pop();
|
|
756 |
- if elem.is_none() {
|
|
757 |
- break;
|
|
758 |
- }
|
|
759 |
- let elem = elem.unwrap().unwrap();
|
|
760 |
+ while let Ok(elem) = receiver.try_recv() {
|
|
761 |
+ let elem = elem.unwrap();
|
|
762 |
if let ItemType::Buffers(buffers) = elem.item {
|
|
763 |
let stem = PathBuf::from(buffers.stem);
|
|
764 |
let stem = stem.file_stem().expect("Unable to get file_stem");
|
|
765 |
@@ -1448,7 +1439,7 @@ mod tests {
|
|
766 |
|
|
767 |
#[test]
|
|
768 |
fn test_plain_producer() {
|
|
769 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
770 |
+ let (sender, receiver) = unbounded();
|
|
771 |
|
|
772 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
773 |
let tmp_path = tmp_dir.path().to_owned();
|
|
774 |
@@ -1459,7 +1450,7 @@ mod tests {
|
|
775 |
"test/prova.info".to_string(),
|
|
776 |
json_path.to_string(),
|
|
777 |
],
|
|
778 |
- &queue,
|
|
779 |
+ &sender,
|
|
780 |
true,
|
|
781 |
false,
|
|
782 |
);
|
|
783 |
@@ -1482,13 +1473,13 @@ mod tests {
|
|
784 |
},
|
|
785 |
}
|
|
786 |
|
|
787 |
- check_produced(tmp_path, &queue, expected);
|
|
788 |
+ check_produced(tmp_path, &receiver, expected);
|
|
789 |
}
|
|
790 |
|
|
791 |
#[test]
|
|
792 |
#[should_panic]
|
|
793 |
fn test_plain_producer_with_gcno() {
|
|
794 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
795 |
+ let (sender, _) = unbounded();
|
|
796 |
|
|
797 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
798 |
let tmp_path = tmp_dir.path().to_owned();
|
|
799 |
@@ -1497,7 +1488,7 @@ mod tests {
|
|
800 |
&[
|
|
801 |
"sub2/RootAccessibleWrap_1.gcno".to_string(),
|
|
802 |
],
|
|
803 |
- &queue,
|
|
804 |
+ &sender,
|
|
805 |
true,
|
|
806 |
false,
|
|
807 |
);
|
|
808 |
@@ -1506,7 +1497,7 @@ mod tests {
|
|
809 |
#[test]
|
|
810 |
#[should_panic]
|
|
811 |
fn test_plain_producer_with_gcda() {
|
|
812 |
- let queue: Arc<WorkQueue> = Arc::new(MsQueue::new());
|
|
813 |
+ let (sender, _) = unbounded();
|
|
814 |
|
|
815 |
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
|
816 |
let tmp_path = tmp_dir.path().to_owned();
|