| |
@@ -499,8 +499,14 @@
|
| |
)
|
| |
self.patch_config_broker.start()
|
| |
|
| |
+ self.patch_execute_cmd = patch(
|
| |
+ "module_build_service.builder.KojiModuleBuilder.execute_cmd",
|
| |
+ side_effect=self.execute_cmd)
|
| |
+ self.patch_execute_cmd.start()
|
| |
+
|
| |
def teardown_method(self, test_method):
|
| |
self.patch_config_broker.stop()
|
| |
+ self.patch_execute_cmd.stop()
|
| |
FakeModuleBuilder.reset()
|
| |
cleanup_moksha()
|
| |
for i in range(20):
|
| |
@@ -509,6 +515,30 @@
|
| |
except Exception:
|
| |
pass
|
| |
|
| |
+ def execute_cmd(self, args, **kwargs):
|
| |
+ pattern = [
|
| |
+ r"rpmbuild$",
|
| |
+ r"-bs$",
|
| |
+ r"(.*).spec$",
|
| |
+ r"--define$",
|
| |
+ r"_topdir (.*)$",
|
| |
+ r"--define$",
|
| |
+ r"_sourcedir (.*)$",
|
| |
+ ]
|
| |
+ assert len(args) == len(pattern)
|
| |
+ matches = [re.match(pattern[i], arg) for i, arg in enumerate(args)]
|
| |
+ assert all(matches)
|
| |
+
|
| |
+ name = matches[2].group(1)
|
| |
+ topdir = matches[4].group(1)
|
| |
+ srpmdir = os.path.join(topdir, "SRPMS")
|
| |
+ if not os.path.exists(srpmdir):
|
| |
+ os.makedirs(srpmdir)
|
| |
+ with open(os.path.join(srpmdir, name + "-1-1.src.rpm"), "w"):
|
| |
+ pass
|
| |
+
|
| |
+ return ("", "")
|
| |
+
|
| |
@pytest.mark.parametrize("mmd_version", [1, 2])
|
| |
@patch("module_build_service.web.auth.get_user", return_value=user)
|
| |
@patch("module_build_service.common.scm.SCM")
|
| |
On my system this improves the time to run test_build.py from 26 seconds
to 10 seconds - and the overall test run from about 56 seconds to 40
seconds - a 29% improvement.