Skip to content

Make examples work when compiled - #630

Open
redorlik wants to merge 3 commits into
spylang:mainfrom
redorlik:main
Open

redorlik wants to merge 3 commits into
spylang:mainfrom
redorlik:main

Conversation

@redorlik

Copy link
Copy Markdown

Added a way to test if the examples work when compiled. Due to a problem of getting the correct return code with the "spy bull -x", the building process is separate from the test of the executable.

There are four examples that are not compilable at this point in time, and these examples are marked as XFAIL.

AI was not used in this pull request

redorlik added 3 commits July 19, 2026 14:19
… subprocesses. It might also improve the chance for working on windows. The remaining failing examples are marked as XFAIL. Also some debug prints are removed

@antocuni antocuni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but see the comment on how to detect xfails.

Also, I see that tests fail early due to ruff check. You might want to install/enable pre-commit, see CONTRIBUTING.md.

Comment thread examples/test_examples.py
Comment on lines +128 to +129
if spy_file.stem in ['collections','annotated','unroll_nested_loops','convert']:
pytest.xfail()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this approach.
The biggest issue is that it doesn't solve the problem that you encountered during the sprint, i.e. that you opened an example, tried to compile and see it was broken.

I think that a better way is the following:

  1. add a special "marker" at the beginning of the docstring of examples which are known not to compile
  2. detected the marker here (could be something as simple as if MARKER in spy_file.read()).

What to use as a marker is open to discussion, but I propose something like this in the first line of the docstring:

"""
SPY BUILD: xfail

Things to notice:
  - Tuples, dicts, and lists work as in Python.
[...]
"""

def main() -> None:
    ...

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