From 976c9c0db46dc6b60e5dd4370d32d8a14a18756d Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 20 May 2026 11:30:54 +0200 Subject: [PATCH] ensure httpd is shut down when test_mirroring_a_repo fails Otherwise, this will fail and then hang forever. THis just puts everything that could cause the hang in try/finally. --- tests/test_integration.py | 47 +++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/tests/test_integration.py b/tests/test_integration.py index 9f4cddcc..0dd3008a 100755 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -1441,28 +1441,31 @@ class IntegrationTest(unittest.TestCase): httpd = ThreadingHTTPServer(("127.0.0.1", 0), RequestHandler) threading.Thread(target=httpd.serve_forever).start() - os.chdir(self.tmp_repo_root) - host, port = httpd.socket.getsockname() - url, output_dir = f"http://{host}:{port}/", Path(f"{host}:{port}") - self.assert_run(self.fdroid_cmd + ["mirror", url]) - self.assertTrue((output_dir / "repo/souch.smsbypass_9.apk").is_file()) - self.assertTrue((output_dir / "repo/icons-640/souch.smsbypass.9.png").is_file()) - # the index shouldn't be saved unless it was verified - self.assertFalse((output_dir / "repo/index-v1.jar").exists()) - self.assert_run_fail( - self.fdroid_cmd + ["mirror", f"{url}?fingerprint=asdfasdf"] - ) - self.assertFalse((output_dir / "repo/index-v1.jar").exists()) - self.assert_run( - self.fdroid_cmd - + [ - "mirror", - f"{url}?fingerprint=F49AF3F11EFDDF20DFFD70F5E3117B9976674167ADCA280E6B1932A0601B26F6", - ], - ) - self.assertTrue((output_dir / "repo/index-v1.jar").is_file()) - - httpd.shutdown() + try: + os.chdir(self.tmp_repo_root) + host, port = httpd.socket.getsockname() + url, output_dir = f"http://{host}:{port}/", Path(f"{host}:{port}") + self.assert_run(self.fdroid_cmd + ["mirror", url]) + self.assertTrue((output_dir / "repo/souch.smsbypass_9.apk").is_file()) + self.assertTrue( + (output_dir / "repo/icons-640/souch.smsbypass.9.png").is_file() + ) + # the index shouldn't be saved unless it was verified + self.assertFalse((output_dir / "repo/index-v1.jar").exists()) + self.assert_run_fail( + self.fdroid_cmd + ["mirror", f"{url}?fingerprint=asdfasdf"] + ) + self.assertFalse((output_dir / "repo/index-v1.jar").exists()) + self.assert_run( + self.fdroid_cmd + + [ + "mirror", + f"{url}?fingerprint=F49AF3F11EFDDF20DFFD70F5E3117B9976674167ADCA280E6B1932A0601B26F6", + ], + ) + self.assertTrue((output_dir / "repo/index-v1.jar").is_file()) + finally: + httpd.shutdown() def test_recovering_from_broken_git_submodules(self): Path("foo").mkdir()