Skip to content

Commit b51d785

Browse files
committed
debug: split 'sqlite' into its own category
1 parent 1a143f3 commit b51d785

File tree

8 files changed

+43
-15
lines changed

8 files changed

+43
-15
lines changed

.github/workflows/python-nightly.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ jobs:
9090
python -m sysconfig
9191
python -c "import sys; print('GIL:', getattr(sys, '_is_gil_enabled', lambda: True)())"
9292
python -m coverage debug sys
93+
python -m coverage debug sqlite
9394
python -m coverage debug pybehave
9495
env | sort
9596

CHANGES.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ upgrading your version of coverage.py.
2323
Unreleased
2424
----------
2525

26-
Nothing yet.
26+
- Split ``sqlite`` debugging information out of the ``sys`` :ref:`coverage
27+
debug <cmd_debug>` and :ref:`cmd_run_debug` options since it's bulky and not
28+
very useful.
2729

2830

2931
.. start-releases

coverage/cmdline.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from coverage.config import CoverageConfig
2323
from coverage.control import DEFAULT_DATAFILE
2424
from coverage.core import CTRACER_FILE
25-
from coverage.data import combinable_files, debug_data_file
25+
from coverage.data import CoverageData, combinable_files, debug_data_file
2626
from coverage.debug import info_header, short_stack, write_formatted_info
2727
from coverage.exceptions import NoSource, CoverageException, _ExceptionDuringRun
2828
from coverage.execfile import PyRunner
@@ -561,7 +561,8 @@ def get_prog_name(self) -> str:
561561
'sys' to show installation information;
562562
'config' to show the configuration;
563563
'premain' to show what is calling coverage;
564-
'pybehave' to show internal flags describing Python behavior.
564+
'pybehave' to show internal flags describing Python behavior;
565+
'sqlite' to show SQLite compilation options.
565566
"""
566567
),
567568
),
@@ -1035,7 +1036,10 @@ def do_debug(self, args: list[str]) -> int:
10351036
"""Implementation of 'coverage debug'."""
10361037

10371038
if not args:
1038-
show_help("What information would you like: config, data, sys, premain, pybehave?")
1039+
show_help(
1040+
"What information would you like: "
1041+
+ "config, data, sys, premain, pybehave, sqlite?"
1042+
)
10391043
return ERR
10401044
if args[1:]:
10411045
show_help("Only one topic at a time, please")
@@ -1057,6 +1061,8 @@ def do_debug(self, args: list[str]) -> int:
10571061
print(short_stack(full=True))
10581062
elif args[0] == "pybehave":
10591063
write_formatted_info(print, "pybehave", env.debug_info())
1064+
elif args[0] == "sqlite":
1065+
write_formatted_info(print, "sqlite", CoverageData.sys_info())
10601066
else:
10611067
show_help(f"Don't know what you mean by {args[0]!r}")
10621068
return ERR

coverage/control.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,22 +414,24 @@ def _write_startup_debug(self) -> None:
414414
wrote_any = False
415415
with self._debug.without_callers():
416416
if self._debug.should("config"):
417-
config_info = self.config.debug_info()
418-
write_formatted_info(self._debug.write, "config", config_info)
417+
write_formatted_info(self._debug.write, "config", self.config.debug_info())
419418
wrote_any = True
420419

421420
if self._debug.should("sys"):
422421
write_formatted_info(self._debug.write, "sys", self.sys_info())
423422
for plugin in self._plugins:
424423
header = "sys: " + plugin._coverage_plugin_name
425-
info = plugin.sys_info()
426-
write_formatted_info(self._debug.write, header, info)
424+
write_formatted_info(self._debug.write, header, plugin.sys_info())
427425
wrote_any = True
428426

429427
if self._debug.should("pybehave"):
430428
write_formatted_info(self._debug.write, "pybehave", env.debug_info())
431429
wrote_any = True
432430

431+
if self._debug.should("sqlite"):
432+
write_formatted_info(self._debug.write, "sqlite", CoverageData.sys_info())
433+
wrote_any = True
434+
433435
if wrote_any:
434436
write_formatted_info(self._debug.write, "end", ())
435437

@@ -1399,8 +1401,6 @@ def plugin_info(plugins: list[Any]) -> list[str]:
13991401
if self._inorout is not None:
14001402
info.extend(self._inorout.sys_info())
14011403

1402-
info.extend(CoverageData.sys_info())
1403-
14041404
return info
14051405

14061406

doc/commands/cmd_debug.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ A few types of information are available:
2929
* ``data``: show a summary of the collected coverage data
3030
* ``premain``: show the call stack invoking coverage
3131
* ``pybehave``: show internal flags describing Python behavior
32+
* ``sqlite``: show internal compilation options for SQLite
3233

3334
.. [[[cog show_help("debug") ]]]
3435
.. code::
@@ -40,15 +41,15 @@ A few types of information are available:
4041
problems. Topics are: 'data' to show a summary of the collected data; 'sys' to
4142
show installation information; 'config' to show the configuration; 'premain'
4243
to show what is calling coverage; 'pybehave' to show internal flags describing
43-
Python behavior.
44+
Python behavior; 'sqlite' to show SQLite compilation options.
4445
4546
Options:
4647
--debug=OPTS Debug options, separated by commas. [env: COVERAGE_DEBUG]
4748
-h, --help Get help on this command.
4849
--rcfile=RCFILE Specify configuration file. By default '.coveragerc',
4950
'setup.cfg', 'tox.ini', and 'pyproject.toml' are tried.
5051
[env: COVERAGE_RCFILE]
51-
.. [[[end]]] (sum: ybjftkTaNE)
52+
.. [[[end]]] (sum: noWWXgVKcd)
5253
5354
5455
.. _cmd_run_debug:

doc/python-coverage.1.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ COMMAND REFERENCE
154154
``sys`` to show installation information;
155155
``config`` to show the configuration;
156156
``premain`` to show what is calling coverage;
157-
``pybehave`` to show internal flags describing Python behavior.
157+
``pybehave`` to show internal flags describing Python behavior;
158+
``sqlite`` to show SQLite compilation options.
158159

159160

160161
**erase**

tests/test_cmdline.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
from tests import testenv
3131
from tests.coveragetest import CoverageTest, OK, ERR, command_line
32-
from tests.helpers import os_sep, re_line
32+
from tests.helpers import os_sep, re_line, re_lines
3333

3434

3535
class BaseCmdLineTest(CoverageTest):
@@ -389,7 +389,10 @@ def test_combine_doesnt_confuse_options_with_args(self) -> None:
389389
@pytest.mark.parametrize(
390390
"cmd, output",
391391
[
392-
("debug", "What information would you like: config, data, sys, premain, pybehave?"),
392+
(
393+
"debug",
394+
"What information would you like: config, data, sys, premain, pybehave, sqlite?",
395+
),
393396
("debug foo", "Don't know what you mean by 'foo'"),
394397
("debug sys config", "Only one topic at a time, please"),
395398
],
@@ -449,6 +452,15 @@ def test_debug_premain(self) -> None:
449452
assert re.search(rf"(?m)^\s+do_debug : .*{s}coverage{s}cmdline.py:\d+$", out)
450453
assert "do_debug : " in lines[-1]
451454

455+
def test_debug_sqlite(self) -> None:
456+
self.command_line("debug sqlite")
457+
out = self.stdout()
458+
assert "sqlite3_sqlite_version:" in out
459+
assert "sqlite3_compile_options:" in out
460+
assert len(out.splitlines()) > 15
461+
# Lots of lines of indented SQLite compile-time options.
462+
assert len(re_lines(r"^ {20,35}[A-Z]{3}", out)) > 12
463+
452464
def test_erase(self) -> None:
453465
# coverage erase
454466
self.cmd_executes(

tests/test_debug.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ def test_debug_pybehave(self) -> None:
244244
vtuple = ast.literal_eval(pyversion.partition(":")[-1].strip())
245245
assert vtuple[:5] == sys.version_info
246246

247+
def test_debug_sqlite(self) -> None:
248+
out_text = self.f1_debug_output(["sqlite"])
249+
assert "sqlite3_compile_options:" in out_text
250+
# The rest of the output is tested in test_cmdline.py:test_debug_sqlite
251+
247252
def test_debug_process(self) -> None:
248253
out_text = self.f1_debug_output(["trace", "process"])
249254
assert f"New process: pid={os.getpid()}, executable:" in out_text

0 commit comments

Comments
 (0)