@@ -3739,16 +3739,16 @@ def xs2str(xs):
37393739 if self .toolchain .mpi_family () and self .toolchain .mpi_family () in toolchain .OPENMPI :
37403740 env .setvar ('OMPI_MCA_rmaps_base_oversubscribe' , '1' )
37413741
3742- # change to install directory (better environment for running tests)
3743- if os . path . isdir ( self . installdir ):
3744- change_dir ( self . installdir )
3742+ # run sanity checks from an empty temp directory
3743+ # using the build or installation directory can produce false positives and polute them with files
3744+ sanity_work_dir = tempfile . mkdtemp ( prefix = 'eb-saniy-check-' )
37453745
37463746 # run sanity check commands
37473747 for cmd in commands :
37483748
37493749 trace_msg (f"running command '{ cmd } ' ..." )
37503750
3751- res = run_shell_cmd (cmd , fail_on_error = False , hidden = True )
3751+ res = run_shell_cmd (cmd , work_dir = sanity_work_dir , fail_on_error = False , hidden = True )
37523752 if res .exit_code != EasyBuildExit .SUCCESS :
37533753 fail_msg = f"sanity check command { cmd } failed with exit code { res .exit_code } (output: { res .output } )"
37543754 self .sanity_check_fail_msgs .append (fail_msg )
@@ -3802,8 +3802,8 @@ def xs2str(xs):
38023802 "Sanity check failed: " + '\n ' .join (self .sanity_check_fail_msgs ),
38033803 exit_code = EasyBuildExit .FAIL_SANITY_CHECK ,
38043804 )
3805- else :
3806- self .log .debug ("Sanity check passed!" )
3805+
3806+ self .log .debug ("Sanity check passed!" )
38073807
38083808 def _set_module_as_default (self , fake = False ):
38093809 """
0 commit comments