def test_expand_archive_with_chdir(self, mock_archive): with Stage(mock_archive.url, name=self.stage_name) as stage: stage.fetch() check_setup(stage, self.stage_name, mock_archive) check_fetch(stage, self.stage_name) stage.expand_archive() stage.chdir_to_source() check_expand_archive(stage, self.stage_name, mock_archive) check_chdir_to_source(stage, self.stage_name) check_destroy(stage, self.stage_name)
def apply(self, stage): """Apply the patch at self.path to the source code in the supplied stage Args: stage: stage for the package that needs to be patched """ stage.chdir_to_source() # Use -N to allow the same patches to be applied multiple times. _patch = which("patch", required=True) _patch('-s', '-p', str(self.level), '-i', self.path)
def apply(self, stage): """Fetch this patch, if necessary, and apply it to the source code in the supplied stage. """ stage.chdir_to_source() patch_stage = None try: if self.url: # use an anonymous stage to fetch the patch if it is a URL patch_stage = spack.stage.Stage(self.url) patch_stage.fetch() patch_file = patch_stage.archive_file else: patch_file = self.path # Use -N to allow the same patches to be applied multiple times. _patch('-s', '-p', str(self.level), '-i', patch_file) finally: if patch_stage: patch_stage.destroy()
def test_restage(self, mock_archive): with Stage(mock_archive.url, name=self.stage_name) as stage: stage.fetch() stage.expand_archive() stage.chdir_to_source() check_expand_archive(stage, self.stage_name, mock_archive) check_chdir_to_source(stage, self.stage_name) # Try to make a file in the old archive dir with open('foobar', 'w') as file: file.write("this file is to be destroyed.") assert 'foobar' in os.listdir(stage.source_path) # Make sure the file is not there after restage. stage.restage() check_chdir(stage, self.stage_name) check_fetch(stage, self.stage_name) stage.chdir_to_source() check_chdir_to_source(stage, self.stage_name) assert 'foobar' not in os.listdir(stage.source_path) check_destroy(stage, self.stage_name)