1- use assert_cmd:: Command ;
1+ use assert_cmd:: cargo :: cargo_bin_cmd ;
22use parquet:: arrow:: arrow_reader:: { ArrowReaderOptions , ParquetRecordBatchReaderBuilder } ;
33use parquet:: file:: metadata:: ParquetMetaDataReader ;
44use std:: fs;
@@ -16,8 +16,7 @@ fn test_tpchgen_cli_tbl_scale_factor_0_001() {
1616 let temp_dir = tempdir ( ) . expect ( "Failed to create temporary directory" ) ;
1717
1818 // Run the tpchgen-cli command
19- Command :: cargo_bin ( "tpchgen-cli" )
20- . expect ( "Binary not found" )
19+ cargo_bin_cmd ! ( "tpchgen-cli" )
2120 . arg ( "--scale-factor" )
2221 . arg ( "0.001" )
2322 . arg ( "--output-dir" )
@@ -73,8 +72,7 @@ fn test_tpchgen_cli_tbl_no_overwrite() {
7372 let expected_file = temp_dir. path ( ) . join ( "part.tbl" ) ;
7473
7574 // First run - create the file
76- Command :: cargo_bin ( "tpchgen-cli" )
77- . expect ( "Binary not found" )
75+ cargo_bin_cmd ! ( "tpchgen-cli" )
7876 . arg ( "--scale-factor" )
7977 . arg ( "0.001" )
8078 . arg ( "--tables" )
@@ -90,8 +88,7 @@ fn test_tpchgen_cli_tbl_no_overwrite() {
9088
9189 // Run the tpchgen-cli command again with the same parameters and expect the
9290 // file to not be overwritten and a warning to be logged
93- let output = Command :: cargo_bin ( "tpchgen-cli" )
94- . expect ( "Binary not found" )
91+ let output = cargo_bin_cmd ! ( "tpchgen-cli" )
9592 . arg ( "--scale-factor" )
9693 . arg ( "0.001" )
9794 . arg ( "--tables" )
@@ -128,8 +125,7 @@ fn test_tpchgen_cli_parquet_no_overwrite() {
128125 let expected_file = temp_dir. path ( ) . join ( "part.parquet" ) ;
129126
130127 // First run - create the file
131- Command :: cargo_bin ( "tpchgen-cli" )
132- . expect ( "Binary not found" )
128+ cargo_bin_cmd ! ( "tpchgen-cli" )
133129 . arg ( "parquet" )
134130 . arg ( "--scale-factor" )
135131 . arg ( "0.001" )
@@ -146,8 +142,7 @@ fn test_tpchgen_cli_parquet_no_overwrite() {
146142
147143 // Run the tpchgen-cli command again with the same parameters and expect the
148144 // file to not be overwritten and a warning to be logged
149- let output = Command :: cargo_bin ( "tpchgen-cli" )
150- . expect ( "Binary not found" )
145+ let output = cargo_bin_cmd ! ( "tpchgen-cli" )
151146 . arg ( "parquet" )
152147 . arg ( "--scale-factor" )
153148 . arg ( "0.001" )
@@ -185,8 +180,7 @@ fn test_tpchgen_cli_quiet_flag() {
185180 let expected_file = temp_dir. path ( ) . join ( "part.tbl" ) ;
186181
187182 // First run - create the file
188- Command :: cargo_bin ( "tpchgen-cli" )
189- . expect ( "Binary not found" )
183+ cargo_bin_cmd ! ( "tpchgen-cli" )
190184 . arg ( "--scale-factor" )
191185 . arg ( "0.001" )
192186 . arg ( "--tables" )
@@ -202,8 +196,7 @@ fn test_tpchgen_cli_quiet_flag() {
202196
203197 // Run the tpchgen-cli command again with --quiet flag
204198 // Expect the file to not be overwritten and NO warning even though warnings show by default
205- let output = Command :: cargo_bin ( "tpchgen-cli" )
206- . expect ( "Binary not found" )
199+ let output = cargo_bin_cmd ! ( "tpchgen-cli" )
207200 . arg ( "--scale-factor" )
208201 . arg ( "0.001" )
209202 . arg ( "--tables" )
@@ -245,8 +238,7 @@ fn test_tpchgen_cli_parts() {
245238
246239 let num_parts = 4 ;
247240 let output_dir = temp_dir. path ( ) . to_path_buf ( ) ;
248- Command :: cargo_bin ( "tpchgen-cli" )
249- . expect ( "Binary not found" )
241+ cargo_bin_cmd ! ( "tpchgen-cli" )
250242 . arg ( "--scale-factor" )
251243 . arg ( "0.001" )
252244 . arg ( "--output-dir" )
@@ -276,8 +268,7 @@ fn test_tpchgen_cli_parts_explicit() {
276268 threads. push ( std:: thread:: spawn ( move || {
277269 // Run the tpchgen-cli command for each part
278270 // output goes into `output_dir/orders/orders.{part}.tbl`
279- Command :: cargo_bin ( "tpchgen-cli" )
280- . expect ( "Binary not found" )
271+ cargo_bin_cmd ! ( "tpchgen-cli" )
281272 . arg ( "--scale-factor" )
282273 . arg ( "0.001" )
283274 . arg ( "--output-dir" )
@@ -306,8 +297,7 @@ fn test_tpchgen_cli_parts_all_tables() {
306297
307298 let num_parts = 8 ;
308299 let output_dir = temp_dir. path ( ) . to_path_buf ( ) ;
309- Command :: cargo_bin ( "tpchgen-cli" )
310- . expect ( "Binary not found" )
300+ cargo_bin_cmd ! ( "tpchgen-cli" )
311301 . arg ( "--scale-factor" )
312302 . arg ( "0.001" )
313303 . arg ( "--output-dir" )
@@ -358,8 +348,7 @@ async fn test_write_parquet_orders() {
358348 // Run the CLI command to generate parquet data
359349 let output_dir = tempdir ( ) . unwrap ( ) ;
360350 let output_path = output_dir. path ( ) . join ( "orders.parquet" ) ;
361- Command :: cargo_bin ( "tpchgen-cli" )
362- . expect ( "Binary not found" )
351+ cargo_bin_cmd ! ( "tpchgen-cli" )
363352 . arg ( "parquet" )
364353 . arg ( "--tables" )
365354 . arg ( "orders" )
@@ -403,8 +392,7 @@ async fn test_write_parquet_orders() {
403392async fn test_write_parquet_row_group_size_default ( ) {
404393 // Run the CLI command to generate parquet data with default settings
405394 let output_dir = tempdir ( ) . unwrap ( ) ;
406- Command :: cargo_bin ( "tpchgen-cli" )
407- . expect ( "Binary not found" )
395+ cargo_bin_cmd ! ( "tpchgen-cli" )
408396 . arg ( "parquet" )
409397 . arg ( "--scale-factor" )
410398 . arg ( "1" )
@@ -470,8 +458,7 @@ async fn test_write_parquet_row_group_size_default() {
470458async fn test_write_parquet_row_group_size_20mb ( ) {
471459 // Run the CLI command to generate parquet data with larger row group size
472460 let output_dir = tempdir ( ) . unwrap ( ) ;
473- Command :: cargo_bin ( "tpchgen-cli" )
474- . expect ( "Binary not found" )
461+ cargo_bin_cmd ! ( "tpchgen-cli" )
475462 . arg ( "parquet" )
476463 . arg ( "--scale-factor" )
477464 . arg ( "1" )
@@ -530,8 +517,7 @@ fn test_tpchgen_cli_part_no_parts() {
530517 let temp_dir = tempdir ( ) . expect ( "Failed to create temporary directory" ) ;
531518
532519 // CLI Error test --part and but not --parts
533- Command :: cargo_bin ( "tpchgen-cli" )
534- . expect ( "Binary not found" )
520+ cargo_bin_cmd ! ( "tpchgen-cli" )
535521 . arg ( "--output-dir" )
536522 . arg ( temp_dir. path ( ) )
537523 . arg ( "--part" )
@@ -548,8 +534,7 @@ fn test_tpchgen_cli_too_many_parts() {
548534 let temp_dir = tempdir ( ) . expect ( "Failed to create temporary directory" ) ;
549535
550536 // This should fail because --part is 42 which is more than the --parts 10
551- Command :: cargo_bin ( "tpchgen-cli" )
552- . expect ( "Binary not found" )
537+ cargo_bin_cmd ! ( "tpchgen-cli" )
553538 . arg ( "--output-dir" )
554539 . arg ( temp_dir. path ( ) )
555540 . arg ( "--part" )
@@ -567,8 +552,7 @@ fn test_tpchgen_cli_too_many_parts() {
567552fn test_tpchgen_cli_zero_part ( ) {
568553 let temp_dir = tempdir ( ) . expect ( "Failed to create temporary directory" ) ;
569554
570- Command :: cargo_bin ( "tpchgen-cli" )
571- . expect ( "Binary not found" )
555+ cargo_bin_cmd ! ( "tpchgen-cli" )
572556 . arg ( "--output-dir" )
573557 . arg ( temp_dir. path ( ) )
574558 . arg ( "--part" )
@@ -585,8 +569,7 @@ fn test_tpchgen_cli_zero_part() {
585569fn test_tpchgen_cli_zero_part_zero_parts ( ) {
586570 let temp_dir = tempdir ( ) . expect ( "Failed to create temporary directory" ) ;
587571
588- Command :: cargo_bin ( "tpchgen-cli" )
589- . expect ( "Binary not found" )
572+ cargo_bin_cmd ! ( "tpchgen-cli" )
590573 . arg ( "--output-dir" )
591574 . arg ( temp_dir. path ( ) )
592575 . arg ( "--part" )
@@ -604,8 +587,7 @@ fn test_tpchgen_cli_zero_part_zero_parts() {
604587#[ tokio:: test]
605588async fn test_incompatible_options_warnings ( ) {
606589 let output_dir = tempdir ( ) . unwrap ( ) ;
607- Command :: cargo_bin ( "tpchgen-cli" )
608- . expect ( "Binary not found" )
590+ cargo_bin_cmd ! ( "tpchgen-cli" )
609591 . arg ( "--format" )
610592 . arg ( "csv" )
611593 . arg ( "--tables" )
@@ -634,8 +616,7 @@ async fn test_incompatible_options_warnings() {
634616#[ tokio:: test]
635617async fn test_quiet_flag_suppresses_warnings ( ) {
636618 let output_dir = tempdir ( ) . unwrap ( ) ;
637- let output = Command :: cargo_bin ( "tpchgen-cli" )
638- . expect ( "Binary not found" )
619+ let output = cargo_bin_cmd ! ( "tpchgen-cli" )
639620 . env ( "RUST_LOG" , "warn" )
640621 . arg ( "--format" )
641622 . arg ( "csv" )
0 commit comments