Execute prebuild_hook in the plugin directory

Set current working directory to the plugin directory before executing
prebuild hook. This allows prebuild hook script to refer to other
scripts in plugin directory using relative path.

Change-Id: I86193b26e5bd55ea55a712e473c2bbb3b36918fd
Closes-Bug: #1578598
This commit is contained in:
Georgy Kibardin 2016-06-29 12:20:05 +03:00 committed by Georgy Kibardin
parent c2d906f5ae
commit abfe5501b2
2 changed files with 8 additions and 6 deletions

View File

@ -53,8 +53,7 @@ class BaseBuildPlugin(BaseAction):
def __init__(self, plugin_path):
self.plugin_path = plugin_path
self.pre_build_hook_path = join_path(self.plugin_path,
'pre_build_hook')
self.pre_build_hook_cmd = './pre_build_hook'
self.meta = utils.parse_yaml(
join_path(self.plugin_path, 'metadata.yaml')
)
@ -78,8 +77,8 @@ class BaseBuildPlugin(BaseAction):
utils.remove_by_mask(self.result_package_mask)
def run_pre_build_hook(self):
if utils.which(self.pre_build_hook_path):
utils.exec_cmd(self.pre_build_hook_path)
if utils.which(join_path(self.plugin_path, self.pre_build_hook_cmd)):
utils.exec_cmd(self.pre_build_hook_cmd, self.plugin_path)
def add_checksums_file(self):
utils.create_checksums_file(self.build_src_dir, self.checksums_path)

View File

@ -76,8 +76,11 @@ class BaseBuild(BaseTestCase):
return_value=True)
def test_run_pre_build_hook(self, exec_cmd_mock, which_mock):
self.builder.run_pre_build_hook()
exec_cmd_mock.assert_called_once_with(self.builder.pre_build_hook_path)
which_mock.assert_called_once_with(self.builder.pre_build_hook_path)
exec_cmd_mock.assert_called_once_with(self.builder.pre_build_hook_cmd,
self.builder.plugin_path)
which_mock.assert_called_once_with(
join_path(self.builder.plugin_path,
self.builder.pre_build_hook_cmd))
@mock.patch('fuel_plugin_builder.actions.build.utils')
def test_build_repos(self, utils_mock):