From ba546809443e10530b822aa99351dd680bce27e9 Mon Sep 17 00:00:00 2001 From: A5rocks Date: Thu, 7 Aug 2025 16:20:08 +0900 Subject: [PATCH 01/11] Re-add `tests/` directory --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bec87cfef..6fd75345c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -311,7 +311,7 @@ omit = [ parallel = true plugins = [] relative_files = true -source = ["trio"] +source = ["trio", "tests/"] [tool.coverage.report] precision = 1 From 39366d40bf95b9865ba19ab098e13072fecad427 Mon Sep 17 00:00:00 2001 From: A5rocks Date: Thu, 7 Aug 2025 23:02:05 +0900 Subject: [PATCH 02/11] Debug: disable coverage thing --- src/trio/_core/_tests/test_thread_cache.py | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/trio/_core/_tests/test_thread_cache.py b/src/trio/_core/_tests/test_thread_cache.py index a308befb6..c83ef7bb6 100644 --- a/src/trio/_core/_tests/test_thread_cache.py +++ b/src/trio/_core/_tests/test_thread_cache.py @@ -198,7 +198,7 @@ def deliver(_: object) -> NoReturn: assert "delivering result" in err -@pytest.mark.skipif(not hasattr(os, "fork"), reason="os.fork isn't supported") +@pytest.mark.skipif(True, reason="os.fork isn't supported") def test_clear_thread_cache_after_fork() -> None: assert hasattr(os, "fork") @@ -224,19 +224,19 @@ def foo() -> None: # this is necessary because os._exit doesn't unwind the stack, # so coverage doesn't get to automatically stop and save # coverage information. - try: - import coverage - - cov = coverage.Coverage.current() - # the following pragmas are necessary because if coverage: - # - isn't running, then it can't record the branch not - # taken - # - isn't installed, then it can't record the ImportError - - if cov: # pragma: no branch - cov.stop() - cov.save() - except ImportError: # pragma: no cover - pass + # try: + # import coverage + + # cov = coverage.Coverage.current() + # # the following pragmas are necessary because if coverage: + # # - isn't running, then it can't record the branch not + # # taken + # # - isn't installed, then it can't record the ImportError + + # if cov: # pragma: no branch + # cov.stop() + # cov.save() + # except ImportError: # pragma: no cover + # pass os._exit(0) # pragma: no cover # coverage was stopped above. From a9a2e5fb720b3833f44aa7bd143eb5dfd2b6fb58 Mon Sep 17 00:00:00 2001 From: A5rocks Date: Thu, 7 Aug 2025 23:22:02 +0900 Subject: [PATCH 03/11] Debug: specifically skip coverage for failing test --- pyproject.toml | 2 ++ src/trio/_core/_tests/test_thread_cache.py | 27 +++++----------------- src/trio/_core/_thread_cache.py | 2 +- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6fd75345c..dd5a90690 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -305,6 +305,8 @@ omit = [ "*/trio/_tests/check_type_completeness.py", # Script to generate a CFFI interface for the Windows kernel "*/trio/_tools/windows_ffi_build.py", + # pytest plugin (I'm not sure why this doesn't work) + "tests/_trio_check_attrs_aliases.py", ] # The test suite spawns subprocesses to test some stuff, so make sure # this doesn't corrupt the coverage files diff --git a/src/trio/_core/_tests/test_thread_cache.py b/src/trio/_core/_tests/test_thread_cache.py index c83ef7bb6..ad878294d 100644 --- a/src/trio/_core/_tests/test_thread_cache.py +++ b/src/trio/_core/_tests/test_thread_cache.py @@ -198,7 +198,7 @@ def deliver(_: object) -> NoReturn: assert "delivering result" in err -@pytest.mark.skipif(True, reason="os.fork isn't supported") +@pytest.mark.skipif(not hasattr(os, "fork"), reason="os.fork isn't supported") def test_clear_thread_cache_after_fork() -> None: assert hasattr(os, "fork") @@ -220,23 +220,8 @@ def foo() -> None: if child_pid != 0: # if this test fails, this will hang, triggering a timeout. os.waitpid(child_pid, 0) - else: - # this is necessary because os._exit doesn't unwind the stack, - # so coverage doesn't get to automatically stop and save - # coverage information. - # try: - # import coverage - - # cov = coverage.Coverage.current() - # # the following pragmas are necessary because if coverage: - # # - isn't running, then it can't record the branch not - # # taken - # # - isn't installed, then it can't record the ImportError - - # if cov: # pragma: no branch - # cov.stop() - # cov.save() - # except ImportError: # pragma: no cover - # pass - - os._exit(0) # pragma: no cover # coverage was stopped above. + else: # pragma: no cover # coverage is shut down by os._exit(0) + # we would *want* to allow coverage to take a snapshot here. check + # git glame for how to do that. however, that times out for some + # reason when having `tests/` in `source` for coverage.py. + os._exit(0) diff --git a/src/trio/_core/_thread_cache.py b/src/trio/_core/_thread_cache.py index 44820e771..5c86ba344 100644 --- a/src/trio/_core/_thread_cache.py +++ b/src/trio/_core/_thread_cache.py @@ -303,7 +303,7 @@ def start_thread_soon( THREAD_CACHE.start_thread_soon(fn, deliver, name) -def clear_worker_threads() -> None: +def clear_worker_threads() -> None: # pragma: no cover # see test_clear_thread_cache_after_fork # This is OK because the child process does not actually have any # worker threads. Additionally, while WorkerThread keeps a strong # reference and so would get affected, the only place those are From b871153bb664cad101d03fdd802ab08bbdc655f7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 7 Aug 2025 14:22:15 +0000 Subject: [PATCH 04/11] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/trio/_core/_thread_cache.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/trio/_core/_thread_cache.py b/src/trio/_core/_thread_cache.py index 5c86ba344..c2b2315bd 100644 --- a/src/trio/_core/_thread_cache.py +++ b/src/trio/_core/_thread_cache.py @@ -303,7 +303,9 @@ def start_thread_soon( THREAD_CACHE.start_thread_soon(fn, deliver, name) -def clear_worker_threads() -> None: # pragma: no cover # see test_clear_thread_cache_after_fork +def clear_worker_threads() -> ( + None +): # pragma: no cover # see test_clear_thread_cache_after_fork # This is OK because the child process does not actually have any # worker threads. Additionally, while WorkerThread keeps a strong # reference and so would get affected, the only place those are From c819c431f72e389e960d99e070310d60c30fc04c Mon Sep 17 00:00:00 2001 From: A5rocks Date: Fri, 22 Aug 2025 07:50:10 +0900 Subject: [PATCH 05/11] Start debugging pytest plugin --- pyproject.toml | 2 -- src/trio/_core/_tests/test_thread_cache.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dd5a90690..6fd75345c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -305,8 +305,6 @@ omit = [ "*/trio/_tests/check_type_completeness.py", # Script to generate a CFFI interface for the Windows kernel "*/trio/_tools/windows_ffi_build.py", - # pytest plugin (I'm not sure why this doesn't work) - "tests/_trio_check_attrs_aliases.py", ] # The test suite spawns subprocesses to test some stuff, so make sure # this doesn't corrupt the coverage files diff --git a/src/trio/_core/_tests/test_thread_cache.py b/src/trio/_core/_tests/test_thread_cache.py index ad878294d..3abdd59e4 100644 --- a/src/trio/_core/_tests/test_thread_cache.py +++ b/src/trio/_core/_tests/test_thread_cache.py @@ -222,6 +222,6 @@ def foo() -> None: os.waitpid(child_pid, 0) else: # pragma: no cover # coverage is shut down by os._exit(0) # we would *want* to allow coverage to take a snapshot here. check - # git glame for how to do that. however, that times out for some + # git blame for how to do that. however, that times out for some # reason when having `tests/` in `source` for coverage.py. os._exit(0) From 345c66d3ed100970faf66297fbe5e1add6a0d08e Mon Sep 17 00:00:00 2001 From: A5rocks Date: Fri, 22 Aug 2025 07:54:00 +0900 Subject: [PATCH 06/11] Debug better --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6fd75345c..50e63f224 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -315,8 +315,8 @@ source = ["trio", "tests/"] [tool.coverage.report] precision = 1 -skip_covered = true -skip_empty = true +skip_covered = false +skip_empty = false show_missing = true exclude_also = [ '^\s*@pytest\.mark\.xfail', From e1895cbb2231ada2df8305dccb46cdf74a8726a1 Mon Sep 17 00:00:00 2001 From: A5rocks Date: Fri, 22 Aug 2025 07:59:02 +0900 Subject: [PATCH 07/11] Allow the `tests/` directory in relative directory --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 50e63f224..0ee645c39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -292,7 +292,7 @@ show_contexts = true skip_covered = false [tool.coverage.paths] -source = ["src", "**/site-packages"] +source = ["src", "**/site-packages", "."] [tool.coverage.run] branch = true From 37de3944e223a1f10f4a3d905f5defe1b326b084 Mon Sep 17 00:00:00 2001 From: A5rocks Date: Fri, 22 Aug 2025 08:03:38 +0900 Subject: [PATCH 08/11] Make coverage detect the pytest plugin --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0ee645c39..42784f71e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -311,7 +311,7 @@ omit = [ parallel = true plugins = [] relative_files = true -source = ["trio", "tests/"] +source = ["trio", "tests"] [tool.coverage.report] precision = 1 From b503adb3dd0abf0b87421baa554231da3f6b8df5 Mon Sep 17 00:00:00 2001 From: A5rocks Date: Fri, 22 Aug 2025 08:36:49 +0900 Subject: [PATCH 09/11] Try another change --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 42784f71e..fafafddd9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -292,7 +292,7 @@ show_contexts = true skip_covered = false [tool.coverage.paths] -source = ["src", "**/site-packages", "."] +source = ["src", "**/site-packages", "tests"] [tool.coverage.run] branch = true @@ -311,7 +311,7 @@ omit = [ parallel = true plugins = [] relative_files = true -source = ["trio", "tests"] +source = ["trio", "tests/", "_trio_check_attrs_aliases"] [tool.coverage.report] precision = 1 From ab647a096a1a5b991c8b70425f280f8087b00f80 Mon Sep 17 00:00:00 2001 From: A5rocks Date: Fri, 22 Aug 2025 10:04:25 +0900 Subject: [PATCH 10/11] Remove debugging aids --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fafafddd9..4976b1221 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -315,8 +315,8 @@ source = ["trio", "tests/", "_trio_check_attrs_aliases"] [tool.coverage.report] precision = 1 -skip_covered = false -skip_empty = false +skip_covered = true +skip_empty = true show_missing = true exclude_also = [ '^\s*@pytest\.mark\.xfail', From 1c0d7c3a3c75a14efc56240800d72361b63598ee Mon Sep 17 00:00:00 2001 From: A5rocks Date: Fri, 22 Aug 2025 23:37:11 +0900 Subject: [PATCH 11/11] Try removing tests from the source paths --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4976b1221..1478e556d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -292,7 +292,7 @@ show_contexts = true skip_covered = false [tool.coverage.paths] -source = ["src", "**/site-packages", "tests"] +source = ["src", "**/site-packages"] [tool.coverage.run] branch = true