spark: Fix test script to use absolute paths for portable testing

This commit is contained in:
spark committed 2026-10-28 23:22:33 +00:00
1 parent 1798728434
commit 5face4ef6d
1 file changed
+6 -3
+6 -3
View File
@@ -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
)