tools: build_examples: call cli directly instead of using runner

This commit is contained in:
Laurier Loiselle 2023-01-25 13:27:58 -05:00
parent 013d447b7f
commit 134feb4747
No known key found for this signature in database
GPG Key ID: 345920CC72089A3F

View File

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import argparse
from click.testing import CliRunner
import click
import os
import sys
from pathlib import Path
@ -53,7 +53,6 @@ def collect_filenames(description, groupkey, ext_list):
def build_generated(groupkeys):
runner = CliRunner()
for key in groupkeys:
# preparation
path = groups[key]["path"]
@ -65,13 +64,12 @@ def build_generated(groupkeys):
out.write(f'# {groups[key]["title"]}\n\n')
# collect and iterate input YAML files
for yaml_file in collect_filenames("Building", key, input_extensions):
res = runner.invoke(cli, args=[
'--format', 'ghpst',
str(yaml_file)
])
if res.exit_code != 0:
try:
res = cli(['--format', 'ghpst', str(yaml_file)])
except BaseException as e:
if str(e) != '0' and not isinstance(e, (click.ClickException, SystemExit)):
raise
raise RuntimeError(f'Cli failed for {yaml_file} with result: {res}') from res.exception
if build_readme:
i = "".join(filter(str.isdigit, yaml_file.stem))