From e9480fd156f687a91be01966b790e0fd2da7862c Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 29 Aug 2023 23:16:38 -0400 Subject: [PATCH] Disable the compare tests when the compare feature is disabled. --- build.rs | 12 ++++++++++++ tests/test_loader.rs | 1 + 2 files changed, 13 insertions(+) diff --git a/build.rs b/build.rs index 999e073..4186b8b 100644 --- a/build.rs +++ b/build.rs @@ -1,10 +1,16 @@ +#[cfg(feature = "compare")] use std::env; +#[cfg(feature = "compare")] use std::fs::File; +#[cfg(feature = "compare")] use std::io::Write; +#[cfg(feature = "compare")] use std::path::Path; +#[cfg(feature = "compare")] use walkdir::WalkDir; +#[cfg(feature = "compare")] fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let destination = Path::new(&out_dir).join("tests.rs"); @@ -31,6 +37,10 @@ fn main() { } } +#[cfg(not(feature = "compare"))] +fn main() {} + +#[cfg(feature = "compare")] fn write_test(test_file: &mut File, test: &walkdir::DirEntry) { let test_name = test .path() @@ -55,6 +65,7 @@ fn write_test(test_file: &mut File, test: &walkdir::DirEntry) { .unwrap(); } +#[cfg(feature = "compare")] fn write_header(test_file: &mut File) { write!( test_file, @@ -70,6 +81,7 @@ use organic::parser::sexp::sexp_with_padding; .unwrap(); } +#[cfg(feature = "compare")] fn is_expect_fail(name: &str) -> Option<&str> { match name { "autogen_greater_element_drawer_drawer_with_headline_inside" => Some("Apparently lines with :end: become their own paragraph. This odd behavior needs to be investigated more."), diff --git a/tests/test_loader.rs b/tests/test_loader.rs index 0471b27..9d63cc1 100644 --- a/tests/test_loader.rs +++ b/tests/test_loader.rs @@ -1 +1,2 @@ +#[cfg(feature = "compare")] include!(concat!(env!("OUT_DIR"), "/tests.rs"));