Last active
December 26, 2024 15:35
-
-
Save miketheman/178429ea5ae4f7ff2b360ac85cd9e1f2 to your computer and use it in GitHub Desktop.
warehouse tests with coverage.py https://hachyderm.io/@coveragepy/113708693164348781
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Checkout warehouse at the current `HEAD` for reproducability | |
git checkout aa5b2ec11745299dacd60cb7f73a066723372a9e | |
# Need to apply some changes to the core to allow un-hashed (unreleased) versions, and building from GitHub source. | |
# Snag the diff file and apply it | |
curl https://gist.githubusercontent.com/miketheman/178429ea5ae4f7ff2b360ac85cd9e1f2/raw/05c7a98464b41e224bf27f85f9a8b903669e6fb7/test-coverage.diff -o tes | |
t-coverage.diff | |
patch < test-coverage.diff | |
# Build all dependencies to bypass hash checking | |
make -B deps | |
# Run tests, reports coverage at the end. Uses `sysmon` | |
make tests | |
# Run again, use `ctrace` | |
make tests COVERAGE_CORE=ctrace | |
# Clean up | |
rm test-coverage.diff | |
git restore Dockerfile Makefile requirements/* | |
make tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- sys ------------------------------------------------------- | |
coverage_version: 7.6.10a0.dev1 | |
coverage_module: /opt/warehouse/lib/python3.12/site-packages/coverage/__init__.py | |
core: -none- | |
CTracer: available | |
plugins.file_tracers: -none- | |
plugins.configurers: -none- | |
plugins.context_switchers: -none- | |
configs_attempted: /opt/warehouse/src/.coveragerc | |
/opt/warehouse/src/setup.cfg | |
/opt/warehouse/src/tox.ini | |
/opt/warehouse/src/pyproject.toml | |
configs_read: /opt/warehouse/src/setup.cfg | |
/opt/warehouse/src/pyproject.toml | |
config_file: /opt/warehouse/src/pyproject.toml | |
config_contents: b'[tool.coverage.run]\nbranch = true\ndynamic_context = "test_function"\nsource = ["warehouse"]\nomit = [\n # We don\'t want to get coverage information for our migrations.\n "warehouse/migrations/*",\n\n # We don\'t want to actually cover our __main__.py file because it is hard\n # to cover and it really just acts as a tiny shim to a function.\n "warehouse/__main__.py",\n\n # Again, tiny shim code that we don\'t actually need to test and trying to\n # do so would just get in the way.\n "warehouse/wsgi.py",\n\n # And again, tiny shim code.\n "warehouse/celery.py",\n]\n# We run multiple processes in parallel, so we need to make sure that we don\'t\n# write to the same file at the same time.\nparallel = true\n\n[tool.coverage.report]\nexclude_lines = [\n "pragma: no cover",\n "class \\\\w+\\\\(Interface\\\\):",\n "if (typing\\\\.)?TYPE_CHECKING:",\n]\n\n[tool.curlylint]\ninclude = \'\\.(html|jinja|txt)$\'\n# For jinja\'s i18n extension:\ntemplate_tags = [[\'trans\', \'pluralize\', \'endtrans\']]\n\n[tool.isort]\nprofile = \'black\'\nlines_between_types = 1\ncombine_as_imports = true\nknown_first_party = [\'warehouse\', \'tests\']\n\n[tool.mypy]\npython_version = "3.12"\nwarn_unused_configs = true\nwarn_unused_ignores = true\nplugins = ["mypy_zope:plugin"]\nexclude = ["warehouse/locale/.*", "warehouse/migrations/versions.*"]\ncache_dir = "dev/.mypy_cache"\n\n[[tool.mypy.overrides]]\n# These modules do not yet have types available.\nmodule = [\n "bpython.*", # https://github.com/bpython/bpython/issues/892\n "b2sdk.*", # https://github.com/Backblaze/b2-sdk-python/issues/148\n "celery.app.backends.*",\n "celery.backends.redis.*",\n "github_reserved_names.*", # https://github.com/Julian/github-reserved-names/pull/10\n "google.cloud.*",\n "forcediphttpsadapter.*",\n "IPython.*", # has types, but only installed in dev\n "packaging_legacy.*", # https://github.com/di/packaging_legacy/pull/5\n "paginate.*",\n "paginate_sqlalchemy.*",\n "premailer.*",\n "pymacaroons.*", # https://github.com/ecordell/pymacaroons/issues/41\n "pyramid.*", # https://github.com/Pylons/pyramid/issues/2638\n "pyramid_jinja2.*",\n "pyramid_mailer.*",\n "pyramid_retry.*",\n "pyramid_rpc.*",\n "pyqrcode.*",\n "requests_aws4auth.*", # https://github.com/tedder/requests-aws4auth/issues/53\n "rfc3986.*", # https://github.com/python-hyper/rfc3986/issues/122\n "transaction.*",\n "ua_parser.*", # https://github.com/ua-parser/uap-python/issues/110\n "venusian.*",\n "whitenoise.*", # https://github.com/evansd/whitenoise/pull/410\n "zope.sqlalchemy.*",\n]\nignore_missing_imports = true\n\n[tool.pytest.ini_options]\naddopts = [\n "--disable-socket",\n "--allow-hosts=localhost,::1,stripe",\n "--durations=20",\n "--numprocesses=auto",\n # Disable ddtrace for tests\n "-p no:ddtrace",\n "-p no:ddtrace.pytest_bdd",\n "-p no:ddtrace.pytest_benchmark",\n]\ncache_dir = "dev/.pytest_cache"\ntestpaths = ["tests/"]\nmarkers = [\n \'unit: Quick running unit tests which test small units of functionality.\',\n \'functional: Slower running tests which test the entire system is functioning.\',\n]\nfilterwarnings = [\n \'ignore::warehouse.utils.exceptions.DevelopmentModeWarning\',\n \'error:SELECT statement has a cartesian product:sqlalchemy.exc.SAWarning\',\n]\n\n[tool.pip-tools.compile]\n# TODO: This can be removed once it becomes the default.\n# See: https://github.com/jazzband/pip-tools/issues/989\nallow-unsafe = true\n' | |
data_file: -none- | |
python: 3.12.7 (main, Dec 3 2024, 09:02:00) [GCC 12.2.0] | |
platform: Linux-6.12.5-orbstack-00287-gf8da5d508983-aarch64-with-glibc2.36 | |
implementation: CPython | |
gil_enabled: True | |
executable: /opt/warehouse/bin/python3 | |
def_encoding: utf-8 | |
fs_encoding: utf-8 | |
pid: 1 | |
cwd: /opt/warehouse/src | |
path: /opt/warehouse/bin | |
/opt/warehouse/src | |
/usr/local/lib/python312.zip | |
/usr/local/lib/python3.12 | |
/usr/local/lib/python3.12/lib-dynload | |
/opt/warehouse/lib/python3.12/site-packages | |
environment: HOME = /root | |
PYTHONPATH = /opt/warehouse/src/ | |
PYTHONUNBUFFERED = 1 | |
PYTHON_SHA256 = 24887b92e2afd4a2ac602419ad4b596372f67ac9b077190f459aba390faf5550 | |
PYTHON_VERSION = 3.12.7 | |
command_line: /opt/warehouse/bin/coverage debug sys | |
sqlite3_sqlite_version: 3.40.1 | |
sqlite3_temp_store: 0 | |
sqlite3_compile_options: ATOMIC_INTRINSICS=1, COMPILER=gcc-12.2.0, DEFAULT_AUTOVACUUM, | |
DEFAULT_CACHE_SIZE=-2000, DEFAULT_FILE_FORMAT=4, | |
DEFAULT_JOURNAL_SIZE_LIMIT=-1, DEFAULT_MMAP_SIZE=0, DEFAULT_PAGE_SIZE=4096, | |
DEFAULT_PCACHE_INITSZ=20, DEFAULT_RECURSIVE_TRIGGERS, | |
DEFAULT_SECTOR_SIZE=4096, DEFAULT_SYNCHRONOUS=2, | |
DEFAULT_WAL_AUTOCHECKPOINT=1000, DEFAULT_WAL_SYNCHRONOUS=2, | |
DEFAULT_WORKER_THREADS=0, ENABLE_COLUMN_METADATA, ENABLE_DBSTAT_VTAB, | |
ENABLE_FTS3, ENABLE_FTS3_PARENTHESIS, ENABLE_FTS3_TOKENIZER, ENABLE_FTS4, | |
ENABLE_FTS5, ENABLE_LOAD_EXTENSION, ENABLE_MATH_FUNCTIONS, | |
ENABLE_PREUPDATE_HOOK, ENABLE_RTREE, ENABLE_SESSION, ENABLE_STMTVTAB, | |
ENABLE_UNLOCK_NOTIFY, ENABLE_UPDATE_DELETE_LIMIT, HAVE_ISNAN, | |
LIKE_DOESNT_MATCH_BLOBS, MALLOC_SOFT_LIMIT=1024, MAX_ATTACHED=10, | |
MAX_COLUMN=2000, MAX_COMPOUND_SELECT=500, MAX_DEFAULT_PAGE_SIZE=32768, | |
MAX_EXPR_DEPTH=1000, MAX_FUNCTION_ARG=127, MAX_LENGTH=1000000000, | |
MAX_LIKE_PATTERN_LENGTH=50000, MAX_MMAP_SIZE=0x7fff0000, | |
MAX_PAGE_COUNT=1073741823, MAX_PAGE_SIZE=65536, MAX_SCHEMA_RETRY=25, | |
MAX_SQL_LENGTH=1000000000, MAX_TRIGGER_DEPTH=1000, | |
MAX_VARIABLE_NUMBER=250000, MAX_VDBE_OP=250000000, MAX_WORKER_THREADS=8, | |
MUTEX_PTHREADS, OMIT_LOOKASIDE, SECURE_DELETE, SOUNDEX, SYSTEM_MALLOC, | |
TEMP_STORE=1, THREADSAFE=1, USE_URI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Dockerfile b/Dockerfile | |
index 2bdb3e7a3..17f0da7fb 100644 | |
--- a/Dockerfile | |
+++ b/Dockerfile | |
@@ -136,7 +136,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | |
&& apt-get update \ | |
&& apt-get install --no-install-recommends -y \ | |
build-essential libffi-dev libxml2-dev libxslt-dev libpq-dev libcurl4-openssl-dev libssl-dev \ | |
- $(if [ "$DEVEL" = "yes" ]; then echo 'libjpeg-dev'; fi) | |
+ $(if [ "$DEVEL" = "yes" ]; then echo 'git libjpeg-dev'; fi) | |
# We create an /opt directory with a virtual environment in it to store our | |
# application in. | |
@@ -221,7 +221,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | |
&& apt-get update \ | |
&& apt-get install --no-install-recommends -y \ | |
libpq5 libxml2 libxslt1.1 libcurl4 \ | |
- $(if [ "$DEVEL" = "yes" ]; then echo 'bash libjpeg62 postgresql-client build-essential libffi-dev libxml2-dev libxslt-dev libpq-dev libcurl4-openssl-dev libssl-dev vim oathtool'; fi) \ | |
+ $(if [ "$DEVEL" = "yes" ]; then echo 'bash libjpeg62 postgresql-client build-essential git libffi-dev libxml2-dev libxslt-dev libpq-dev libcurl4-openssl-dev libssl-dev vim oathtool'; fi) \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
diff --git a/Makefile b/Makefile | |
index a592a3fb4..951ec85a7 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -118,7 +118,7 @@ translations: .state/docker-build-base | |
docker compose run --rm base bin/translations | |
requirements/%.txt: requirements/%.in | |
- docker compose run --rm base bin/pip-compile --generate-hashes --output-file=$@ $< | |
+ docker compose run --rm base bin/pip-compile --output-file=$@ $< | |
resetdb: .state/docker-build-base | |
docker compose pause web worker | |
diff --git a/requirements/tests.in b/requirements/tests.in | |
index 2022fe164..70100d5b9 100644 | |
--- a/requirements/tests.in | |
+++ b/requirements/tests.in | |
@@ -1,4 +1,4 @@ | |
-coverage | |
+coverage @ git+https://github.com/nedbat/coveragepy@67f1440e0a384000e337 | |
factory_boy | |
freezegun | |
pretend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment