| |
@@ -577,6 +577,52 @@
|
| |
self.assertEqual('', cli.cmd.repo.git.log('--merges'))
|
| |
|
| |
|
| |
+ class TestClone(CliTestCase):
|
| |
+ """Test clone command"""
|
| |
+ def shortDescription(self):
|
| |
+ return None
|
| |
+
|
| |
+ @patch('sys.stderr', new=StringIO())
|
| |
+ @patch('pyrpkg.Commands._clone_config', new_callable=Mock())
|
| |
+ @patch('pyrpkg.Commands._run_command')
|
| |
+ def test_extra_args(self, _run_command, _clone_config):
|
| |
+ cli_cmd = ['rpkg', '--user', 'dude', '--path', self.cloned_repo_path,
|
| |
+ 'clone', 'repository_name', '--', '--progress']
|
| |
+
|
| |
+ with patch('sys.argv', new=cli_cmd):
|
| |
+ cli = self.new_cli()
|
| |
+ cli.clone()
|
| |
+
|
| |
+ expected_cmd = ['git', 'clone', 'ssh://dude@localhost/repository_name',
|
| |
+ '--origin', 'origin', '--progress']
|
| |
+ _run_command.assert_called_once_with(expected_cmd,
|
| |
+ cwd=self.cloned_repo_path)
|
| |
+ output = sys.stderr.getvalue().strip()
|
| |
+ self.assertEqual('', output)
|
| |
+
|
| |
+ @patch('sys.stderr', new=StringIO())
|
| |
+ @patch('pyrpkg.Commands._clone_config', new_callable=Mock())
|
| |
+ @patch('pyrpkg.Commands._run_command')
|
| |
+ def test_extra_args_incorrect(self, _run_command, _clone_config):
|
| |
+ """Missing '--' separator between standard arguments and extra
|
| |
+ arguments. This can be valid command but might have different
|
| |
+ and unexpected behaviour. Warning is shown."""
|
| |
+
|
| |
+ cli_cmd = ['rpkg', '--user', 'dude', '--path', self.cloned_repo_path,
|
| |
+ 'clone', 'repository_name', '--progress']
|
| |
+
|
| |
+ with patch('sys.argv', new=cli_cmd):
|
| |
+ cli = self.new_cli()
|
| |
+ cli.clone()
|
| |
+
|
| |
+ expected_cmd = ['git', 'clone', 'ssh://dude@localhost/repository_name',
|
| |
+ '--origin', 'origin', '--progress']
|
| |
+ _run_command.assert_called_once_with(expected_cmd,
|
| |
+ cwd=self.cloned_repo_path)
|
| |
+ output = sys.stderr.getvalue().strip()
|
| |
+ self.assertIn('extra_args in the command are not separated', output)
|
| |
+
|
| |
+
|
| |
class TestSrpm(CliTestCase):
|
| |
"""Test srpm command"""
|
| |
|
| |
@@ -595,14 +641,28 @@
|
| |
@patch('pyrpkg.Commands._run_command')
|
| |
def test_srpm_with_options(self, _run_command):
|
| |
cli_cmd = ['rpkg', '--path', self.cloned_repo_path, '--release', 'rhel-6', 'srpm',
|
| |
- '--define', 'macro1 meansthis']
|
| |
+ '--define', '"macro1 meansthis"']
|
| |
|
| |
with patch('sys.argv', new=cli_cmd):
|
| |
cli = self.new_cli()
|
| |
cli.srpm()
|
| |
|
| |
expected_cmd = ['rpmbuild'] + cli.cmd.rpmdefines + \
|
| |
- ['--define', 'macro1 meansthis', '--nodeps', '-bs',
|
| |
+ ['--define', '"macro1 meansthis"', '--nodeps', '-bs',
|
| |
+ os.path.join(cli.cmd.path, cli.cmd.spec)]
|
| |
+ _run_command.assert_called_once_with(expected_cmd, shell=True)
|
| |
+
|
| |
+ @patch('pyrpkg.Commands._run_command')
|
| |
+ def test_srpm_with_extra_args(self, _run_command):
|
| |
+ cli_cmd = ['rpkg', '--path', self.cloned_repo_path, '--release', 'rhel-6', 'srpm',
|
| |
+ '--', '--define', '"name body"', '--undefine', 'python']
|
| |
+
|
| |
+ with patch('sys.argv', new=cli_cmd):
|
| |
+ cli = self.new_cli()
|
| |
+ cli.srpm()
|
| |
+
|
| |
+ expected_cmd = ['rpmbuild'] + cli.cmd.rpmdefines + \
|
| |
+ ['--define', '"name body"', '--undefine', 'python', '--nodeps', '-bs',
|
| |
os.path.join(cli.cmd.path, cli.cmd.spec)]
|
| |
_run_command.assert_called_once_with(expected_cmd, shell=True)
|
| |
|
| |
@@ -630,7 +690,7 @@
|
| |
|
| |
cli_cmd = ['rpkg', '--path', self.cloned_repo_path, '--release', 'rhel-6', '-q', 'compile',
|
| |
'--builddir', builddir, '--short-circuit', '--arch', 'i686', '--nocheck',
|
| |
- '--define', 'macro1 meansthis']
|
| |
+ '--define', 'macro1 meansthis', '--', '--rmspec']
|
| |
|
| |
with patch('sys.argv', new=cli_cmd):
|
| |
cli = self.new_cli()
|
| |
@@ -639,7 +699,7 @@
|
| |
spec = os.path.join(cli.cmd.path, cli.cmd.spec)
|
| |
rpmbuild = ['rpmbuild'] + cli.cmd.rpmdefines + \
|
| |
["--define '_builddir %s'" % builddir, '--target', 'i686',
|
| |
- '--define', 'macro1 meansthis', '--short-circuit',
|
| |
+ '--define', 'macro1 meansthis', '--rmspec', '--short-circuit',
|
| |
'--nocheck', '--quiet', '-bc', spec]
|
| |
|
| |
_run_command.assert_called_once_with(rpmbuild, shell=True)
|
| |
@@ -669,7 +729,7 @@
|
| |
cli_cmd = [
|
| |
'rpkg', '--path', self.cloned_repo_path, '--release', 'rhel-6',
|
| |
'-q', 'compile', '--arch', 'i686', '--builddir', builddir,
|
| |
- '--buildrootdir', buildrootdir
|
| |
+ '--buildrootdir', buildrootdir, '--', '-v'
|
| |
]
|
| |
|
| |
with patch('sys.argv', new=cli_cmd):
|
| |
@@ -678,7 +738,7 @@
|
| |
|
| |
spec = os.path.join(cli.cmd.path, cli.cmd.spec)
|
| |
rpmbuild = ['rpmbuild'] + cli.cmd.rpmdefines + [
|
| |
- "--define '_builddir %s'" % builddir, '--target', 'i686',
|
| |
+ "--define '_builddir %s'" % builddir, '--target', 'i686', '-v',
|
| |
'--quiet', "--define '_buildrootdir %s'" % buildrootdir,
|
| |
'--nodeps', '-bp', spec
|
| |
]
|
| |
@@ -756,7 +816,8 @@
|
| |
cli_cmd = [
|
| |
'rpkg', '--path', self.cloned_repo_path, '--release', 'rhel-6',
|
| |
'-q', 'local', '--builddir', builddir, '--arch', 'i686',
|
| |
- '--with', 'a', '--without', 'b', '--buildrootdir', buildrootdir]
|
| |
+ '--with', 'a', '--without', 'b', '--buildrootdir', buildrootdir,
|
| |
+ '--', '--clean']
|
| |
|
| |
with patch('sys.argv', new=cli_cmd):
|
| |
cli = self.new_cli()
|
| |
@@ -766,7 +827,7 @@
|
| |
rpmbuild = ['rpmbuild'] + cli.cmd.rpmdefines + [
|
| |
'--with', 'a', '--without', 'b',
|
| |
"--define '_builddir %s'" % builddir,
|
| |
- '--target', 'i686', '--quiet',
|
| |
+ '--target', 'i686', '--clean', '--quiet',
|
| |
"--define '_buildrootdir %s'" % buildrootdir,
|
| |
'-ba', spec
|
| |
]
|
| |
@@ -813,8 +874,9 @@
|
| |
spec = os.path.join(cli.cmd.path, cli.cmd.spec)
|
| |
rpmbuild = ['rpmbuild'] + cli.cmd.rpmdefines + [
|
| |
"--define '_builddir %s'" % builddir,
|
| |
+ '--quiet',
|
| |
"--define '_buildrootdir %s'" % buildrootdir,
|
| |
- '--quiet', '-bl', spec
|
| |
+ '-bl', spec
|
| |
]
|
| |
_run_command.assert_called_once_with(rpmbuild, shell=True)
|
| |
|
| |
@@ -1621,6 +1683,33 @@
|
| |
]
|
| |
self.mock_run_command.assert_called_with(expected_cmd)
|
| |
|
| |
+ def test_extra_args(self):
|
| |
+ cli_cmd = ['rpkg', '--path', self.cloned_repo_path,
|
| |
+ '--release', 'rhel-6', 'mockbuild',
|
| |
+ '--root', '/etc/mock/some-root',
|
| |
+ '--with', 'a',
|
| |
+ '--', '--with', 'd', '--without', '"bb"']
|
| |
+ cli = self.mockbuild(cli_cmd)
|
| |
+
|
| |
+ expected_cmd = ['mock', '--with', 'a', '--with', 'd',
|
| |
+ '--without', '"bb"', '-r', '/etc/mock/some-root',
|
| |
+ '--resultdir', cli.cmd.mock_results_dir, '--rebuild',
|
| |
+ cli.cmd.srpmname]
|
| |
+ self.mock_run_command.assert_called_with(expected_cmd)
|
| |
+
|
| |
+ def test_extra_args_new_arguments(self):
|
| |
+ cli_cmd = ['rpkg', '--path', self.cloned_repo_path,
|
| |
+ '--release', 'rhel-6', 'mockbuild',
|
| |
+ '--root', '/etc/mock/some-root',
|
| |
+ '--', '--nocheck', '--arch=amd64', '-q']
|
| |
+ cli = self.mockbuild(cli_cmd)
|
| |
+
|
| |
+ expected_cmd = ['mock', '--nocheck', '--arch=amd64', '-q',
|
| |
+ '-r', '/etc/mock/some-root',
|
| |
+ '--resultdir', cli.cmd.mock_results_dir, '--rebuild',
|
| |
+ cli.cmd.srpmname]
|
| |
+ self.mock_run_command.assert_called_with(expected_cmd)
|
| |
+
|
| |
|
| |
class TestCoprBuild(CliTestCase):
|
| |
"""Test copr command"""
|
| |
There are two groups of arguments:
* standard arguments defined by individual parsers
* extra arguments that are allowed for some (individually allowed)
commands. They are passed to underlying command (usually appended
to the rest of arguments on commandline)
This commit adds a common way that allow user to use extra arguments
for some commands. Commands include mockbuild, srpm, clone.
JIRA: RHELCMP-101
JIRA: RHELCMP-141
Fixes: #432
Fixes: #413
Signed-off-by: Ondrej Nosek onosek@redhat.com