Skip to content

run_all_examples: display stdout/stderr when a script fails #11

@jeromeetienne

Description

@jeromeetienne

Problem

When tools/run_all_examples.py runs an example script that fails, the captured subprocess output (stdout/stderr) is silently discarded. It is only shown when --verbose is passed manually, making it hard to diagnose failures at a glance.

Proposed Fix

Change launch_example to return (success, stdout, stderr) instead of a plain bool, then always print the captured output in main() when a script fails.

launch_example signature change

def launch_example(cmdline_args: list[str], env_variables: dict[str, str]) -> tuple[bool, str, str]:
  • On success: return (True, result.stdout, result.stderr)
  • On CalledProcessError: return (False, error.stdout, error.stderr)
  • Remove the now-unused verbose parameter

Call site update in main()

run_success, out, err = launch_example([sys.executable, script_path, *example_args], env_variables=env_variables)

Display on failure

if not run_success:
    if out:
        print(out)
    if err:
        print(err, file=sys.stderr)
    sys.exit(1)

Files

  • tools/run_all_examples.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions