mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 10:56:29 +03:00
Speedup rust tests (#3242)
Speeds up running the rust tests by about a factor of 2.
This commit is contained in:
40
src/blob.rs
40
src/blob.rs
@@ -940,7 +940,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_recode_image() {
|
async fn test_recode_image_1() {
|
||||||
let bytes = include_bytes!("../test-data/image/avatar1000x1000.jpg");
|
let bytes = include_bytes!("../test-data/image/avatar1000x1000.jpg");
|
||||||
// BALANCED_IMAGE_SIZE > 1000, the original image size, so the image is not scaled down:
|
// BALANCED_IMAGE_SIZE > 1000, the original image size, so the image is not scaled down:
|
||||||
send_image_check_mediaquality(Some("0"), bytes, 1000, 1000, 0, 1000, 1000)
|
send_image_check_mediaquality(Some("0"), bytes, 1000, 1000, 0, 1000, 1000)
|
||||||
@@ -957,7 +957,10 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
async fn test_recode_image_2() {
|
||||||
// The "-rotated" files are rotated by 270 degrees using the Exif metadata
|
// The "-rotated" files are rotated by 270 degrees using the Exif metadata
|
||||||
let bytes = include_bytes!("../test-data/image/rectangle2000x1800-rotated.jpg");
|
let bytes = include_bytes!("../test-data/image/rectangle2000x1800-rotated.jpg");
|
||||||
let img_rotated = send_image_check_mediaquality(
|
let img_rotated = send_image_check_mediaquality(
|
||||||
@@ -978,18 +981,24 @@ mod tests {
|
|||||||
.write_to(&mut buf, image::ImageFormat::Jpeg)
|
.write_to(&mut buf, image::ImageFormat::Jpeg)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let bytes = buf.into_inner();
|
let bytes = buf.into_inner();
|
||||||
let img_rotated = send_image_check_mediaquality(
|
|
||||||
Some("0"),
|
// Do this in parallel to speed up the test a bit
|
||||||
&bytes,
|
// (it still takes very long though)
|
||||||
BALANCED_IMAGE_SIZE * 1800 / 2000,
|
let bytes2 = bytes.clone();
|
||||||
BALANCED_IMAGE_SIZE,
|
let join_handle = async_std::task::spawn(async move {
|
||||||
0,
|
let img_rotated = send_image_check_mediaquality(
|
||||||
BALANCED_IMAGE_SIZE * 1800 / 2000,
|
Some("0"),
|
||||||
BALANCED_IMAGE_SIZE,
|
&bytes2,
|
||||||
)
|
BALANCED_IMAGE_SIZE * 1800 / 2000,
|
||||||
.await
|
BALANCED_IMAGE_SIZE,
|
||||||
.unwrap();
|
0,
|
||||||
assert_correct_rotation(&img_rotated);
|
BALANCED_IMAGE_SIZE * 1800 / 2000,
|
||||||
|
BALANCED_IMAGE_SIZE,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_correct_rotation(&img_rotated);
|
||||||
|
});
|
||||||
|
|
||||||
let img_rotated = send_image_check_mediaquality(
|
let img_rotated = send_image_check_mediaquality(
|
||||||
Some("1"),
|
Some("1"),
|
||||||
@@ -1004,6 +1013,11 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_correct_rotation(&img_rotated);
|
assert_correct_rotation(&img_rotated);
|
||||||
|
|
||||||
|
join_handle.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
async fn test_recode_image_3() {
|
||||||
let bytes = include_bytes!("../test-data/image/rectangle200x180-rotated.jpg");
|
let bytes = include_bytes!("../test-data/image/rectangle200x180-rotated.jpg");
|
||||||
let img_rotated = send_image_check_mediaquality(Some("0"), bytes, 200, 180, 270, 180, 200)
|
let img_rotated = send_image_check_mediaquality(Some("0"), bytes, 200, 180, 270, 180, 200)
|
||||||
.await
|
.await
|
||||||
|
|||||||
Reference in New Issue
Block a user