Skip to content

Commit f0730a8

Browse files
committed
fix cwd regress test
1 parent 7adcf89 commit f0730a8

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

cmdstanpy/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ def do_command(
10011001
10021002
"""
10031003
get_logger().debug('cmd: %s\ncwd: %s', ' '.join(cmd), cwd)
1004+
restore_cwd = os.getcwd() if cwd is not None else None
10041005
try:
10051006
# NB: Using this rather than cwd arg to Popen due to windows behavior
10061007
with pushd(cwd if cwd is not None else '.'):
@@ -1042,6 +1043,8 @@ def do_command(
10421043
raise RuntimeError(msg)
10431044
except OSError as e:
10441045
msg = 'Command: {}\nfailed with error {}\n'.format(cmd, str(e))
1046+
if restore_cwd is not None:
1047+
os.chdir(restore_cwd)
10451048
raise RuntimeError(msg) from e
10461049

10471050

0 commit comments

Comments
 (0)