Skip to content

Custom runners for non-Python code fences - #67

Merged
Elias Freider (freider) merged 7 commits into
mainfrom
add-custom-runners
Nov 5, 2026
Merged

Elias Freider (freider) merged 7 commits into
mainfrom
add-custom-runners

Conversation

@aaazzam

@aaazzam Adam Azzam (aaazzam) commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

This PR closes #66 by making custom runners usable for non-Python fences.

It does so by adding two opt-in paths:

  1. runner:<name> now collects any fence language with the named registered runner.
  2. register_runner(default_for=(...)) registers a runner as the default for specific fence languages.

Custom runners were always available a la (1) above, but only for python-based fences. Adding more opt-in paths of course adds marginal complexity to the runner selection precedence, which this PR makes:

  1. Explicit runner:<name> on the fence.
  2. A language match from default_for.
  3. The global default runner for built-in Python fences.
  4. Ignore the fence.

This PR enables us to do things like:

@register_runner(default_for=("js", "javascript"))
class JavascriptRunner(DefaultRunner):
    ...

which sets a global default for js and javascript fences

```js
expect(value).toBe(1)
```

while allowing per-fence customizeability

```js runner:OtherRunner
expect(value).toBe(1)
```

Also exposes all fence options (info-string options plus mdx-comment metadata) as an options: frozenset field on FenceTestDefinition, so custom runners can define their own per-fence flags without declaring a placeholder pytest fixture for each one.

@freider Elias Freider (freider) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

love it!

Adam Azzam (aaazzam) and others added 7 commits November 5, 2026 16:32
Custom runners previously had only fixture names as a per-fence metadata
channel, forcing consumers to declare placeholder pytest fixtures for
flags whose values are never used. Expose the full set of fence options
(info-string options plus mdx-comment metadata) as an `options`
frozenset on FenceTestDefinition so runners can define their own flags.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@freider
Elias Freider (freider) merged commit 64c1816 into main Nov 5, 2026
10 checks passed
@freider
Elias Freider (freider) deleted the add-custom-runners branch November 5, 2026 21:36
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.

Custom runners for non-Python code fences

2 participants