tools: build_examples: call cli directly instead of using runner
This commit is contained in:
parent
013d447b7f
commit
134feb4747
@ -2,7 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from click.testing import CliRunner
|
import click
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -53,7 +53,6 @@ def collect_filenames(description, groupkey, ext_list):
|
|||||||
|
|
||||||
|
|
||||||
def build_generated(groupkeys):
|
def build_generated(groupkeys):
|
||||||
runner = CliRunner()
|
|
||||||
for key in groupkeys:
|
for key in groupkeys:
|
||||||
# preparation
|
# preparation
|
||||||
path = groups[key]["path"]
|
path = groups[key]["path"]
|
||||||
@ -65,13 +64,12 @@ def build_generated(groupkeys):
|
|||||||
out.write(f'# {groups[key]["title"]}\n\n')
|
out.write(f'# {groups[key]["title"]}\n\n')
|
||||||
# collect and iterate input YAML files
|
# collect and iterate input YAML files
|
||||||
for yaml_file in collect_filenames("Building", key, input_extensions):
|
for yaml_file in collect_filenames("Building", key, input_extensions):
|
||||||
res = runner.invoke(cli, args=[
|
try:
|
||||||
'--format', 'ghpst',
|
res = cli(['--format', 'ghpst', str(yaml_file)])
|
||||||
str(yaml_file)
|
except BaseException as e:
|
||||||
])
|
if str(e) != '0' and not isinstance(e, (click.ClickException, SystemExit)):
|
||||||
if res.exit_code != 0:
|
raise
|
||||||
|
|
||||||
raise RuntimeError(f'Cli failed for {yaml_file} with result: {res}') from res.exception
|
|
||||||
if build_readme:
|
if build_readme:
|
||||||
i = "".join(filter(str.isdigit, yaml_file.stem))
|
i = "".join(filter(str.isdigit, yaml_file.stem))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user