spark: Fix test script to use absolute paths for portable testing
This commit is contained in:
1 parent
1798728434
commit
5face4ef6d
1 file changed
+6
-3
@@ -3,6 +3,9 @@
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
def run_test(cmd, expected, description):
|
||||
"""Run a test command and verify output."""
|
||||
@@ -19,21 +22,21 @@ def run_test(cmd, expected, description):
|
||||
|
||||
# Test CSV mode with known data
|
||||
test_csv_pass = run_test(
|
||||
['python3', 'line_counter.py', 'test_data.csv', 'csv'],
|
||||
['python3', f'{BASE_DIR}/line_counter.py', f'{BASE_DIR}/test_data.csv', 'csv'],
|
||||
5,
|
||||
"CSV count mode (5 items)"
|
||||
)
|
||||
|
||||
# Test count mode with known lines
|
||||
test_count_pass = run_test(
|
||||
['python3', 'line_counter.py', 'test_log.txt', 'count'],
|
||||
['python3', f'{BASE_DIR}/line_counter.py', f'{BASE_DIR}/test_log.txt', 'count'],
|
||||
10,
|
||||
"Line count mode (10 lines)"
|
||||
)
|
||||
|
||||
# Test error handling for non-existent file
|
||||
result = subprocess.run(
|
||||
['python3', 'line_counter.py', 'nonexistent.txt', 'count'],
|
||||
['python3', f'{BASE_DIR}/line_counter.py', f'{BASE_DIR}/nonexistent.txt', 'count'],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user