|
| 1 | +# CI Test Failure Debugging Notes |
| 2 | + |
| 3 | +## Problem Summary |
| 4 | + |
| 5 | +Tests pass on macOS but fail on Linux CI. The issue is extra columns appearing in org tables on macOS. |
| 6 | + |
| 7 | +## Evidence |
| 8 | + |
| 9 | +### macOS output (golden files): |
| 10 | +``` |
| 11 | +| idx | Name | Age | Score | \r | |
| 12 | +|-----+------+-----+-------|----| |
| 13 | +| 0 | Joe | 44 | 92.5 | \r | |
| 14 | +``` |
| 15 | + |
| 16 | +### Linux output (CI): |
| 17 | +``` |
| 18 | +| idx | Name | Age | Score | |
| 19 | +|-----+------+-----+-------| |
| 20 | +| 0 | Joe | 44 | 92.5 | |
| 21 | +``` |
| 22 | + |
| 23 | +## Where the `\r` comes from |
| 24 | + |
| 25 | +The carriage return is NOT in the Python output. Verified by checking: |
| 26 | +```python |
| 27 | +.venv/bin/python3 -c " |
| 28 | +import pandas as pd |
| 29 | +df = pd.DataFrame({'Name': ['Joe'], 'Age': [44]}) |
| 30 | +print(repr(df.to_markdown())) |
| 31 | +" |
| 32 | +# Output is clean, no \r |
| 33 | +``` |
| 34 | + |
| 35 | +The `\r` appears after Emacs processes the output. It's present in the staging org files: |
| 36 | +```bash |
| 37 | +grep -A 3 "RESULTS: print_table" tests/staging/babel-formatting.org | od -c |
| 38 | +# Shows literal \r byte before the final | |
| 39 | +``` |
| 40 | + |
| 41 | +## Suspects |
| 42 | + |
| 43 | +1. **org-table-align** - Called in `ob-python-extras/adjust-org-babel-results`. May interpret trailing content differently on macOS. |
| 44 | + |
| 45 | +2. **Process output handling** - How Emacs captures Python process stdout may differ between macOS and Linux. |
| 46 | + |
| 47 | +3. **Line ending handling** - macOS may be adding CR characters somewhere in the pipeline. |
| 48 | + |
| 49 | +## Attempted Fixes |
| 50 | + |
| 51 | +### 1. Added tabulate dependency |
| 52 | +Tabulate produces cleaner markdown output than the CSV fallback. Didn't fix the issue - the `\r` is added after Python outputs the data. |
| 53 | + |
| 54 | +### 2. Normalization in run_expect_tests.sh |
| 55 | +Added jq filters to strip: |
| 56 | +- `| \r |` at end of lines |
| 57 | +- `| |` (whitespace) at end of lines |
| 58 | +- `|----|` (separator) at end of lines |
| 59 | +- Bare `\r` characters |
| 60 | + |
| 61 | +Partially works but doesn't catch all cases because the separator column can have variable numbers of dashes. |
| 62 | + |
| 63 | +## Potential Solutions |
| 64 | + |
| 65 | +### Option A: Generate golden files on Linux |
| 66 | +Run `--update-goldens` in CI or on a Linux machine, then commit those. This would make the "expected" output match what Linux produces. |
| 67 | + |
| 68 | +### Option B: Fix the source of \r |
| 69 | +Find where in Emacs/ob-python-extras the carriage returns are being inserted and prevent it. Likely somewhere in: |
| 70 | +- `ob-python-extras.el` around line 464 (`ob-python-extras/my-align-advice-function`) |
| 71 | +- Or in how babel captures process output |
| 72 | + |
| 73 | +### Option C: More aggressive normalization |
| 74 | +Strip ALL trailing table columns that match `| .* |$` pattern, not just specific ones. Risk: might strip legitimate content. |
| 75 | + |
| 76 | +### Option D: Skip table comparison |
| 77 | +Only compare non-table lines, or use a fuzzy comparison for tables that ignores trailing columns. |
| 78 | + |
| 79 | +## Files Involved |
| 80 | + |
| 81 | +- `tests/run_expect_tests.sh` - Test runner with normalization logic |
| 82 | +- `tests/extract-results.el` - Extracts results from org files to JSON |
| 83 | +- `tests/golden/*.json` - Expected outputs (generated on macOS) |
| 84 | +- `ob-python-extras.el` - Main package, has org-table-align advice |
| 85 | +- `python/print_org_df.py` - DataFrame to org-table conversion |
0 commit comments