Skip to content

Commit a53031a

Browse files
antonsyndclaude
andcommitted
fix: Handle raw output format in dogfood convert tool
The _extract_program_output function was expecting output files to contain the "=== Running Program ===" marker, but newer dogfood output files store raw program output without this marker. This caused empty .expected files to be generated, breaking the integration tests. The fix handles both formats: if the marker is present, extract content after it; otherwise use the raw content as-is. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b7a75f7 commit a53031a

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

build_tools/sharpy_dogfood/convert.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
def _extract_program_output(actual_output: str) -> str:
1616
"""Extract just the program output from actual_output.txt.
1717
18-
The actual_output.txt contains lines like:
18+
The actual_output.txt may contain lines like:
1919
Successfully compiled to: /path/to/exe
2020
=== Running Program ===
2121
<actual program output here>
2222
23+
Or it may just contain the raw program output (newer format).
24+
2325
This function extracts only the program output portion.
2426
Note: The dogfood tool strips trailing whitespace from output, but
2527
Console.WriteLine actually produces a trailing newline, so we add it back.
@@ -35,11 +37,16 @@ def _extract_program_output(actual_output: str) -> str:
3537
if in_output:
3638
output_lines.append(line)
3739

38-
# Join and preserve the trailing newline if present
39-
result = "\n".join(output_lines)
40-
# Remove leading empty line if present (from the blank line after "=== Running Program ===")
41-
if result.startswith("\n"):
42-
result = result[1:]
40+
# If we found the marker, use the extracted lines
41+
if in_output:
42+
result = "\n".join(output_lines)
43+
# Remove leading empty line if present (from the blank line after "=== Running Program ===")
44+
if result.startswith("\n"):
45+
result = result[1:]
46+
else:
47+
# No marker found - the file contains raw output (newer format)
48+
result = actual_output
49+
4350
# Add trailing newline since print() adds one but dogfood strips it
4451
if result and not result.endswith("\n"):
4552
result += "\n"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
True
2+
False
3+
True
4+
False
5+
True
6+
True
7+
True
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
31
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2024
2+
4
3+
150
4+
85
5+
100
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
40
2+
26
3+
True
4+
False
5+
8
6+
48

0 commit comments

Comments
 (0)