def test_patch_step(self): """Test patch step.""" test_easyconfigs = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'easyconfigs', 'test_ecs') ec = process_easyconfig(os.path.join(test_easyconfigs, 't', 'toy', 'toy-0.0.eb'))[0] orig_sources = ec['ec']['sources'][:] toy_patches = [ 'toy-0.0_typo.patch', # test for applying patch ('toy-extra.txt', 'toy-0.0'), # test for patch-by-copy ] self.assertEqual(ec['ec']['patches'], toy_patches) # test applying patches without sources ec['ec']['sources'] = [] eb = EasyBlock(ec['ec']) eb.fetch_step() eb.extract_step() self.assertErrorRegex(EasyBuildError, '.*', eb.patch_step) # test actual patching of unpacked sources ec['ec']['sources'] = orig_sources eb = EasyBlock(ec['ec']) eb.fetch_step() eb.extract_step() eb.patch_step() # verify that patches were applied toydir = os.path.join(eb.builddir, 'toy-0.0') self.assertEqual(sorted(os.listdir(toydir)), ['toy-extra.txt', 'toy.source', 'toy.source.orig']) self.assertTrue("and very proud of it" in read_file(os.path.join(toydir, 'toy.source'))) self.assertEqual(read_file(os.path.join(toydir, 'toy-extra.txt')), 'moar!\n')
def test_patch_step(self): """Test patch step.""" test_easyconfigs = os.path.join( os.path.abspath(os.path.dirname(__file__)), 'easyconfigs') ec = process_easyconfig(os.path.join(test_easyconfigs, 'toy-0.0.eb'))[0] orig_sources = ec['ec']['sources'][:] toy_patches = [ 'toy-0.0_typo.patch', # test for applying patch ('toy-extra.txt', 'toy-0.0'), # test for patch-by-copy ] self.assertEqual(ec['ec']['patches'], toy_patches) # test applying patches without sources ec['ec']['sources'] = [] eb = EasyBlock(ec['ec']) eb.fetch_step() eb.extract_step() self.assertErrorRegex(EasyBuildError, '.*', eb.patch_step) # test actual patching of unpacked sources ec['ec']['sources'] = orig_sources eb = EasyBlock(ec['ec']) eb.fetch_step() eb.extract_step() eb.patch_step() # verify that patches were applied toydir = os.path.join(eb.builddir, 'toy-0.0') self.assertEqual(sorted(os.listdir(toydir)), ['toy-extra.txt', 'toy.source', 'toy.source.orig']) self.assertTrue("and very proud of it" in read_file( os.path.join(toydir, 'toy.source'))) self.assertEqual(read_file(os.path.join(toydir, 'toy-extra.txt')), 'moar!\n')
def run(self, unpack_src=False): """Common operations for extensions: unpacking sources, patching, ...""" # unpack file if desired if unpack_src: targetdir = os.path.join(self.master.builddir, remove_unwanted_chars(self.name)) self.ext_dir = extract_file("%s" % self.src, targetdir, extra_options=self.unpack_options) if self.start_dir and os.path.isdir(self.start_dir): self.log.debug("Using start_dir: %s", self.start_dir) change_dir(self.start_dir) # patch if needed EasyBlock.patch_step(self, beginpath=self.ext_dir)
def test_patch_step(self): """Test patch step.""" ec = process_easyconfig(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'easyconfigs', 'toy-0.0.eb'))[0] orig_sources = ec['ec']['sources'][:] # test applying patches without sources ec['ec']['sources'] = [] eb = EasyBlock(ec['ec']) eb.fetch_step() eb.extract_step() self.assertErrorRegex(EasyBuildError, '.*', eb.patch_step) # test actual patching of unpacked sources ec['ec']['sources'] = orig_sources eb = EasyBlock(ec['ec']) eb.fetch_step() eb.extract_step() eb.patch_step()
def run(self, unpack_src=False): """Common operations for extensions: unpacking sources, patching, ...""" # unpack file if desired if unpack_src: targetdir = os.path.join(self.master.builddir, remove_unwanted_chars(self.name)) self.ext_dir = extract_file(self.src, targetdir, extra_options=self.unpack_options, change_into_dir=False, cmd=self.src_extract_cmd) # setting start dir must be done from unpacked source directory for extension, # because start_dir value is usually a relative path (if it is set) change_dir(self.ext_dir) self._set_start_dir() change_dir(self.start_dir) else: self._set_start_dir() # patch if needed EasyBlock.patch_step(self, beginpath=self.ext_dir)