Skip to content

Commit

Permalink
On failure generate_references.py save error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Sep 4, 2024
1 parent a220d7f commit df3caa2
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions test/usecases/generate_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,31 @@ def substitute_line(lines, starts_with, replacement):
break


def ensure_directory_exists(filename=None, dirname=None):
if dirname is None:
dirname = os.path.dirname(filename)

if dirname and not os.path.exists(dirname):
os.makedirs(dirname)


def generate_references(nmodl, usecase_dir, output_dir, nmodl_flags):
mod_files = glob.glob(os.path.join(usecase_dir, "*.mod"))
for mod_file in mod_files:
try:
subprocess.run(
["nmodl", mod_file, *nmodl_flags, "-o", output_dir], check=True
[nmodl, mod_file, *nmodl_flags, "-o", output_dir],
capture_output=True,
check=True,
)
except subprocess.CalledProcessError as e:
print(e.output)
raise e
if e.output:
cxx_file = os.path.join(
output_dir, os.path.basename(mod_file[:-4] + ".cpp")
)
ensure_directory_exists(filename=cxx_file)
with open(cxx_file, "w") as cxx:
cxx.write(e.output.decode("utf-8"))

cxx_files = glob.glob(os.path.join(output_dir, "*.cpp"))

Expand Down

0 comments on commit df3caa2

Please sign in to comment.