Skip to content

Commit ecce533

Browse files
committed
try macos kaleido
Signed-off-by: Andrei Gherghescu <[email protected]>
1 parent 45c1b05 commit ecce533

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

plotly/src/plot.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ impl PartialEq for Plot {
585585
mod tests {
586586
use std::path::PathBuf;
587587

588+
use base64::{engine::general_purpose, Engine as _};
588589
use serde_json::{json, to_value};
589590

590591
use super::*;
@@ -748,7 +749,7 @@ mod tests {
748749
assert!(!dst.exists());
749750
}
750751

751-
#[cfg(target_os = "linux")]
752+
// #[cfg(not(target_os = "macos"))]
752753
#[test]
753754
#[cfg(feature = "kaleido")]
754755
fn test_save_to_png() {
@@ -760,19 +761,21 @@ mod tests {
760761
assert!(!dst.exists());
761762
}
762763

763-
#[cfg(target_os = "linux")]
764+
// #[cfg(not(target_os = "macos"))]
764765
#[test]
765766
#[cfg(feature = "kaleido")]
766767
fn test_save_to_jpeg() {
767768
let plot = create_test_plot();
768769
let dst = PathBuf::from("example.jpeg");
769770
plot.write_image(&dst, ImageFormat::JPEG, 1024, 680, 1.0);
770-
assert!(dst.exists());
771+
let imgSize = std::fs::metadata("example.jpeg").unwrap().len();
772+
dbg!(imgSize);
773+
assert!(!dst.exists());
771774
assert!(std::fs::remove_file(&dst).is_ok());
772775
assert!(!dst.exists());
773776
}
774777

775-
#[cfg(target_os = "linux")]
778+
// #[cfg(not(target_os = "macos"))]
776779
#[test]
777780
#[cfg(feature = "kaleido")]
778781
fn test_save_to_svg() {
@@ -796,7 +799,7 @@ mod tests {
796799
assert!(!dst.exists());
797800
}
798801

799-
#[cfg(target_os = "linux")]
802+
// #[cfg(not(target_os = "macos"))]
800803
#[test]
801804
#[cfg(feature = "kaleido")]
802805
fn test_save_to_pdf() {
@@ -820,16 +823,18 @@ mod tests {
820823
assert!(!dst.exists());
821824
}
822825

823-
#[cfg(target_os = "linux")]
824826
#[test]
827+
#[ignore] // Fails in the CI
828+
// #[cfg(not(target_os = "macos"))]
825829
#[cfg(feature = "kaleido")]
826830
fn test_image_to_base64() {
827-
use base64::engine::general_purpose;
828-
use base64::Engine;
829831
let plot = create_test_plot();
830832

831833
let image_base64 = plot.to_base64(ImageFormat::PNG, 200, 150, 1.0);
832834

835+
std::thread::sleep(std::time::Duration::from_secs(2));
836+
837+
dbg!(&image_base64);
833838
assert!(!image_base64.is_empty());
834839

835840
let result_decoded = general_purpose::STANDARD.decode(image_base64).unwrap();
@@ -850,13 +855,17 @@ mod tests {
850855
assert!(image_base64.is_empty());
851856
}
852857

853-
#[cfg(target_os = "linux")]
854858
#[test]
859+
#[ignore] // Fails in the CI
860+
#[cfg(not(target_os = "macos"))]
855861
#[cfg(feature = "kaleido")]
856862
fn test_image_to_svg_string() {
857863
let plot = create_test_plot();
858864
let image_svg = plot.to_svg(200, 150, 1.0);
859865

866+
std::thread::sleep(std::time::Duration::from_secs(2));
867+
dbg!(&image_svg);
868+
860869
assert!(!image_svg.is_empty());
861870

862871
let expected = "<svg class=\"main-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"200\" height=\"150\" style=\"\" viewBox=\"0 0 200 150\"><rect x=\"0\" y=\"0\" width=\"200\" height=\"150\" style=\"fill: rgb(255, 255, 255); fill-opacity: 1;\"/><defs id=\"defs-2dc70a\"><g class=\"clips\"><clipPath id=\"clip2dc70axyplot\" class=\"plotclip\"><rect width=\"40\" height=\"2\"/></clipPath><clipPath class=\"axesclip\" id=\"clip2dc70ax\"><rect x=\"80\" y=\"0\" width=\"40\" height=\"150\"/></clipPath><clipPath class=\"axesclip\" id=\"clip2dc70ay\"><rect x=\"0\" y=\"82\" width=\"200\" height=\"2\"/></clipPath><clipPath class=\"axesclip\" id=\"clip2dc70axy\"><rect x=\"80\" y=\"82\" width=\"40\" height=\"2\"/></clipPath></g><g class=\"gradients\"/></defs><g class=\"bglayer\"/><g class=\"layer-below\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"cartesianlayer\"><g class=\"subplot xy\"><g class=\"layer-subplot\"><g class=\"shapelayer\"/><g class=\"imagelayer\"/></g><g class=\"gridlayer\"><g class=\"x\"><path class=\"xgrid crisp\" transform=\"translate(100,0)\" d=\"M0,82v2\" style=\"stroke: rgb(238, 238, 238); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(114.25,0)\" d=\"M0,82v2\" style=\"stroke: rgb(238, 238, 238); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y\"/></g><g class=\"zerolinelayer\"><path class=\"xzl zl crisp\" transform=\"translate(85.75,0)\" d=\"M0,82v2\" style=\"stroke: rgb(68, 68, 68); stroke-opacity: 1; stroke-width: 1px;\"/></g><path class=\"xlines-below\"/><path class=\"ylines-below\"/><g class=\"overlines-below\"/><g class=\"xaxislayer-below\"/><g class=\"yaxislayer-below\"/><g class=\"overaxes-below\"/><g class=\"plot\" transform=\"translate(80,82)\" clip-path=\"url('#clip2dc70axyplot')\"><g class=\"scatterlayer mlayer\"><g class=\"trace scatter trace86f735\" style=\"stroke-miterlimit: 2; opacity: 1;\"><g class=\"fills\"/><g class=\"errorbars\"/><g class=\"lines\"><path class=\"js-line\" d=\"M5.75,1L20,0L34.25,2\" style=\"vector-effect: non-scaling-stroke; fill: none; stroke: rgb(31, 119, 180); stroke-opacity: 1; stroke-width: 2px; opacity: 1;\"/></g><g class=\"points\"><path class=\"point\" transform=\"translate(5.75,1)\" d=\"M3,0A3,3 0 1,1 0,-3A3,3 0 0,1 3,0Z\" style=\"opacity: 1; stroke-width: 0px; fill: rgb(31, 119, 180); fill-opacity: 1;\"/><path class=\"point\" transform=\"translate(20,0)\" d=\"M3,0A3,3 0 1,1 0,-3A3,3 0 0,1 3,0Z\" style=\"opacity: 1; stroke-width: 0px; fill: rgb(31, 119, 180); fill-opacity: 1;\"/><path class=\"point\" transform=\"translate(34.25,2)\" d=\"M3,0A3,3 0 1,1 0,-3A3,3 0 0,1 3,0Z\" style=\"opacity: 1; stroke-width: 0px; fill: rgb(31, 119, 180); fill-opacity: 1;\"/></g><g class=\"text\"/></g></g></g><g class=\"overplot\"/><path class=\"xlines-above crisp\" d=\"M0,0\" style=\"fill: none;\"/><path class=\"ylines-above crisp\" d=\"M0,0\" style=\"fill: none;\"/><g class=\"overlines-above\"/><g class=\"xaxislayer-above\"><g class=\"xtick\"><text text-anchor=\"middle\" x=\"0\" y=\"97\" transform=\"translate(85.75,0)\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(68, 68, 68); fill-opacity: 1; white-space: pre;\">0</text></g><g class=\"xtick\"><text text-anchor=\"middle\" x=\"0\" y=\"97\" transform=\"translate(100,0)\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(68, 68, 68); fill-opacity: 1; white-space: pre;\">1</text></g><g class=\"xtick\"><text text-anchor=\"middle\" x=\"0\" y=\"97\" transform=\"translate(114.25,0)\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(68, 68, 68); fill-opacity: 1; white-space: pre;\">2</text></g></g><g class=\"yaxislayer-above\"><g class=\"ytick\"><text text-anchor=\"end\" x=\"79\" y=\"4.199999999999999\" transform=\"translate(0,84)\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(68, 68, 68); fill-opacity: 1; white-space: pre;\">2</text></g><g class=\"ytick\"><text text-anchor=\"end\" x=\"79\" y=\"4.199999999999999\" transform=\"translate(0,83.5)\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(68, 68, 68); fill-opacity: 1; white-space: pre;\">4</text></g><g class=\"ytick\"><text text-anchor=\"end\" x=\"79\" y=\"4.199999999999999\" transform=\"translate(0,83)\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(68, 68, 68); fill-opacity: 1; white-space: pre;\">6</text></g><g class=\"ytick\"><text text-anchor=\"end\" x=\"79\" y=\"4.199999999999999\" transform=\"translate(0,82.5)\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(68, 68, 68); fill-opacity: 1; white-space: pre;\">8</text></g><g class=\"ytick\"><text text-anchor=\"end\" x=\"79\" y=\"4.199999999999999\" transform=\"translate(0,82)\" style=\"font-family: 'Open Sans', verdana, arial, sans-serif; font-size: 12px; fill: rgb(68, 68, 68); fill-opacity: 1; white-space: pre;\">10</text></g></g><g class=\"overaxes-above\"/></g></g><g class=\"polarlayer\"/><g class=\"ternarylayer\"/><g class=\"geolayer\"/><g class=\"funnelarealayer\"/><g class=\"pielayer\"/><g class=\"treemaplayer\"/><g class=\"sunburstlayer\"/><g class=\"glimages\"/><defs id=\"topdefs-2dc70a\"><g class=\"clips\"/></defs><g class=\"layer-above\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"infolayer\"><g class=\"g-gtitle\"/><g class=\"g-xtitle\"/><g class=\"g-ytitle\"/></g></svg>";

plotly_kaleido/src/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ impl Kaleido {
197197
"--disable-dev-shm-usage",
198198
"--disable-software-rasterizer",
199199
"--single-process",
200+
"--disable-gpu-driver-bug-workarounds",
201+
"--disable-gpu-driver-workarounds",
202+
"--disable-gpu-vsync",
200203
])
201204
.stdin(Stdio::piped())
202205
.stdout(Stdio::piped())
@@ -297,7 +300,7 @@ mod tests {
297300
}
298301

299302
// This seems to fail unpredictably on MacOs.
300-
#[cfg(target_os = "linux")]
303+
#[cfg(not(target_os = "macos"))]
301304
#[test]
302305
fn test_save_png() {
303306
let test_plot = create_test_plot();
@@ -309,7 +312,7 @@ mod tests {
309312
}
310313

311314
// This seems to fail unpredictably on MacOs.
312-
#[cfg(target_os = "linux")]
315+
#[cfg(not(target_os = "macos"))]
313316
#[test]
314317
fn test_save_jpeg() {
315318
let test_plot = create_test_plot();
@@ -321,7 +324,7 @@ mod tests {
321324
}
322325

323326
// This seems to fail unpredictably on MacOs.
324-
#[cfg(target_os = "linux")]
327+
#[cfg(not(target_os = "macos"))]
325328
#[test]
326329
fn test_save_webp() {
327330
let test_plot = create_test_plot();
@@ -333,7 +336,7 @@ mod tests {
333336
}
334337

335338
// This seems to fail unpredictably on MacOs.
336-
#[cfg(target_os = "linux")]
339+
#[cfg(not(target_os = "macos"))]
337340
#[test]
338341
fn test_save_svg() {
339342
let test_plot = create_test_plot();
@@ -345,7 +348,7 @@ mod tests {
345348
}
346349

347350
// This seems to fail unpredictably on MacOs.
348-
#[cfg(target_os = "linux")]
351+
#[cfg(not(target_os = "macos"))]
349352
#[test]
350353
fn test_save_pdf() {
351354
let test_plot = create_test_plot();

0 commit comments

Comments
 (0)