File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name : CmdStanPy
2-
2+
33on :
44 push :
55 branches :
1414 description : ' Version to test'
1515 required : false
1616 default : ' latest'
17-
17+
1818jobs :
1919 get-cmdstan-version :
2020 # get the latest cmdstan version to use as part of the cache key
@@ -81,11 +81,15 @@ jobs:
8181 - name : Show libraries
8282 run : python -m pip freeze
8383
84+ - name : Get system info
85+ uses : kenchan0130/actions-system-info@v1.0.0
86+ id : system-info
87+
8488 - name : CmdStan installation cacheing
8589 uses : actions/cache@v2
8690 with :
8791 path : ~/.cmdstan
88- key : ${{ runner.os }}-cmdstan-${{ needs.get-cmdstan-version.outputs.version }}-${{ hashFiles('**/install_cmdstan.py') }}
92+ key : ${{ runner.os }}-${{ steps.system-info.outputs.release }}- cmdstan-${{ needs.get-cmdstan-version.outputs.version }}-${{ hashFiles('**/install_cmdstan.py') }}
8993
9094 - name : Install CmdStan (Linux, macOS)
9195 if : matrix.os != 'windows-latest'
Original file line number Diff line number Diff line change @@ -1319,8 +1319,10 @@ def pushd(new_dir: str) -> Iterator[None]:
13191319 """Acts like pushd/popd."""
13201320 previous_dir = os .getcwd ()
13211321 os .chdir (new_dir )
1322- yield
1323- os .chdir (previous_dir )
1322+ try :
1323+ yield
1324+ finally :
1325+ os .chdir (previous_dir )
13241326
13251327
13261328def report_signal (sig : int ) -> None :
Original file line number Diff line number Diff line change 4545 validate_dir ,
4646 windows_short_path ,
4747 write_stan_json ,
48+ pushd ,
4849)
4950
5051HERE = os .path .dirname (os .path .abspath (__file__ ))
@@ -807,6 +808,17 @@ def test_exit(self):
807808 do_command (args , HERE )
808809
809810
811+ class PushdTest (unittest .TestCase ):
812+
813+ def test_restore_cwd (self ):
814+ "Ensure do_command in a different cwd restores cwd after error."
815+ cwd = os .getcwd ()
816+ with self .assertRaises (RuntimeError ):
817+ with pushd (os .path .dirname (cwd )):
818+ raise RuntimeError ('error' )
819+ self .assertEqual (cwd , os .getcwd ())
820+
821+
810822class FlattenTest (unittest .TestCase ):
811823 def test_good (self ):
812824 array_3d = np .empty ((200 , 4 , 4 ))
You can’t perform that action at this time.
0 commit comments