Skip to content

Commit 8ecbf3c

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

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

plotly/src/plot.rs

Lines changed: 17 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,20 @@ 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+
assert!(!dst.exists());
771773
assert!(std::fs::remove_file(&dst).is_ok());
772774
assert!(!dst.exists());
773775
}
774776

775-
#[cfg(target_os = "linux")]
777+
#[cfg(not(target_os = "macos"))]
776778
#[test]
777779
#[cfg(feature = "kaleido")]
778780
fn test_save_to_svg() {
@@ -796,7 +798,7 @@ mod tests {
796798
assert!(!dst.exists());
797799
}
798800

799-
#[cfg(target_os = "linux")]
801+
#[cfg(not(target_os = "macos"))]
800802
#[test]
801803
#[cfg(feature = "kaleido")]
802804
fn test_save_to_pdf() {
@@ -820,16 +822,18 @@ mod tests {
820822
assert!(!dst.exists());
821823
}
822824

823-
#[cfg(target_os = "linux")]
824825
#[test]
826+
#[ignore] // Fails in the CI
827+
#[cfg(not(target_os = "macos"))]
825828
#[cfg(feature = "kaleido")]
826829
fn test_image_to_base64() {
827-
use base64::engine::general_purpose;
828-
use base64::Engine;
829830
let plot = create_test_plot();
830831

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

834+
std::thread::sleep(std::time::Duration::from_secs(2));
835+
836+
dbg!(&image_base64);
833837
assert!(!image_base64.is_empty());
834838

835839
let result_decoded = general_purpose::STANDARD.decode(image_base64).unwrap();
@@ -850,13 +854,17 @@ mod tests {
850854
assert!(image_base64.is_empty());
851855
}
852856

853-
#[cfg(target_os = "linux")]
854857
#[test]
858+
#[ignore] // Fails in the CI
859+
#[cfg(not(target_os = "macos"))]
855860
#[cfg(feature = "kaleido")]
856861
fn test_image_to_svg_string() {
857862
let plot = create_test_plot();
858863
let image_svg = plot.to_svg(200, 150, 1.0);
859864

865+
std::thread::sleep(std::time::Duration::from_secs(2));
866+
dbg!(&image_svg);
867+
860868
assert!(!image_svg.is_empty());
861869

862870
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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ mod tests {
297297
}
298298

299299
// This seems to fail unpredictably on MacOs.
300-
#[cfg(target_os = "linux")]
300+
#[cfg(not(target_os = "macos"))]
301301
#[test]
302302
fn test_save_png() {
303303
let test_plot = create_test_plot();
@@ -309,7 +309,7 @@ mod tests {
309309
}
310310

311311
// This seems to fail unpredictably on MacOs.
312-
#[cfg(target_os = "linux")]
312+
#[cfg(not(target_os = "macos"))]
313313
#[test]
314314
fn test_save_jpeg() {
315315
let test_plot = create_test_plot();
@@ -321,7 +321,7 @@ mod tests {
321321
}
322322

323323
// This seems to fail unpredictably on MacOs.
324-
#[cfg(target_os = "linux")]
324+
#[cfg(not(target_os = "macos"))]
325325
#[test]
326326
fn test_save_webp() {
327327
let test_plot = create_test_plot();
@@ -333,7 +333,7 @@ mod tests {
333333
}
334334

335335
// This seems to fail unpredictably on MacOs.
336-
#[cfg(target_os = "linux")]
336+
#[cfg(not(target_os = "macos"))]
337337
#[test]
338338
fn test_save_svg() {
339339
let test_plot = create_test_plot();
@@ -345,7 +345,7 @@ mod tests {
345345
}
346346

347347
// This seems to fail unpredictably on MacOs.
348-
#[cfg(target_os = "linux")]
348+
#[cfg(not(target_os = "macos"))]
349349
#[test]
350350
fn test_save_pdf() {
351351
let test_plot = create_test_plot();

0 commit comments

Comments
 (0)