Skip to content

Conversation

@JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Mar 24, 2025

This makes it easier to figure out why a test is failing.

Example output on failure:

=================================== FAILURES ====================================
________________________ testAnnotateTwoOperationsOnLine ________________________
data: /Users/jukka/src/mypy/mypyc/test-data/annotate-basic.test:18:
Failed: Invalid source code output (/Users/jukka/src/mypy/mypyc/test-data/annotate-basic.test, line 18)
----------------------------- Captured stdout call ------------------------------
Generated IR:

def f(x):
    x :: object
    r0 :: str
    r1, r2, r3 :: object
L0:
    r0 = 'foo'
    r1 = CPyObject_GetAttr(x, r0)
    r2 = object 1
    r3 = PyNumber_Add(r1, r2)
    return r3
----------------------------- Captured stderr call ------------------------------
Expected:
  main:2: Get non-native attribute "foo". Generic "+" operation.x (diff)
Actual:
  main:2: Get non-native attribute "foo". Generic "+" operation. (diff)

Alignment of first line difference:
  E: ...Generic "+" operation.x
  A: ...Generic "+" operation.
                              ^
Update the test output using --update-data (implies -n0; you can additionally use the -k selector to update only specific tests)

This makes it easier to figure out why a test is failing.

Example output on failure:
```
=================================== FAILURES ====================================
________________________ testAnnotateTwoOperationsOnLine ________________________
data: /Users/jukka/src/mypy/mypyc/test-data/annotate-basic.test:18:
Failed: Invalid source code output (/Users/jukka/src/mypy/mypyc/test-data/annotate-basic.test, line 18)
----------------------------- Captured stdout call ------------------------------
Generated IR:

def f(x):
    x :: object
    r0 :: str
    r1, r2, r3 :: object
L0:
    r0 = 'foo'
    r1 = CPyObject_GetAttr(x, r0)
    r2 = object 1
    r3 = PyNumber_Add(r1, r2)
    return r3
----------------------------- Captured stderr call ------------------------------
Expected:
  main:2: Get non-native attribute "foo". Generic "+" operation.x (diff)
Actual:
  main:2: Get non-native attribute "foo". Generic "+" operation. (diff)

Alignment of first line difference:
  E: ...Generic "+" operation.x
  A: ...Generic "+" operation.
                              ^
Update the test output using --update-data (implies -n0; you can additionally use the -k selector to update only specific tests)
```
@JukkaL JukkaL merged commit 62d8709 into master Mar 24, 2025
12 checks passed
@JukkaL JukkaL deleted the mypyc-annotate-show-ir branch March 24, 2025 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants