| |
@@ -993,10 +993,13 @@
|
| |
def _mock_glob(g):
|
| |
return {
|
| |
os.path.join(cmd.path, 'x86_64', '*.rpm'): [bin_path],
|
| |
+ srpm_path: [srpm_path],
|
| |
}[g]
|
| |
+
|
| |
exists.side_effect = _mock_exists
|
| |
glob.side_effect = _mock_glob
|
| |
- cmd._get_build_arches_from_spec = Mock(return_value=['x86_64', 'x86_64'])
|
| |
+ cmd._get_build_arches_from_spec = Mock(
|
| |
+ return_value=['x86_64', 'x86_64'])
|
| |
|
| |
cmd.lint()
|
| |
|
| |
@@ -1008,6 +1011,74 @@
|
| |
bin_path,
|
| |
], shell=True)])
|
| |
|
| |
+ @patch('glob.glob')
|
| |
+ @patch('os.path.exists')
|
| |
+ @patch('pyrpkg.Commands._run_command')
|
| |
+ @patch('pyrpkg.Commands.load_rpmdefines', new=mock_load_rpmdefines)
|
| |
+ @patch('pyrpkg.Commands.rel', new_callable=PropertyMock)
|
| |
+ def test_lint_dist_git_results_layout(self, rel, run, exists, glob):
|
| |
+ rel.return_value = '2.fc26'
|
| |
+
|
| |
+ cmd = self.make_commands(results_dir='subdir')
|
| |
+ srpm_path = os.path.join(cmd.path, 'results',
|
| |
+ 'docpkg-1.2-2.fc26.src.rpm')
|
| |
+ bin_path = os.path.join(cmd.path, 'results',
|
| |
+ 'docpkg-1.2-2.fc26.x86_64.rpm')
|
| |
+
|
| |
+ def _mock_exists(path):
|
| |
+ return path in [srpm_path, os.path.join(cmd.path, 'results')]
|
| |
+
|
| |
+ def _mock_glob(g):
|
| |
+ return {
|
| |
+ os.path.join(cmd.path, 'results', '*.rpm'): [bin_path],
|
| |
+ srpm_path: [srpm_path],
|
| |
+ }[g]
|
| |
+
|
| |
+ exists.side_effect = _mock_exists
|
| |
+ glob.side_effect = _mock_glob
|
| |
+
|
| |
+ cmd.lint()
|
| |
+
|
| |
+ self.assertEqual(
|
| |
+ run.call_args_list,
|
| |
+ [call(['rpmlint',
|
| |
+ os.path.join(cmd.path, 'docpkg.spec'),
|
| |
+ srpm_path,
|
| |
+ bin_path,
|
| |
+ ], shell=True)])
|
| |
+
|
| |
+ @patch('glob.glob')
|
| |
+ @patch('os.path.exists')
|
| |
+ @patch('pyrpkg.Commands._run_command')
|
| |
+ @patch('pyrpkg.Commands.load_rpmdefines', new=mock_load_rpmdefines)
|
| |
+ @patch('pyrpkg.Commands.rel', new_callable=PropertyMock)
|
| |
+ def lint_mockbuild(self, rel, run, exists, glob):
|
| |
+ rel.return_value = '2.fc26'
|
| |
+
|
| |
+ cmd = self.make_commands()
|
| |
+ mockdir = os.path.join(cmd.path, 'results_docpkg/1.2.2/2.fc26')
|
| |
+ srpm_path = os.path.join(mockdir, 'docpkg-1.2-2.fc26.src.rpm')
|
| |
+ bin_path = os.path.join(mockdir, 'docpkg-1.2-2.fc26.x86_64.rpm')
|
| |
+
|
| |
+ def _mock_exists(path):
|
| |
+ return path in [mockdir]
|
| |
+
|
| |
+ def _mock_glob(g):
|
| |
+ return {mockdir: [srpm_path, bin_path]}[g]
|
| |
+
|
| |
+ exists.side_effect = _mock_exists
|
| |
+ glob.side_effect = _mock_glob
|
| |
+
|
| |
+ cmd.lint()
|
| |
+
|
| |
+ self.assertEqual(
|
| |
+ run.call_args_list,
|
| |
+ [call(['rpmlint',
|
| |
+ os.path.join(cmd.path, 'dockpkg.spec'),
|
| |
+ srpm_path,
|
| |
+ bin_path,
|
| |
+ ], shell=True)])
|
| |
+
|
| |
|
| |
class TestRunCommand(CommandTestCase):
|
| |
"""Test _run_command"""
|
| |
Subcommand lint was looking for srpm only in repository root,
and for rpms only with globs of form
%{ARCH}/*.rpm
.This works in many cases,
but not when the config option
results_dir
is set tosubdir
or when (if ever) SRPMLayout is used.
Fixed by using relevant layout parameters
when looking for files to lint.
It is difficult to account for layout parameter
rpmfilename
properly.In addition to a basename,
that parameter can contain a path relative to
rpmdir
and may contain rpm macros.
Since macro evaluation is not possible in the
rpkg lint
context,a simple heuristic is used instead,
covering the known cases:
%{ARCH}
.Also, support for linting mockbuild results is added.
As mockbuild is arguably even more important than local build,
cases where both mockbuild and local build results are present,
mockbuild results are selected.
Resolves #586