File tree Expand file tree Collapse file tree 3 files changed +20
-23
lines changed
Expand file tree Collapse file tree 3 files changed +20
-23
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ require "../spec_helper"
55require " compiler/crystal/ffi"
66require " compiler/crystal/loader"
77require " ../loader/spec_helper"
8+ require " ../../support/env"
89
910# all the integral return types must be at least as large as the register size
1011# to avoid integer promotion by FFI!
3637{% end % }
3738
3839describe Crystal ::FFI ::CallInterface do
39- before_all do
40+ around_all do | example |
4041 FileUtils .mkdir_p(SPEC_CRYSTAL_LOADER_LIB_PATH )
4142 build_c_dynlib(compiler_datapath(" ffi" , " sum.c" ))
4243
4344 {% if flag?(:win32 ) && flag?(:gnu ) % }
44- ENV [" PATH" ] = " #{ SPEC_CRYSTAL_LOADER_LIB_PATH } #{ Process ::PATH_DELIMITER } #{ ENV [" PATH" ]} "
45- {% end % }
46- end
47-
48- after_all do
49- {% if flag?(:win32 ) && flag?(:gnu ) % }
50- ENV [" PATH" ] = ENV [" PATH" ].delete_at(0 , ENV [" PATH" ].index!(Process ::PATH_DELIMITER ) + 1 )
45+ with_env({" PATH" => " #{ SPEC_CRYSTAL_LOADER_LIB_PATH } #{ Process ::PATH_DELIMITER } #{ ENV [" PATH" ]} " }) do
46+ example.run
47+ end
48+ {% else % }
49+ example.run
5150 {% end % }
5251
5352 FileUtils .rm_rf(SPEC_CRYSTAL_LOADER_LIB_PATH )
Original file line number Diff line number Diff line change 11{% skip_file if flag?(:without_interpreter ) % }
22require " ./spec_helper"
33require " ../loader/spec_helper"
4+ require " ../../support/env"
45
56private def ldflags
67 {% if flag?(:msvc ) % }
@@ -19,18 +20,16 @@ private def ldflags_with_backtick
1920end
2021
2122describe Crystal ::Repl ::Interpreter do
22- before_all do
23+ around_all do | example |
2324 FileUtils .mkdir_p(SPEC_CRYSTAL_LOADER_LIB_PATH )
2425 build_c_dynlib(compiler_datapath(" interpreter" , " sum.c" ))
2526
2627 {% if flag?(:win32 ) % }
27- ENV [" PATH" ] = " #{ SPEC_CRYSTAL_LOADER_LIB_PATH } #{ Process ::PATH_DELIMITER } #{ ENV [" PATH" ]} "
28- {% end % }
29- end
30-
31- after_all do
32- {% if flag?(:win32 ) % }
33- ENV [" PATH" ] = ENV [" PATH" ].delete_at(0 , ENV [" PATH" ].index!(Process ::PATH_DELIMITER ) + 1 )
28+ with_env({" PATH" => " #{ SPEC_CRYSTAL_LOADER_LIB_PATH } #{ Process ::PATH_DELIMITER } #{ ENV [" PATH" ]} " }) do
29+ example.run
30+ end
31+ {% else % }
32+ example.run
3433 {% end % }
3534
3635 FileUtils .rm_rf(SPEC_CRYSTAL_LOADER_LIB_PATH )
Original file line number Diff line number Diff line change 11require " ./spec_helper"
22require " ../support/env"
33
4- private def unset_tempdir ( & )
4+ private def reset_tempdir ( tmp_path = nil , & )
55 {% if flag?(:windows ) % }
6- with_env(" TMP" : nil , " TEMP" : nil , " USERPROFILE" : nil ) { yield }
6+ with_env(" TMP" : tmp_path , " TEMP" : nil , " USERPROFILE" : nil ) { yield }
77 {% else % }
8- with_env(" TMPDIR" : nil ) { yield }
8+ with_env(" TMPDIR" : tmp_path ) { yield }
99 {% end % }
1010end
1111
@@ -665,7 +665,7 @@ describe "Dir" do
665665
666666 describe " .tempdir" do
667667 it " returns default directory for tempfiles" do
668- unset_tempdir do
668+ reset_tempdir do
669669 {% if flag?(:windows ) % }
670670 # GetTempPathW defaults to the Windows directory when %TMP%, %TEMP%
671671 # and %USERPROFILE% are not set.
@@ -681,9 +681,8 @@ describe "Dir" do
681681 end
682682
683683 it " returns configure directory for tempfiles" do
684- unset_tempdir do
685- tmp_path = Path [" my_temporary_path" ].expand.to_s
686- ENV [{{ flag?(:windows ) ? " TMP" : " TMPDIR" }}] = tmp_path
684+ tmp_path = Path [" my_temporary_path" ].expand.to_s
685+ reset_tempdir(tmp_path) do
687686 Dir .tempdir.should eq tmp_path
688687 end
689688 end
You can’t perform that action at this time.
0 commit comments