|
21 | 21 | //! This file is organized as: |
22 | 22 | //! - Test runners that spawn individual test processes |
23 | 23 | //! - Test cases that contain the actual validation logic |
24 | | -use log::info; |
25 | | -use std::sync::Once; |
26 | 24 | use std::{process::Command, str}; |
27 | 25 |
|
28 | 26 | use crate::memory_limit::memory_limit_validation::utils; |
29 | 27 |
|
30 | | -static INIT: Once = Once::new(); |
31 | | - |
32 | 28 | // =========================================================================== |
33 | 29 | // Test runners: |
34 | 30 | // Runners are split into multiple tests to run in parallel |
@@ -69,62 +65,26 @@ fn sort_with_mem_limit_2_cols_2_runner() { |
69 | 65 | spawn_test_process("sort_with_mem_limit_2_cols_2"); |
70 | 66 | } |
71 | 67 |
|
72 | | -/// `spawn_test_process` might trigger multiple recompilations and the test binary |
73 | | -/// size might grow indefinitely. This initializer ensures recompilation is only done |
74 | | -/// once and the target size is bounded. |
75 | | -/// |
76 | | -/// TODO: This is a hack, can be cleaned up if we have a better way to let multiple |
77 | | -/// test cases run in different processes (instead of different threads by default) |
78 | | -fn init_once() { |
79 | | - INIT.call_once(|| { |
80 | | - let _ = Command::new("cargo") |
81 | | - .arg("test") |
82 | | - .arg("--no-run") |
83 | | - .arg("--package") |
84 | | - .arg("datafusion") |
85 | | - .arg("--test") |
86 | | - .arg("core_integration") |
87 | | - .arg("--features") |
88 | | - .arg("extended_tests") |
89 | | - .env("DATAFUSION_TEST_MEM_LIMIT_VALIDATION", "1") |
90 | | - .output() |
91 | | - .expect("Failed to execute test command"); |
92 | | - }); |
93 | | -} |
94 | | - |
95 | | -/// Helper function that executes a test in a separate process with the required environment |
96 | | -/// variable set. Memory limit validation tasks need to measure memory resident set |
97 | | -/// size (RSS), so they must run in a separate process. |
| 68 | +/// Helper function that executes a test in a separate process with the required |
| 69 | +/// environment variable set. Re-invokes the current test binary directly, |
| 70 | +/// avoiding cargo overhead and recompilation. |
98 | 71 | fn spawn_test_process(test: &str) { |
99 | | - init_once(); |
100 | | - |
101 | 72 | let test_path = |
102 | 73 | format!("memory_limit::memory_limit_validation::sort_mem_validation::{test}"); |
103 | | - info!("Running test: {test_path}"); |
104 | | - |
105 | | - // Run the test command |
106 | | - let output = Command::new("cargo") |
107 | | - .arg("test") |
108 | | - .arg("--package") |
109 | | - .arg("datafusion") |
110 | | - .arg("--test") |
111 | | - .arg("core_integration") |
112 | | - .arg("--features") |
113 | | - .arg("extended_tests") |
114 | | - .arg("--") |
| 74 | + |
| 75 | + let exe = std::env::current_exe().expect("Failed to get test binary path"); |
| 76 | + |
| 77 | + let output = Command::new(exe) |
115 | 78 | .arg(&test_path) |
116 | 79 | .arg("--exact") |
117 | 80 | .arg("--nocapture") |
118 | 81 | .env("DATAFUSION_TEST_MEM_LIMIT_VALIDATION", "1") |
119 | 82 | .output() |
120 | 83 | .expect("Failed to execute test command"); |
121 | 84 |
|
122 | | - // Convert output to strings |
123 | 85 | let stdout = str::from_utf8(&output.stdout).unwrap_or(""); |
124 | 86 | let stderr = str::from_utf8(&output.stderr).unwrap_or(""); |
125 | 87 |
|
126 | | - info!("{stdout}"); |
127 | | - |
128 | 88 | assert!( |
129 | 89 | output.status.success(), |
130 | 90 | "Test '{}' failed with status: {}\nstdout:\n{}\nstderr:\n{}", |
|
0 commit comments