From ec67d226fdd0c767ed2ff2d018e8944dfa42ed8c Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 28 Nov 2024 10:52:15 +0100 Subject: [PATCH] add test for line endings --- tests/integration_test.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/integration_test.rs b/tests/integration_test.rs index a303b7e..3bf28ac 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -358,6 +358,30 @@ async fn test_reproducible_shasum( insta::assert_snapshot!(format!("sha256-{}-executable", platform), &sha256_digest); } +#[rstest] +#[case(Platform::Linux64)] +#[case(Platform::Win64)] +#[tokio::test] +async fn test_line_endings( + #[case] platform: Platform, + #[with(PathBuf::from("examples/simple-python/pixi.toml"), "default".to_string(), platform, None, None, false, "env".to_string(), true)] + options: Options, +) { + let pack_result = pixi_pack::pack(options.pack_options.clone()).await; + assert!(pack_result.is_ok(), "{:?}", pack_result); + + let out_file = options.pack_options.output_file.clone(); + let output = fs::read_to_string(&out_file).unwrap(); + + if platform.is_windows() { + let num_crlf = output.matches("\r\n").count(); + let num_lf = output.matches("\n").count(); + assert_eq!(num_crlf, num_lf); + } else { + assert!(!output.contains("\r\n")); + } +} + #[rstest] #[tokio::test] async fn test_non_authenticated(