From 3100c65fc408598be7976ed7178003768493fcaf Mon Sep 17 00:00:00 2001 From: SRetip Date: Wed, 20 Mar 2024 17:17:34 +0200 Subject: [PATCH 1/3] change table format --- module/move/willbe/src/entity/test.rs | 29 ++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/module/move/willbe/src/entity/test.rs b/module/move/willbe/src/entity/test.rs index 024c0068c8..057d786d30 100644 --- a/module/move/willbe/src/entity/test.rs +++ b/module/move/willbe/src/entity/test.rs @@ -24,6 +24,7 @@ mod private // qqq : for Petro : don't do micro imports #[ cfg( feature = "progress_bar" ) ] use indicatif::{ MultiProgress, ProgressBar, ProgressStyle }; + use prettytable::format::{ FormatBuilder, TableFormat }; use rayon::ThreadPoolBuilder; use process_tools::process::*; use wtools::error::anyhow::{ Error, format_err }; @@ -146,14 +147,15 @@ mod private { writeln!( f, "Package : {}\nThe tests will be executed using the following configurations :", self.package.file_name().unwrap().to_string_lossy() )?; let mut table = Table::new(); - table.set_format( *prettytable::format::consts::FORMAT_NO_BORDER ); + let format = format(); + table.set_format( format ); let mut all_features = BTreeSet::new(); for variant in &self.test_variants { let features = variant.features.iter().cloned(); if features.len() == 0 { - all_features.extend( [ "[ ]".to_string() ] ); + all_features.extend( [ "[]".to_string() ] ); } all_features.extend( features ); } @@ -164,7 +166,7 @@ mod private { header_row.add_cell( Cell::new( feature ) ); } - table.add_row( header_row ); + table.set_titles( header_row ); for variant in &self.test_variants { @@ -268,6 +270,21 @@ mod private } } + fn format() -> TableFormat + { + let format = FormatBuilder::new() + .column_separator( ' ' ) + .borders( ' ' ) + .separators + ( + &[ prettytable::format::LinePosition::Title ], + prettytable::format::LineSeparator::new( '-', '+', '+', '+' ) + ) + .padding( 1, 1 ) + .build(); + format + } + #[ derive( Debug, Former ) ] pub struct PackageTestOptions< 'a > { @@ -490,6 +507,8 @@ mod private return Ok( () ) } let mut table = Table::new(); + let format = format(); + table.set_format( format ); table.set_format( *prettytable::format::consts::FORMAT_NO_BORDER ); let mut all_features = BTreeSet::new(); for variant in self.tests.keys() @@ -497,7 +516,7 @@ mod private let features = variant.features.iter().cloned(); if features.len() == 0 { - all_features.extend( [ "[ ]".to_string() ] ); + all_features.extend( [ "[]".to_string() ] ); } all_features.extend( features ); } @@ -509,7 +528,7 @@ mod private { header_row.add_cell( Cell::new( feature ) ); } - table.add_row( header_row ); + table.set_titles( header_row ); let mut failed = 0; let mut success = 0; From 4a2077d76d5b53e31973df0d79ffe778be7561a5 Mon Sep 17 00:00:00 2001 From: SRetip Date: Wed, 20 Mar 2024 17:34:20 +0200 Subject: [PATCH 2/3] add test case --- .../tests/inc/only_test/with_field_under_feature.rs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 module/core/former/tests/inc/only_test/with_field_under_feature.rs diff --git a/module/core/former/tests/inc/only_test/with_field_under_feature.rs b/module/core/former/tests/inc/only_test/with_field_under_feature.rs new file mode 100644 index 0000000000..f2def6fc85 --- /dev/null +++ b/module/core/former/tests/inc/only_test/with_field_under_feature.rs @@ -0,0 +1,8 @@ +// #[ derive( Former ) ] +// struct Foo +// { +// #[ cfg( feature = "baz" ) ] +// bar : i32, +// } + +// error => Unknown attribute #[cfg(feature = "baz")] \ No newline at end of file From 8e611a215844912f16b6e48e7233748a21b56c0d Mon Sep 17 00:00:00 2001 From: SRetip Date: Wed, 20 Mar 2024 17:36:46 +0200 Subject: [PATCH 3/3] add xxx --- .../core/former/tests/inc/only_test/with_field_under_feature.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/module/core/former/tests/inc/only_test/with_field_under_feature.rs b/module/core/former/tests/inc/only_test/with_field_under_feature.rs index f2def6fc85..2623f7579b 100644 --- a/module/core/former/tests/inc/only_test/with_field_under_feature.rs +++ b/module/core/former/tests/inc/only_test/with_field_under_feature.rs @@ -1,3 +1,4 @@ +// xxx : need to fix // #[ derive( Former ) ] // struct Foo // {