Skip to content

Commit 50766ba

Browse files
committed
Add more rayon tests with global pool
1 parent 9e9ac1a commit 50766ba

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

Cargo.toml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ png = "0.16"
1919
walkdir = "2.0"
2020
criterion = "0.3"
2121

22+
[features]
23+
default = ["rayon"]
24+
platform_independent = []
25+
nightly_aarch64_neon = []
26+
27+
## Internal development configuration: testing and benchmarking
28+
2229
[[bench]]
2330
name = "decoding_benchmark"
2431
harness = false
@@ -31,8 +38,10 @@ harness = false
3138
name = "rayon"
3239
required-features = ["rayon"]
3340

34-
[features]
35-
default = ["rayon"]
36-
platform_independent = []
37-
nightly_aarch64_neon = []
41+
[[test]]
42+
name = "rayon-0"
43+
required-features = ["rayon"]
3844

45+
[[test]]
46+
name = "rayon-1"
47+
required-features = ["rayon"]

tests/rayon-0.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//! Must be a separate test because it modifies the _global_ rayon pool.
2+
use std::{fs::File, path::Path};
3+
use jpeg_decoder::Decoder;
4+
5+
#[test]
6+
fn decoding_in_global_pool() {
7+
let path = Path::new("tests").join("reftest").join("images").join("mozilla").join("jpg-progressive.jpg");
8+
9+
rayon::ThreadPoolBuilder::new()
10+
.num_threads(1)
11+
.build_global()
12+
.unwrap();
13+
14+
let mut decoder = Decoder::new(File::open(&path).unwrap());
15+
let _ = decoder.decode().unwrap();
16+
}

tests/rayon-1.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! Must be a separate test because it modifies the _global_ rayon pool.
2+
use std::{fs::File, path::Path};
3+
use jpeg_decoder::Decoder;
4+
5+
#[test]
6+
fn decoding_in_fetched_global_pool() {
7+
let path = Path::new("tests").join("reftest").join("images").join("mozilla").join("jpg-progressive.jpg");
8+
9+
rayon::ThreadPoolBuilder::new()
10+
.num_threads(1)
11+
.build_global()
12+
.unwrap();
13+
14+
rayon::scope(|_| {
15+
let mut decoder = Decoder::new(File::open(&path).unwrap());
16+
let _ = decoder.decode().unwrap();
17+
})
18+
}

0 commit comments

Comments
 (0)