From: Hood Chatham Date: Sun, 17 Aug 2025 23:57:15 +0000 (+0200) Subject: gh-127146: Emscripten: Add test_sample_profiler skips where needed (#137815) X-Git-Tag: v3.15.0a1~663 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc2872445b2aee4bb4e001d4171489d7123b1daf;p=thirdparty%2FPython%2Fcpython.git gh-127146: Emscripten: Add test_sample_profiler skips where needed (#137815) Emscripten doesn't have the `socket.SO_REUSEADDR` constant; skip tests that require that symbol to exist. --- diff --git a/Lib/test/test_sample_profiler.py b/Lib/test/test_sample_profiler.py index f234af60c8ab..6446247cb5ce 100644 --- a/Lib/test/test_sample_profiler.py +++ b/Lib/test/test_sample_profiler.py @@ -20,7 +20,7 @@ from profile.stack_collector import ( from test.support.os_helper import unlink from test.support import force_not_colorized_test_class, SHORT_TIMEOUT from test.support.socket_helper import find_unused_port -from test.support import requires_subprocess +from test.support import requires_subprocess, is_emscripten PROCESS_VM_READV_SUPPORTED = False @@ -1792,6 +1792,7 @@ class TestSampleProfilerCLI(unittest.TestCase): # cwd is coordinator_cmd[4] self.assertEqual(coordinator_cmd[5:], expected_target_args) + @unittest.skipIf(is_emscripten, "socket.SO_REUSEADDR does not exist") def test_cli_module_argument_parsing(self): test_args = ["profile.sample", "-m", "mymodule"] @@ -1818,6 +1819,7 @@ class TestSampleProfilerCLI(unittest.TestCase): realtime_stats=False, ) + @unittest.skipIf(is_emscripten, "socket.SO_REUSEADDR does not exist") def test_cli_module_with_arguments(self): test_args = ["profile.sample", "-m", "mymodule", "arg1", "arg2", "--flag"] @@ -1844,6 +1846,7 @@ class TestSampleProfilerCLI(unittest.TestCase): realtime_stats=False, ) + @unittest.skipIf(is_emscripten, "socket.SO_REUSEADDR does not exist") def test_cli_script_argument_parsing(self): test_args = ["profile.sample", "myscript.py"] @@ -1870,6 +1873,7 @@ class TestSampleProfilerCLI(unittest.TestCase): realtime_stats=False, ) + @unittest.skipIf(is_emscripten, "socket.SO_REUSEADDR does not exist") def test_cli_script_with_arguments(self): test_args = ["profile.sample", "myscript.py", "arg1", "arg2", "--flag"] @@ -1938,6 +1942,7 @@ class TestSampleProfilerCLI(unittest.TestCase): error_msg = mock_stderr.getvalue() self.assertIn("one of the arguments", error_msg) + @unittest.skipIf(is_emscripten, "socket.SO_REUSEADDR does not exist") def test_cli_module_with_profiler_options(self): test_args = [ "profile.sample", "-i", "1000", "-d", "30", "-a", @@ -1967,6 +1972,7 @@ class TestSampleProfilerCLI(unittest.TestCase): realtime_stats=False, ) + @unittest.skipIf(is_emscripten, "socket.SO_REUSEADDR does not exist") def test_cli_script_with_profiler_options(self): """Test script with various profiler options.""" test_args = [ @@ -2013,6 +2019,7 @@ class TestSampleProfilerCLI(unittest.TestCase): error_msg = mock_stderr.getvalue() self.assertIn("argument -m/--module: expected one argument", error_msg) + @unittest.skipIf(is_emscripten, "socket.SO_REUSEADDR does not exist") def test_cli_long_module_option(self): test_args = ["profile.sample", "--module", "mymodule", "arg1"]