55from collections .abc import Mapping
66from typing import Any , Generator
77
8- from tests .util import *
8+ from tests .util import Config
99from jinja2 import Template
1010
1111TRANSPILE_SH : str = r"""#!/usr/bin/env bash
8888
8989cd "${SCRIPT_DIR}"
9090
91- c2rust-postprocess --update-rust {{args}} repo/lib.rs > "$LOG_FILE"
91+ c2rust-postprocess --update-rust {{args}} repo/lib.rs 2>&1 | tee "$LOG_FILE"
9292"""
9393
9494CARGO_SH : str = r"""#!/usr/bin/env bash
@@ -167,9 +167,7 @@ def autogen_refactor(conf: str, yaml: dict[str, Any]) -> Generator[Path, None, N
167167 # Get list of transformations from config
168168 transforms = refactor .get ("transforms" )
169169 if transforms and isinstance (transforms , list ):
170- lines = [
171- t .strip () for t in transforms if isinstance (t , str ) and t .strip ()
172- ]
170+ lines = [t .strip () for t in transforms if isinstance (t , str ) and t .strip ()]
173171 if lines :
174172 params ["transform_lines" ] = "\n " .join (lines )
175173 elif transforms and isinstance (transforms , str ):
@@ -184,7 +182,9 @@ def autogen_refactor(conf: str, yaml: dict[str, Any]) -> Generator[Path, None, N
184182 yield Path (out_path )
185183
186184
187- def autogen_postprocess (conf : str , yaml : dict [str , Any ]) -> Generator [Path , None , None ]:
185+ def autogen_postprocess (
186+ conf : str , yaml : dict [str , Any ], verbose : bool
187+ ) -> Generator [Path , None , None ]:
188188 """
189189 Yield generated paths.
190190 """
@@ -204,7 +204,12 @@ def autogen_postprocess(conf: str, yaml: dict[str, Any]) -> Generator[Path, None
204204 exclude_file = conf .with_name ("postprocess-exclude.yml" )
205205 if exclude_file .exists ():
206206 # args are relative to script dir
207- params ["args" ] = shlex .join (["--exclude-file" , str (exclude_file .relative_to (conf .parent ))])
207+ params ["args" ] = shlex .join (
208+ ["--exclude-file" , str (exclude_file .relative_to (conf .parent ))]
209+ )
210+
211+ if verbose :
212+ params ["args" ] = f"--log-level DEBUG { params ['args' ]} " .rstrip ()
208213
209214 out_path = conf .with_name ("postprocess.gen.sh" )
210215 render_script (POSTPROCESS_SH , out_path , params )
@@ -257,5 +262,5 @@ def autogen(conf: Config) -> Generator[Path, None, None]:
257262 for cf , yaml in conf .project_conf .items ():
258263 yield from autogen_transpile (cf , yaml )
259264 yield from autogen_refactor (cf , yaml )
260- yield from autogen_postprocess (cf , yaml )
265+ yield from autogen_postprocess (cf , yaml , conf . verbose )
261266 yield from autogen_cargo (cf , yaml )
0 commit comments