示例#1
0
    def _test_rmtree(self, *args, **kwargs):
        testdir = tempfile.mkdtemp()
        with open(os.path.join(testdir, 'foo.txt'), 'w') as fp:
            fp.write('hello\n')

        os_ext.rmtree(testdir, *args, **kwargs)
        assert not os.path.exists(testdir)
示例#2
0
    def _makedir(self, *dirs, wipeout=False):
        ret = os.path.join(*dirs)
        if wipeout:
            os_ext.rmtree(ret, ignore_errors=True)

        os.makedirs(ret, exist_ok=True)
        return ret
示例#3
0
def test_rmtree_error(tmp_path):
    # Try to remove an inexistent directory
    testdir = tmp_path / 'tmp'
    testdir.mkdir()
    os.rmdir(str(testdir))
    with pytest.raises(OSError):
        os_ext.rmtree(testdir)
示例#4
0
def safe_rmtree(path, **kwargs):
    '''Do some safety checks before removing path to protect against silly, but
    catastrophic bugs, during development.

    Do not allow removing any subdirectory of reframe or any directory
    containing reframe. Also do not allow removing the user's $HOME directory.
    '''

    path = os.path.abspath(path)
    common_path = os.path.commonpath([reframe.INSTALL_PREFIX, path])
    assert common_path != reframe.INSTALL_PREFIX
    assert common_path != path
    assert path != os.environ['HOME']
    os_ext.rmtree(path, **kwargs)
示例#5
0
    def cleanup(self, remove_files=False, unload_env=True):
        """The cleanup phase of the regression test pipeline.

        :arg remove_files: If :class:`True`, the stage directory associated
            with this test will be removed.
        :arg unload_env: If :class:`True`, the environment that was used to run
            this test will be unloaded.
        """
        aliased = os.path.samefile(self._stagedir, self._outputdir)
        if aliased:
            self.logger.debug('skipping copy to output dir '
                              'since they alias each other')
        else:
            self._copy_to_outputdir()

        if remove_files:
            self.logger.debug('removing stage directory')
            os_ext.rmtree(self._stagedir)

        if unload_env:
            self.logger.debug("unloading test's environment")
            self._user_environ.unload()
            self._current_environ.unload()
            self._current_partition.local_env.unload()
示例#6
0
 def tearDown(self):
     os_ext.rmtree(self.prefix)
     os_ext.rmtree(self.perflogdir, ignore_errors=True)
     os_ext.force_remove_file(self.logfile)
示例#7
0
 def tearDown(self):
     self.perf_file.close()
     self.output_file.close()
     os.remove(self.perf_file.name)
     os.remove(self.output_file.name)
     os_ext.rmtree(self.resourcesdir)
示例#8
0
 def tearDown(self):
     os_ext.rmtree(rt.runtime().resources.prefix)
     os_ext.rmtree('.rfm_testing', ignore_errors=True)
示例#9
0
 def tearDown(self):
     os_ext.rmtree(rt.runtime().resources.prefix)
示例#10
0
 def tearDown(self):
     os_ext.rmtree(self.workdir)
示例#11
0
 def test_rmtree_error(self):
     # Try to remove an inexistent directory
     testdir = tempfile.mkdtemp()
     os.rmdir(testdir)
     with pytest.raises(OSError):
         os_ext.rmtree(testdir)
示例#12
0
 def _rmtree(*args, **kwargs):
     os_ext.rmtree(testdir, *args, **kwargs)
     assert not os.path.exists(testdir)