Skip to content

feat(lib): propagate manim render exit code #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(unreleased)=
## [Unreleased](https://github.com/jeertmans/manim-slides/compare/v5.5.1...HEAD)

(unreleased-added)=
### Added

- `manim-slides render` now exists with the same return code as the one returned by `manim render` or `manimgl`.
[@chrjabs](https://github.com/chrjabs) [#545](https://github.com/jeertmans/manim-slides/pull/545)

(unreleased-chore)=
### Chore

Expand Down
5 changes: 3 additions & 2 deletions manim_slides/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
if ce and gl:
raise click.UsageError("You cannot specify both --CE and --GL renderers.")
if gl:
subprocess.run([sys.executable, "-m", "manimlib", "-w", *args])
completed = subprocess.run([sys.executable, "-m", "manimlib", "-w", *args])

Check warning on line 51 in manim_slides/render.py

View check run for this annotation

Codecov / codecov/patch

manim_slides/render.py#L51

Added line #L51 was not covered by tests
else:
subprocess.run([sys.executable, "-m", "manim", "render", *args])
completed = subprocess.run([sys.executable, "-m", "manim", "render", *args])
sys.exit(completed.returncode)
5 changes: 5 additions & 0 deletions tests/data/slides.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ def construct(self):

class BasicSlideSkipReversing(BasicSlide):
skip_reversing = True


class FailingSlide(Slide):
def construct(self):
self.play("this fails to render")
31 changes: 31 additions & 0 deletions tests/test_slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,37 @@ def test_render_basic_slide(
assert local_presentation_config.resolution == presentation_config.resolution


@pytest.mark.parametrize(
"renderer",
[
"--CE",
pytest.param(
"--GL",
marks=pytest.mark.skipif(
sys.version_info < (3, 10),
reason="See https://github.com/3b1b/manim/issues/2263.",
),
),
"--CE --renderer=opengl",
],
ids=("CE", "GL", "CE(GL)"),
)
def test_render_failing_slide(
renderer: str,
slides_file: Path,
manimgl_config: Path,
) -> None:
runner = CliRunner()

with runner.isolated_filesystem() as tmp_dir:
shutil.copy(manimgl_config, tmp_dir)
results = runner.invoke(
render, [*renderer.split(" "), str(slides_file), "FailingSlide", "-ql"]
)

assert results.exit_code != 0, results


def test_clear_cache(
slides_file: Path,
) -> None:
Expand Down
Loading