From 3805a0d9f12bed09b9ecbd95c42432f1d3ac5486 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: May 09 2018 07:06:13 +0000 Subject: Merge #313 `Minor fixes relative to PR #295` --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 2d4d206..4aa47da 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -686,6 +686,10 @@ class Commands(object): self.log.debug('Errors occoured while running following command to get N-V-R-E:') self.log.debug(joined_cmd) self.log.error(err) + if proc.returncode > 0: + raise rpkgError('Could not get n-v-r-e from %s' + % os.path.join(self.path, self.spec)) + # Get just the output, then split it by ??, grab the first and split # again to get ver and rel first_line_output = output.split('??')[1] diff --git a/tests/test_commands.py b/tests/test_commands.py index 55d7376..e2ad992 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -137,6 +137,17 @@ class LoadNameVerRelTest(CommandTestCase): """ self.assertRaises(rpkgError, self.cmd.load_nameverrel) + def test_load_when_echo_text_from_spec(self): + import utils + self.write_file(os.path.join(self.cloned_repo_path, self.spec_file), + content=utils.spec_file_echo_text) + + self.cmd.load_nameverrel() + self.assertEqual('docpkg', self.cmd._module_name_spec) + self.assertEqual('0', self.cmd._epoch) + self.assertEqual('1.2', self.cmd._ver) + self.assertEqual('2.el6', self.cmd._rel) + class LoadBranchMergeTest(CommandTestCase): """Test case for testing Commands.load_branch_merge""" diff --git a/tests/utils.py b/tests/utils.py index 5a4ac91..631ba14 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -56,6 +56,30 @@ rm -rf $$RPM_BUILD_ROOT - Initial version ''' +spec_file_echo_text = ''' +Summary: Dummy summary +Name: docpkg +Version: 1.2 +Release: 2%{dist} +License: GPL +%{echo:some text} +%{echo:other pkg info} +%description +Dummy docpkg for tests +%prep +%check +%build +touch README.rst +%clean +%install +%files +%defattr(-,root,root,-) +%doc README.rst +%changelog +* Thu Apr 21 2016 Tester - 1.2-2 +- Initial version +''' + class Assertions(object):