@@ -21,7 +21,7 @@ use datafusion_sqllogictest::{DataFusion, TestContext};
21
21
use futures:: stream:: StreamExt ;
22
22
use itertools:: Itertools ;
23
23
use log:: info;
24
- use sqllogictest:: strict_column_validator;
24
+ use sqllogictest:: { strict_column_validator, Normalizer } ;
25
25
use std:: ffi:: OsStr ;
26
26
use std:: fs;
27
27
use std:: path:: { Path , PathBuf } ;
@@ -40,19 +40,25 @@ pub fn main() -> Result<()> {
40
40
. block_on ( run_tests ( ) )
41
41
}
42
42
43
- fn value_validator ( actual : & [ Vec < String > ] , expected : & [ String ] ) -> bool {
44
- let expected = expected
45
- . iter ( )
46
- // Trailing whitespace from lines in SLT will typically be removed, but do not fail if it is not
47
- // If particular test wants to cover trailing whitespace on a value,
48
- // it should project additional non-whitespace column on the right.
49
- . map ( |s| s. trim_end ( ) . to_owned ( ) )
50
- . collect :: < Vec < _ > > ( ) ;
43
+ #[ allow( clippy:: ptr_arg) ]
44
+ fn normalizer ( s : & String ) -> String {
45
+ // Trailing whitespace from lines in SLT will typically be removed, but do not fail if it is not
46
+ // If particular test wants to cover trailing whitespace on a value,
47
+ // it should project additional non-whitespace column on the right.
48
+ s. trim_end ( ) . to_owned ( )
49
+ }
50
+
51
+ fn value_validator (
52
+ normalizer : Normalizer ,
53
+ actual : & [ Vec < String > ] ,
54
+ expected : & [ String ] ,
55
+ ) -> bool {
56
+ let expected = expected. iter ( ) . map ( normalizer) . collect :: < Vec < _ > > ( ) ;
51
57
let actual = actual
52
58
. iter ( )
53
59
. map ( |strs| strs. iter ( ) . join ( " " ) )
54
60
// Editors do not preserve trailing whitespace, so expected may or may not lack it included
55
- . map ( |s| s . trim_end ( ) . to_owned ( ) )
61
+ . map ( |str| normalizer ( & str ) )
56
62
. collect :: < Vec < _ > > ( ) ;
57
63
actual == expected
58
64
}
@@ -159,6 +165,7 @@ async fn run_test_file(test_file: TestFile) -> Result<()> {
159
165
) )
160
166
} ) ;
161
167
runner. with_column_validator ( strict_column_validator) ;
168
+ runner. with_normalizer ( normalizer) ;
162
169
runner. with_validator ( value_validator) ;
163
170
runner
164
171
. run_file_async ( path)
@@ -178,6 +185,7 @@ async fn run_test_file_with_postgres(test_file: TestFile) -> Result<()> {
178
185
let mut runner =
179
186
sqllogictest:: Runner :: new ( || Postgres :: connect ( relative_path. clone ( ) ) ) ;
180
187
runner. with_column_validator ( strict_column_validator) ;
188
+ runner. with_normalizer ( normalizer) ;
181
189
runner. with_validator ( value_validator) ;
182
190
runner
183
191
. run_file_async ( path)
@@ -217,6 +225,7 @@ async fn run_complete_file(test_file: TestFile) -> Result<()> {
217
225
path,
218
226
col_separator,
219
227
value_validator,
228
+ normalizer,
220
229
strict_column_validator,
221
230
)
222
231
. await
@@ -246,6 +255,7 @@ async fn run_complete_file_with_postgres(test_file: TestFile) -> Result<()> {
246
255
path,
247
256
col_separator,
248
257
value_validator,
258
+ normalizer,
249
259
strict_column_validator,
250
260
)
251
261
. await
0 commit comments