Run the TUI and check if columns are properly sized
()
| 7 | import os |
| 8 | |
| 9 | def test_column_widths(): |
| 10 | """Run the TUI and check if columns are properly sized""" |
| 11 | print("Testing column width fix...") |
| 12 | print("=" * 60) |
| 13 | |
| 14 | # Use XCAPTURE_DATADIR environment variable or default |
| 15 | datadir = os.environ.get('XCAPTURE_DATADIR', '/home/tanel/dev/0xtools-next/xcapture/out') |
| 16 | |
| 17 | # Command to run |
| 18 | cmd = [ |
| 19 | "../xtop", |
| 20 | "-d", datadir, |
| 21 | "--from", "2025-08-11T16:25:00", |
| 22 | "--to", "2025-08-11T17:05:00", |
| 23 | "--debuglog", "width_test.log" |
| 24 | ] |
| 25 | |
| 26 | print(f"Running: {' '.join(cmd)}") |
| 27 | print() |
| 28 | print("Please check:") |
| 29 | print("1. On initial load, columns should be properly sized") |
| 30 | print("2. Content should NOT be truncated") |
| 31 | print("3. You should NOT need to press 'r' to fix widths") |
| 32 | print() |
| 33 | print("Press Ctrl+C to stop the TUI when done checking") |
| 34 | print("=" * 60) |
| 35 | |
| 36 | try: |
| 37 | # Run the TUI |
| 38 | subprocess.run(cmd) |
| 39 | except KeyboardInterrupt: |
| 40 | print("\nTest completed") |
| 41 | |
| 42 | # Check the debug log |
| 43 | print("\nChecking debug log for column width info...") |
| 44 | try: |
| 45 | with open("width_test.log", "r") as f: |
| 46 | for line in f: |
| 47 | if "Added column:" in line and "width:" in line: |
| 48 | print(line.strip()) |
| 49 | except FileNotFoundError: |
| 50 | print("Debug log not found") |
| 51 | |
| 52 | if __name__ == "__main__": |
| 53 | test_column_widths() |