diff -Nru libzstd-1.5.5+dfsg2/debian/changelog libzstd-1.5.5+dfsg2/debian/changelog --- libzstd-1.5.5+dfsg2/debian/changelog 2023-07-06 06:00:14.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/changelog 2023-09-17 13:48:35.000000000 +0000 @@ -1,9 +1,20 @@ -libzstd (1.5.5+dfsg2-1ubuntu11) mantic; urgency=medium +libzstd (1.5.5+dfsg2-2) unstable; urgency=medium - * Fix compiler failure with lto - * Fix i386 LP: #2011470 + * Clean up a directory of symlinks created by the test suite. + Closes: #1049066 + * Bump the CMake version requirement to 3.24. Closes: #1031384 + * Fix the nodoc build: do not tweak non-existent manpages. Closes: #1037088 + * Declare version 1 of the dpkg-build API: + - drop the implied Root-Requires-Root: true + - use dpkg's default.mk instead of including buildtools.mk directly + * Use the DEB_HOST_MULTIARCH variable provided by default.mk. + * Use dh-package-notes to record ELF package metadata. + * Update the bundled copy of the check-build Python library in + the autopkgtest tree: + - remove the non-runtime check-build files + - import check-build 0.1.0 - -- Gianfranco Costamagna Thu, 06 Jul 2023 08:00:14 +0200 + -- Peter Pentchev Sun, 17 Sep 2023 16:48:35 +0300 libzstd (1.5.5+dfsg2-1) unstable; urgency=medium diff -Nru libzstd-1.5.5+dfsg2/debian/clean libzstd-1.5.5+dfsg2/debian/clean --- libzstd-1.5.5+dfsg2/debian/clean 1970-01-01 00:00:00.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/clean 2023-09-10 20:21:27.000000000 +0000 @@ -0,0 +1 @@ +tests/cli-tests/bin/symlinks/ diff -Nru libzstd-1.5.5+dfsg2/debian/control libzstd-1.5.5+dfsg2/debian/control --- libzstd-1.5.5+dfsg2/debian/control 2023-07-06 06:00:14.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/control 2023-09-11 00:05:26.000000000 +0000 @@ -3,19 +3,20 @@ Uploaders: Peter Pentchev Section: libs Priority: optional -Build-Depends: cmake, +Build-Depends: cmake (>= 3.24~), debhelper (>> 13.3.2~), + dh-package-notes, + dpkg-build-api (= 1), help2man, liblz4-dev, liblzma-dev, zlib1g-dev, less , - python3:any , + python3 , Standards-Version: 4.6.2 Vcs-Browser: https://salsa.debian.org/pkg-rpm-team/libzstd Vcs-Git: https://salsa.debian.org/pkg-rpm-team/libzstd.git Homepage: https://github.com/facebook/zstd -Rules-Requires-Root: no Package: libzstd-dev Architecture: any diff -Nru libzstd-1.5.5+dfsg2/debian/patches/0023-cmake-min-3.13.patch libzstd-1.5.5+dfsg2/debian/patches/0023-cmake-min-3.13.patch --- libzstd-1.5.5+dfsg2/debian/patches/0023-cmake-min-3.13.patch 2023-06-22 21:34:21.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/patches/0023-cmake-min-3.13.patch 2023-09-10 23:21:10.000000000 +0000 @@ -1,9 +1,11 @@ -Description: Require CMake 3.13.4 in Debian - Bump the minimum required CMake version to the one in - Debian 10 (buster / oldoldstable). +Description: Require CMake 3.24 in Debian + Bump the minimum required CMake version to the one that puts + the generated files into a per-build directory as expected by + our debian/*.install files. +Bug-Debian: https://bugs.debian.org/1031384 Forwarded: not-needed Author: Peter Pentchev -Last-Update: 2023-06-23 +Last-Update: 2023-09-11 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -12,7 +14,7 @@ # ################################################################ -cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) -+cmake_minimum_required(VERSION 3.13.4 FATAL_ERROR) ++cmake_minimum_required(VERSION 3.24.0 FATAL_ERROR) # As of 2018-12-26 ZSTD has been validated to build with cmake version 3.13.2 new policies. # Set and use the newest cmake policies that are validated to work diff -Nru libzstd-1.5.5+dfsg2/debian/patches/fix-lto-failure.patch libzstd-1.5.5+dfsg2/debian/patches/fix-lto-failure.patch --- libzstd-1.5.5+dfsg2/debian/patches/fix-lto-failure.patch 2023-07-06 06:00:14.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/patches/fix-lto-failure.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ ---- libzstd-1.5.5+dfsg2.orig/programs/fileio.c -+++ libzstd-1.5.5+dfsg2/programs/fileio.c -@@ -2220,7 +2220,7 @@ static dRess_t FIO_createDResources(FIO_ - { - int useMMap = prefs->mmapDict == ZSTD_ps_enable; - int forceNoUseMMap = prefs->mmapDict == ZSTD_ps_disable; -- stat_t statbuf; -+ stat_t statbuf = {}; - dRess_t ress; - memset(&ress, 0, sizeof(ress)); - diff -Nru libzstd-1.5.5+dfsg2/debian/patches/series libzstd-1.5.5+dfsg2/debian/patches/series --- libzstd-1.5.5+dfsg2/debian/patches/series 2023-07-06 06:00:05.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/patches/series 2023-09-17 13:48:14.000000000 +0000 @@ -7,4 +7,3 @@ 0018-kfreebsd-ftbfs-utime-now.patch 0022-tests-timeout.patch 0023-cmake-min-3.13.patch -fix-lto-failure.patch diff -Nru libzstd-1.5.5+dfsg2/debian/rules libzstd-1.5.5+dfsg2/debian/rules --- libzstd-1.5.5+dfsg2/debian/rules 2023-06-22 21:46:07.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/rules 2023-09-11 00:05:47.000000000 +0000 @@ -2,11 +2,13 @@ # Export build tools for all targets to avoid build hash changes. DPKG_EXPORT_BUILDTOOLS=1 -include /usr/share/dpkg/buildtools.mk + +include /usr/share/dpkg/default.mk + +include /usr/share/debhelper/dh_package_notes/package-notes.mk export DH_VERBOSE=1 -arch ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) export DEB_BUILD_MAINT_OPTIONS=hardening=+all # Upstream's makefiles will respect PREFIX, and this means we avoid a patch @@ -16,7 +18,7 @@ mandir := $(CURDIR)/debian/zstd/usr/share/man/man1 DH_AUTO_CONFIGURE_OPTS := \ - -DCMAKE_LIBRARY_ARCHITECTURE=${arch} \ + -DCMAKE_LIBRARY_ARCHITECTURE=${DEB_HOST_MULTIARCH} \ -DZSTD_LEGACY_SUPPORT:BOOL=ON \ ifneq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) @@ -51,7 +53,7 @@ dh_auto_build -D contrib/pzstd override_dh_auto_install: - dh_auto_install -- libdir=/usr/lib/$(arch) + dh_auto_install -- libdir=/usr/lib/${DEB_HOST_MULTIARCH} dh_auto_install -D contrib/pzstd ifeq (,$(filter noudeb,$(DEB_BUILD_PROFILES))) @@ -62,10 +64,12 @@ override_dh_makeshlibs: dh_makeshlibs -plibzstd1 -V'libzstd1 (>= 1.5.5)' --add-udeb=libzstd1-udeb +ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS))) execute_after_dh_installman: cp $(mandir)/zstd.1 $(mandir)/zstdmt.1 $(HELP2MAN) --name='parallelized Zstandard compression, a la pigz' contrib/pzstd/pzstd \ | perl -pe 's/(\(de\)compression\s\(default:)(\d+)(\))/$$1 All$$3/g' >$(mandir)/pzstd.1 +endif build: dh $@ diff -Nru libzstd-1.5.5+dfsg2/debian/tests/c/programs.toml libzstd-1.5.5+dfsg2/debian/tests/c/programs.toml --- libzstd-1.5.5+dfsg2/debian/tests/c/programs.toml 2023-02-12 23:02:37.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/c/programs.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -[format.version] -major = 0 -minor = 1 - -[program.trivial] -executable = "triv" - -[program.trivial.commands] -clean = [["make", "clean"]] -build = [["make"]] -test = [["make", "test"]] diff -Nru libzstd-1.5.5+dfsg2/debian/tests/c/trivial/Makefile libzstd-1.5.5+dfsg2/debian/tests/c/trivial/Makefile --- libzstd-1.5.5+dfsg2/debian/tests/c/trivial/Makefile 2023-02-12 17:18:50.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/c/trivial/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -#!/usr/bin/make -f - -PROG= triv -SRCS= trivial.c -OBJS= trivial.o - -CC?= cc - -CPPFLAGS_STD?= -D_POSIX_SOURCE=200809L -D_XOPEN_SOURCE=700 - -CPPFLAGS+= ${CPPFLAGS_STD} - -CFLAGS_STD?= -std=c99 -pedantic -CFLAGS_OPT?= -g -O -pipe -CFLAGS_WARN?= -Wall -W -Wextra - -CFLAGS?= ${CFLAGS_OPT} -CFLAGS+= ${CFLAGS_STD} - -LDFLAGS?= - -LIBS?= - -RM?= rm -f -- - -all: ${PROG} - -${PROG}: ${OBJS} - ${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${LIBS} - -.c.o: - ${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $< - -clean: - ${RM} ${PROG} ${OBJS} - -test: all - ./${PROG} - -.PHONY: all test clean diff -Nru libzstd-1.5.5+dfsg2/debian/tests/c/trivial/trivial.c libzstd-1.5.5+dfsg2/debian/tests/c/trivial/trivial.c --- libzstd-1.5.5+dfsg2/debian/tests/c/trivial/trivial.c 2023-02-12 17:18:32.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/c/trivial/trivial.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -#include - -int main(void) -{ - puts("This is radio Clash tearing up the seven veils"); - return 0; -} diff -Nru libzstd-1.5.5+dfsg2/debian/tests/.config/ruff-all/pyproject.toml libzstd-1.5.5+dfsg2/debian/tests/.config/ruff-all/pyproject.toml --- libzstd-1.5.5+dfsg2/debian/tests/.config/ruff-all/pyproject.toml 2023-02-12 14:17:50.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/.config/ruff-all/pyproject.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -[tool.ruff] -extend = "../ruff-base/pyproject.toml" -select = ["ALL"] diff -Nru libzstd-1.5.5+dfsg2/debian/tests/.config/ruff-base/pyproject.toml libzstd-1.5.5+dfsg2/debian/tests/.config/ruff-base/pyproject.toml --- libzstd-1.5.5+dfsg2/debian/tests/.config/ruff-base/pyproject.toml 2023-02-12 16:40:57.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/.config/ruff-base/pyproject.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -[tool.ruff] -target-version = "py310" -line-length = 100 -select = [] -ignore = [ - # We know what "self" is, we hope. - "ANN101", - - # We leave most of the formatting to the `black` tool. - "COM812", - - # No blank lines before the class docstring, TYVM - "D203", - - # The multi-line docstring summary starts on the same line - "D213", - - # Too restrictive. - "EM", - - # We have different ideas about the ordering of the typing classes. - "I", - - # typedload needs this. - ## "TCH003", - - # Too restrictive. - "TRY003", -] - -[tool.ruff.per-file-ignores] -# This is a test suite. -"*/tests/*.py" = ["S101"] diff -Nru libzstd-1.5.5+dfsg2/debian/tests/.config/ruff-most/pyproject.toml libzstd-1.5.5+dfsg2/debian/tests/.config/ruff-most/pyproject.toml --- libzstd-1.5.5+dfsg2/debian/tests/.config/ruff-most/pyproject.toml 2023-03-05 10:42:21.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/.config/ruff-most/pyproject.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -[tool.ruff] -extend = "../ruff-base/pyproject.toml" -# This is the list of all of the linters in Ruff 0.0.245 except for -# the ones that are completely excluded in the ruff-base config. -select = [ - "A", - "ANN", - "ARG", - "B", - "BLE", - "C4", - "C90", - "COM", - "D", - "DTZ", - "E", - # "EM", - "ERA", - "EXE", - "F", - "FBT", - "G", - # "I", - "ICN", - "INP", - "ISC", - "N", - "PD", - "PGH", - "PIE", - "PL", - "PT", - "PTH", - "PYI", - "Q", - "RET", - "RSE", - "RUF", - "S", - "SIM", - "SLF", - "T10", - "T20", - "TCH", - "TID", - "TRY", - "UP", - "W", - "YTT", -] diff -Nru libzstd-1.5.5+dfsg2/debian/tests/control libzstd-1.5.5+dfsg2/debian/tests/control --- libzstd-1.5.5+dfsg2/debian/tests/control 2023-07-06 06:00:14.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/control 2023-02-12 23:12:46.000000000 +0000 @@ -1,24 +1,24 @@ Test-Command: zstd -b1 >/dev/null 2>&1 Features: test-name=zstd-selftest -Test-Command: "$(pwd)"/debian/tests/test pkg-make +Test-Command: env PYTHONPATH="$(pwd)/debian/tests/python" python3 -B -u -m check_build -c debian/tests/ztest/programs.toml -v -- pkg-make Depends: @, build-essential, pkgconf, - python3:any, - python3-click:any, - python3-typedload:any, + python3, + python3-click, + python3-typedload, Restrictions: allow-stderr Features: test-name=build-pkg-config -Test-Command: "$(pwd)"/debian/tests/test cmake +Test-Command: env PYTHONPATH="$(pwd)/debian/tests/python" python3 -B -u -m check_build -c debian/tests/ztest/programs.toml -v -- cmake Depends: @, build-essential, cmake, - python3:any, - python3-click:any, - python3-typedload:any, + python3, + python3-click, + python3-typedload, Restrictions: allow-stderr Features: test-name=build-cmake diff -Nru libzstd-1.5.5+dfsg2/debian/tests/pyproject.toml libzstd-1.5.5+dfsg2/debian/tests/pyproject.toml --- libzstd-1.5.5+dfsg2/debian/tests/pyproject.toml 2023-02-12 23:12:46.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/pyproject.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -[build-system] -requires = ["setuptools >= 61", "wheel"] -build-backend = "setuptools.build_meta" - -[project] -name = "check-build" -description = "Check whether some example programs can be compiled and built" -readme = "README.md" -requires-python = ">= 3.10" -classifiers = [ - "Development Status :: 4 - Beta", - "Environment :: Console", - "Intended Audience :: Developers", - "License :: DFSG approved", - "License :: Freely Distributable", - "License :: OSI Approved", - "License :: OSI Approved :: BSD License", - "Operating System :: POSIX", - "Operating System :: Unix", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation :: CPython", - "Topic :: Software Development", - "Topic :: Software Development :: Testing", - "Topic :: Utilities", - "Typing :: Typed", -] -dynamic = ["dependencies", "version"] - -[[project.authors]] -name = "Peter Pentchev" -email = "roam@ringlet.net" - -[project.scripts] -check-build = "check_build.__main__:main" - -[project.urls] -Homepage = "https://gitlab.com/ppentchev/check-build" -Changes = "https://gitlab.com/ppentchev/check-build/-/blob/main/CHANGELOG.md" -"Issue Tracker" = "https://gitlab.com/ppentchev/check-build/-/issues" -"Source Code" = "https://gitlab.com/ppentchev/check-build" - -[tool.setuptools] -zip-safe = true -package-dir = {"" = "python"} -packages = ["check_build"] - -[tool.setuptools.package-data] -check_build = ["py.typed"] - -[tool.setuptools.dynamic] -dependencies = {file = "requirements/install.txt"} -version = {attr = "check_build.defs.VERSION"} - -[tool.black] -target-version = ["py310", "py311"] -line-length = 100 - -[tool.mypy] -strict = true -python-version = "3.10" - -# This is the list of the Pylint 2.16.1 default plugins. -[tool.pylint] -load-plugins = [ - "pylint.extensions.bad_builtin", - "pylint.extensions.broad_try_clause", - "pylint.extensions.check_elif", - "pylint.extensions.code_style", - # "pylint.extensions.comparetozero", # clarity - "pylint.extensions.comparison_placement", - "pylint.extensions.confusing_elif", - "pylint.extensions.consider_refactoring_into_while_condition", - "pylint.extensions.consider_ternary_expression", - "pylint.extensions.dict_init_mutate", - "pylint.extensions.docparams", - "pylint.extensions.docstyle", - "pylint.extensions.dunder", - # "pylint.extensions.empty_comment", # the copyright notices trigger that one - "pylint.extensions.emptystring", - "pylint.extensions.eq_without_hash", - "pylint.extensions.for_any_all", - "pylint.extensions.magic_value", - "pylint.extensions.mccabe", - "pylint.extensions.no_self_use", - "pylint.extensions.overlapping_exceptions", - "pylint.extensions.private_import", - "pylint.extensions.redefined_loop_name", - "pylint.extensions.redefined_variable_type", - "pylint.extensions.set_membership", - "pylint.extensions.typing", - "pylint.extensions.while_used", -] - -[tool.pylint.main] -disable = [ - "consider-using-assignment-expr", -] - -[tool.test-stages] -stages = ["ruff", "@check", "@tests"] diff -Nru libzstd-1.5.5+dfsg2/debian/tests/python/check_build/defs.py libzstd-1.5.5+dfsg2/debian/tests/python/check_build/defs.py --- libzstd-1.5.5+dfsg2/debian/tests/python/check_build/defs.py 2023-02-12 22:30:26.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/python/check_build/defs.py 2023-09-11 17:54:11.000000000 +0000 @@ -1,34 +1,13 @@ -# Copyright (c) Peter Pentchev -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. +# SPDX-FileCopyrightText: Peter Pentchev +# SPDX-License-Identifier: BSD-2-Clause """Common definitions for the check-build library.""" from __future__ import annotations import dataclasses - from typing import TYPE_CHECKING + if TYPE_CHECKING: import logging import pathlib @@ -37,10 +16,18 @@ VERSION = "0.1.0" +@dataclasses.dataclass class CBuildError(Exception): """An error that occurred during the check-build routines operation.""" +@dataclasses.dataclass +class SkippedProgramError(CBuildError): + """A program had to be skipped.""" + + prog: str + + @dataclasses.dataclass(frozen=True) class Commands: """The commands to build and test a program.""" @@ -51,10 +38,18 @@ @dataclasses.dataclass(frozen=True) +class Prerequisites: + """The prerequisites to check for before attempting to build the program.""" + + programs: list[str] | None + + +@dataclasses.dataclass(frozen=True) class Program: """The definition of a single program.""" executable: str + prerequisites: Prerequisites | None commands: Commands @@ -62,6 +57,7 @@ class Config: """Runtime configuration for the check-build routines.""" + force: bool log: logging.Logger program: dict[str, Program] selected: list[str] diff -Nru libzstd-1.5.5+dfsg2/debian/tests/python/check_build/__init__.py libzstd-1.5.5+dfsg2/debian/tests/python/check_build/__init__.py --- libzstd-1.5.5+dfsg2/debian/tests/python/check_build/__init__.py 2023-02-12 14:26:20.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/python/check_build/__init__.py 2023-09-11 17:54:11.000000000 +0000 @@ -1,24 +1,3 @@ -# Copyright (c) Peter Pentchev -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. +# SPDX-FileCopyrightText: Peter Pentchev +# SPDX-License-Identifier: BSD-2-Clause """Read data about programs to build, build them one by one or all at once.""" diff -Nru libzstd-1.5.5+dfsg2/debian/tests/python/check_build/__main__.py libzstd-1.5.5+dfsg2/debian/tests/python/check_build/__main__.py --- libzstd-1.5.5+dfsg2/debian/tests/python/check_build/__main__.py 2023-02-12 17:32:27.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/python/check_build/__main__.py 2023-09-11 17:54:11.000000000 +0000 @@ -1,26 +1,5 @@ -# Copyright (c) Peter Pentchev -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. +# SPDX-FileCopyrightText: Peter Pentchev +# SPDX-License-Identifier: BSD-2-Clause """Check whether some programs will build or not.""" import pathlib @@ -41,25 +20,49 @@ required=True, type=click.Path(exists=True, dir_okay=False, resolve_path=True, path_type=pathlib.Path), ) +@click.option("-f", "--force", is_flag=True, default=False) @click.option("-v", "--verbose", is_flag=True, default=False) @click.argument("programs", type=str, nargs=-1) -def main(config: pathlib.Path, verbose: bool, programs: tuple[str, ...]) -> None: # noqa: FBT001 +def main( + config: pathlib.Path, force: bool, verbose: bool, programs: tuple[str, ...] # noqa: FBT001 +) -> None: """Parse command-line arguments, build things.""" try: - cfg = parse.load_config(config, programs, util.build_logger(verbose=verbose)) + cfg = parse.load_config( + config=config, force=force, programs=programs, logger=util.build_logger(verbose=verbose) + ) except defs.CBuildError as err: sys.exit(f"Could not parse the configuration file: {err}") if not cfg.selected: sys.exit("No programs specified") - for prog in cfg.selected: + skipped = [] + built_ok = [] + + def build_or_skip(prog: str) -> None: + """Build a program or skip it, updating the stats lists.""" try: process.build_and_test(cfg, prog) + except defs.SkippedProgramError: + skipped.append(prog) + else: + built_ok.append(prog) + + for prog in cfg.selected: + try: + build_or_skip(prog) except defs.CBuildError as err: sys.exit(f"Could not build the {prog} program: {err}") - cfg.log.info("All the programs were built and tested successfully") + cfg.log.info( + "%(built_ok)d program%(built_plu)s built and tested successfully, %(skipped)d skipped", + { + "built_ok": len(built_ok), + "built_plu": "" if len(built_ok) == 1 else "s", + "skipped": len(skipped), + }, + ) if __name__ == "__main__": - main() # pylint: disable=no-value-for-parameter + main() diff -Nru libzstd-1.5.5+dfsg2/debian/tests/python/check_build/parse.py libzstd-1.5.5+dfsg2/debian/tests/python/check_build/parse.py --- libzstd-1.5.5+dfsg2/debian/tests/python/check_build/parse.py 2023-02-12 22:30:26.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/python/check_build/parse.py 2023-09-11 17:54:11.000000000 +0000 @@ -1,26 +1,5 @@ -# Copyright (c) Peter Pentchev -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. +# SPDX-FileCopyrightText: Peter Pentchev +# SPDX-License-Identifier: BSD-2-Clause """Parse the configuration file.""" from __future__ import annotations @@ -28,29 +7,144 @@ import dataclasses import functools import sys - from typing import TYPE_CHECKING, Any import typedload.dataloader from check_build import defs + if sys.version_info >= (3, 11): import tomllib else: import tomli as tomllib if TYPE_CHECKING: - from typing import Final - import logging import pathlib + from typing import Final +@dataclasses.dataclass class ParseError(defs.CBuildError): """An error that occurred while parsing the configuration file.""" +@dataclasses.dataclass +class ConfigError(ParseError): + """An error that occurred while loading or parsing the configuration file.""" + + config: pathlib.Path + """The path to the config file that could not be parsed.""" + + +@dataclasses.dataclass +class ConfigExcError(ConfigError): + """An error that occurred while loading the config file with an exception attached.""" + + err: Exception + """The exception that occurred while loading the config file.""" + + +@dataclasses.dataclass +class ConfigAbsoluteError(ConfigError): + """The path to the config file was not an absolute one.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"Not an absolute path to the config file: {self.config}" + + +@dataclasses.dataclass +class ConfigReadError(ConfigExcError): + """Could not read the config file.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"Could not read the {self.config} file: {self.err}" + + +@dataclasses.dataclass +class ConfigUTF8Error(ConfigExcError): + """Could not parse the config file as valid UTF-8 text.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"Could not parse the {self.config} file as valid UTF-8: {self.err}" + + +@dataclasses.dataclass +class ConfigTOMLError(ConfigExcError): + """Could not parse the config file as valid TOML.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"Could not parse the {self.config} file as valid TOML: {self.err}" + + +@dataclasses.dataclass +class ConfigTableError(ConfigError): + """The config file did not contain a top-level TOML table.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"Expected a table as the top-level object in the {self.config} file" + + +@dataclasses.dataclass +class ConfigParseError(ConfigExcError): + """Could not parse the config file as per our expected structure.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"Could not parse the {self.config} file: {self.err}" + + +@dataclasses.dataclass +class FormatParseError(ConfigExcError): + """Could not parse the config file to obtain the format version.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"Could not determine the format version of the {self.config} file: {self.err}" + + +@dataclasses.dataclass +class FormatInvalidError(ConfigError): + """The format version in the config file did not consist of two integers.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"The format.version.major/minor values in the {self.config} file must be integers" + + +@dataclasses.dataclass +class FormatUnsupportedError(ConfigError): + """The format version is not supported by this version of check-build.""" + + major: int + """The major number of the format version.""" + + minor: int + """The minor number of the format version.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"Unsupported format version {self.major}.{self.minor} in the {self.config} file" + + +@dataclasses.dataclass +class UnknownProgramsError(ParseError): + """The programs specified on the command line are not defined in the config file.""" + + unknown: list[str] + """The unknown programs specified on the command line.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"Unknown programs specified: {', '.join(self.unknown)}" + + @dataclasses.dataclass(frozen=True) class TCommands: """The commands to build and test a program.""" @@ -61,11 +155,19 @@ @dataclasses.dataclass(frozen=True) +class TPrereq: + """The prerequisites for building a program.""" + + programs: list[str] | None = None + + +@dataclasses.dataclass(frozen=True) class TProgram: """The definition of a single program.""" executable: str commands: TCommands + prerequisites: TPrereq | None = None @dataclasses.dataclass(frozen=True) @@ -80,15 +182,11 @@ try: major, minor = progs["format"]["version"]["major"], progs["format"]["version"]["minor"] except (TypeError, KeyError) as err: - raise ParseError( - f"Could not determine the format version of the {config} file: {err}" - ) from err + raise FormatParseError(config, err) from err if not isinstance(major, int) or not isinstance(minor, int): - raise ParseError( - f"The format.version.major/minor values in the {config} file must be integers" - ) + raise FormatInvalidError(config) if (major, minor) != (0, 1): - raise ParseError(f"Unsupported format version {major}.{minor} in the {config} file") + raise FormatUnsupportedError(config, major, minor) def _select_programs(cfg: TConfig, programs: tuple[str, ...]) -> list[str]: @@ -99,7 +197,7 @@ selected: Final = list(programs) unknown: Final = [name for name in selected if name not in cfg.program] if unknown: - raise ParseError(f"Unknown programs specified: {', '.join(unknown)}") + raise UnknownProgramsError(unknown) return selected @@ -111,37 +209,41 @@ def load_config( - config: pathlib.Path, programs: tuple[str, ...], logger: logging.Logger + *, config: pathlib.Path, force: bool, programs: tuple[str, ...], logger: logging.Logger ) -> defs.Config: """Load the configuration file describing the list of programs to build.""" if not config.is_absolute(): - raise ParseError(f"Not an absolute path to the config file: {config}") + raise ConfigAbsoluteError(config) try: contents: Final = config.read_text(encoding="UTF-8") except OSError as err: - raise ParseError(f"Could not read the {config} file: {err}") from err + raise ConfigReadError(config, err) from err except ValueError as err: - raise ParseError(f"Could not parse the {config} file as valid UTF-8: {err}") from err + raise ConfigUTF8Error(config, err) from err try: progs: Final = tomllib.loads(contents) except ValueError as err: - raise ParseError(f"Could not parse the {config} file as valid TOML: {err}") from err + raise ConfigTOMLError(config, err) from err if not isinstance(progs, dict): - raise ParseError(f"Expected a table as the top-level object in the {config} file") + raise ConfigTableError(config) _validate_format_version(config, progs) del progs["format"] try: cfg: Final = typed_loader().load(progs, TConfig) except ValueError as err: - raise ParseError(f"Could not parse the {config} file: {err}") from err + raise ConfigParseError(config, err) from err return defs.Config( + force=force, log=logger, program={ name: defs.Program( executable=prog.executable, + prerequisites=defs.Prerequisites(programs=prog.prerequisites.programs) + if prog.prerequisites is not None + else None, commands=defs.Commands( clean=prog.commands.clean, build=prog.commands.build, test=prog.commands.test ), diff -Nru libzstd-1.5.5+dfsg2/debian/tests/python/check_build/process.py libzstd-1.5.5+dfsg2/debian/tests/python/check_build/process.py --- libzstd-1.5.5+dfsg2/debian/tests/python/check_build/process.py 2023-02-12 22:30:26.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/python/check_build/process.py 2023-09-11 17:54:11.000000000 +0000 @@ -1,45 +1,91 @@ -# Copyright (c) Peter Pentchev -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. +# SPDX-FileCopyrightText: Peter Pentchev +# SPDX-License-Identifier: BSD-2-Clause """Build and test a single program.""" from __future__ import annotations +import dataclasses +import os import pathlib import shlex import shutil import subprocess import tempfile - from typing import Final from check_build import defs +@dataclasses.dataclass class ProcessError(defs.CBuildError): """An error that occurred during the build and test process.""" +@dataclasses.dataclass +class RunError(ProcessError): + """Could not run a program for a build stage.""" + + tag: str + """The stage at which a program failed.""" + + cmdstr: str + """The command we attempted to run.""" + + cwd: pathlib.Path + """The directory we attempted to run the program in.""" + + err: Exception + """The error that occurred while running the program.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return ( + f"A {self.tag} command failed: could not run `{self.cmdstr}` in {self.cwd}: {self.err}" + ) + + +@dataclasses.dataclass +class NoProgramError(ProcessError): + """A program was not defined in the configuration.""" + + prog: str + """The program we expected to be able to be build.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"No {self.prog!r} program defined in the configuration" + + +@dataclasses.dataclass +class CopyError(ProcessError): + """Could not copy a source directory to a temporary one.""" + + origdir: pathlib.Path + """The original directory in the source tree.""" + + srcdir: pathlib.Path + """The temporary directory to build and run the program in.""" + + err: Exception + """The error that occurred while running the program.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"Could not copy {self.origdir} to the temporary {self.srcdir}: {self.err}" + + +@dataclasses.dataclass +class NotSourceError(ProcessError): + """The expected directory does not contain our configuration files.""" + + origdir: pathlib.Path + """The directory that was not as expected.""" + + def __str__(self) -> str: + """Provide a human-readable description of the error.""" + return f"Not a source directory: {self.origdir}" + + def _run_commands( cfg: defs.Config, tag: str, commands: list[list[str]], *, cwd: pathlib.Path ) -> None: @@ -48,22 +94,69 @@ cmdstr = shlex.join(cmd) cfg.log.debug("- running `%(cmdstr)s`", {"cmdstr": cmdstr}) try: - subprocess.run(cmd, check=True, cwd=cwd, shell=False) + subprocess.run(cmd, check=True, cwd=cwd, shell=False) # noqa: S603 except (OSError, subprocess.CalledProcessError) as err: - raise ProcessError( - f"A {tag} command failed: could not run `{cmdstr}` in {cwd}: {err}" - ) from err + raise RunError(tag, cmdstr, cwd, err) from err + + +def _prereqs_programs_ok( + cfg: defs.Config, prereqs: defs.Prerequisites, srcdir: pathlib.Path +) -> bool: + """If any programs have been specified as prerequisites, look for them in the search path.""" + programs: Final = prereqs.programs + if not programs: + return True + + def _check_prog(cmd: str) -> bool: + """Check for the presence of a single program.""" + prog_path: Final = pathlib.Path(cmd) + if len(prog_path.parts) != 1 or prog_path.is_absolute(): + target: Final = srcdir / prog_path + if not os.access(target, os.F_OK | os.X_OK): + cfg.log.info( + "- the %(target)s prerequisite program is not present", + {"target": shlex.quote(str(target))}, + ) + return False + + return True + + if shutil.which(cmd) is None: + cfg.log.info( + "- the %(cmd)s prerequisite external program is not present", + {"cmd": shlex.quote(cmd)}, + ) + return False + + return True + + cfg.log.info("Checking for programs present: %(progs)s", {"progs": shlex.join(programs)}) + return all(_check_prog(prog) for prog in programs) + + +def _prereqs_ok(cfg: defs.Config, prog: str, progdef: defs.Program, srcdir: pathlib.Path) -> bool: + """If any prerequisites have been specified, check whether they are present.""" + prereqs: Final = progdef.prerequisites + if prereqs is None: + return True + + cfg.log.info("Checking for the prerequisites of %(prog)s", {"prog": prog}) + + if not _prereqs_programs_ok(cfg, prereqs, srcdir): + return False + + return True def build_and_test(cfg: defs.Config, prog: str) -> None: """Build and test a single program in a temporary directory.""" progdef: Final = cfg.program.get(prog) if progdef is None: - raise ProcessError(f"No {prog!r} program defined in the configuration") + raise NoProgramError(prog) origdir: Final = cfg.topdir / prog if not origdir.is_dir(): - raise ProcessError(f"Not a source directory: {origdir}") + raise NotSourceError(origdir) with tempfile.TemporaryDirectory(prefix="check-build.") as tempd_obj: tempd: Final = pathlib.Path(tempd_obj) @@ -75,9 +168,14 @@ try: shutil.copytree(origdir, srcdir, symlinks=True) except OSError as err: - raise ProcessError( - f"Could not copy {origdir} to the temporary {srcdir}: {err}" - ) from err + raise CopyError(origdir, srcdir, err) from err + + if not _prereqs_ok(cfg, prog, progdef, srcdir): + if not cfg.force: + cfg.log.info("SKIPPING %(prog)s, prerequisites not satisfied", {"prog": prog}) + raise defs.SkippedProgramError(prog) + + cfg.log.info("NOT SKIPPING %(prog)s despite unsatisfied prerequisites", {"prog": prog}) cfg.log.info("Building %(prog)s in %(srcdir)s", {"prog": prog, "srcdir": srcdir}) _run_commands(cfg, "build", progdef.commands.build, cwd=srcdir) diff -Nru libzstd-1.5.5+dfsg2/debian/tests/python/check_build/util.py libzstd-1.5.5+dfsg2/debian/tests/python/check_build/util.py --- libzstd-1.5.5+dfsg2/debian/tests/python/check_build/util.py 2023-02-12 17:32:48.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/python/check_build/util.py 2023-09-11 17:54:11.000000000 +0000 @@ -1,35 +1,17 @@ -# Copyright (c) Peter Pentchev -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. +# SPDX-FileCopyrightText: Peter Pentchev +# SPDX-License-Identifier: BSD-2-Clause """Common utilities for the check-build library.""" +import functools import logging import sys +@functools.lru_cache(maxsize=2) def build_logger(*, verbose: bool) -> logging.Logger: """Build a logger that outputs messages to the standard output stream.""" - logger = logging.getLogger() + name_prefix = "" if verbose else "non-" + logger = logging.getLogger(f"check-build/{name_prefix}verbose") logger.setLevel(logging.DEBUG) stdout_handler = logging.StreamHandler(stream=sys.stdout) diff -Nru libzstd-1.5.5+dfsg2/debian/tests/python/tests/__init__.py libzstd-1.5.5+dfsg2/debian/tests/python/tests/__init__.py --- libzstd-1.5.5+dfsg2/debian/tests/python/tests/__init__.py 2023-02-12 16:34:03.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/python/tests/__init__.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -# Copyright (c) Peter Pentchev -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -"""A unit tests suite for the check-build library.""" diff -Nru libzstd-1.5.5+dfsg2/debian/tests/python/tests/test_trivial.py libzstd-1.5.5+dfsg2/debian/tests/python/tests/test_trivial.py --- libzstd-1.5.5+dfsg2/debian/tests/python/tests/test_trivial.py 2023-02-12 17:33:33.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/python/tests/test_trivial.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -# Copyright (c) Peter Pentchev -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -"""Test the functionality with a trivial configuration.""" - -from __future__ import annotations - -import pathlib - -from unittest import mock - -from typing import TYPE_CHECKING - -from check_build import defs -from check_build import parse -from check_build import process -from check_build import util - -if TYPE_CHECKING: - from typing import Final - - -TOPDIR = pathlib.Path(__file__).parent.parent.parent - -PROG_TRIVIAL = "trivial" -PROG_NO_SUCH = "no such program" - - -def test_trivial() -> None: - """Parse the configuration, find the 'trivial' test, run it.""" - commands: list[tuple[list[str | pathlib.Path], pathlib.Path]] = [] - - def mock_run( - cmd: list[str | pathlib.Path], - *, - check: bool = False, - cwd: pathlib.Path | None = None, - shell: bool = False, - ) -> None: - """Mock subprocess.run(), check for the right programs in the right order.""" - assert check - assert not shell - - assert cwd is not None - assert cwd.is_dir() - assert cwd != TOPDIR / "c/trivial" - - nonlocal commands - if not commands: - assert cmd == ["make"] - elif len(commands) == 1: - assert cwd == commands[0][1] - assert cmd == ["make", "test"] - else: - raise ValueError(f"Too many commands: {commands=!r} {cmd=!r} {cwd=!r}") - - commands.append((cmd, cwd)) - - cfg: Final = parse.load_config( - TOPDIR / "c/programs.toml", (PROG_TRIVIAL,), util.build_logger(verbose=True) - ) - assert PROG_TRIVIAL in cfg.program - assert PROG_NO_SUCH not in cfg.program - assert all(isinstance(prog, defs.Program) for prog in cfg.program.values()) - assert cfg.selected == [PROG_TRIVIAL] - - with mock.patch("subprocess.run", new=mock_run): - process.build_and_test(cfg, PROG_TRIVIAL) diff -Nru libzstd-1.5.5+dfsg2/debian/tests/README.md libzstd-1.5.5+dfsg2/debian/tests/README.md --- libzstd-1.5.5+dfsg2/debian/tests/README.md 2023-02-12 21:33:29.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/README.md 2023-09-11 17:53:11.000000000 +0000 @@ -1,6 +1,101 @@ + + # check-build -- check whether example programs can be built The `check-build` tool can be used to build and test different programs in a temporary build directory. The programs are listed in a TOML configuration file, along with the commands to build and test them. + +## Configuration file structure + +The file describing the subdirectories with the programs to be built has +the following structure: + +### The "format" section + +The `format` section contains a single table named `version` with two +keys, `major` and `minor`, both integers. The `major.minor` pair +specifies the version of the format specification for the `programs.toml` +file itself. + +The only valid combination of values is `major = 0` and `minor = 1`. + +### The "program" section + +This table contains the definitions for the programs that `check-build` +should try to build and run. It may have one or more entries with +names corresponding to the names of the subdirectories where the files for +each program may be found. + +#### The "program.NAME.prerequisites" section + +This table currently only has a single valid key, `programs`: a list of +program names that will be looked for in the current execution search path. + +If any of these prerequisites are not met, `check-build` will not +attempt to build the program, but it will report it as skipped, not failed. +This may be overridden by the `--force` command-line option +(or the `check_build.defs.Config.force` boolean variable): if it is +specified, then `check-build` will attempt to build and run the program +even if some of its prerequisites are not met. + +#### The "program.NAME.commands" section + +This table contains the lists of commands to be executed in order to +build and test the program. Each value is a list of commands to be +executed, and each command in its turn is a list of strings: +a program name and arguments to pass to it. + +There are currently three valid keys in this table: + +- `clean`: not used yet, since `check-build` always copies the program + files to a newly-created temporary directory, so there should be no + previously-existing build artifacts +- `build`: one or more commands to execute to build the program +- `test`: one or more commands to execute to make sure that the program + that was just built is operational and correct + +## The `check-build` command-line tool + +The most common way to use `check-build` is through the command-line tool: +run `check-build`, specify the path to the TOML configuration file using +the `-c` option, optionally pass the `-v` / `--verbose` flag. By default, +the `check-build` tool will try to build and test all the programs +defined in the configuration file; pass one or more program names on +the command line to only build and test those. + +## Examples + +Given the following contents of the `ztest/programs.toml` configuration file: + + [format.version] + major = 0 + minor = 1 + + [program.pkg-make] + executable = "ztest" + + [program.pkg-make.commands] + clean = [["make", "clean"]] + build = [["make"]] + test = [["make", "test"]] + + [program.cmake] + executable = "ztest" + + [program.cmake.commands] + clean = [["make", "clean"]] + build = [["cmake", "."], ["make"]] + test = [["./ztest"]] + +Build and test both programs: + + check-build -c ztest/programs.toml + +Only build and test the CMake version with some `check-build` diagnostic messages: + + check-build -c ztest/programs.toml -v cmake diff -Nru libzstd-1.5.5+dfsg2/debian/tests/setup.cfg libzstd-1.5.5+dfsg2/debian/tests/setup.cfg --- libzstd-1.5.5+dfsg2/debian/tests/setup.cfg 2023-02-12 14:36:24.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/setup.cfg 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -[flake8] -max_line_length = 100 diff -Nru libzstd-1.5.5+dfsg2/debian/tests/test libzstd-1.5.5+dfsg2/debian/tests/test --- libzstd-1.5.5+dfsg2/debian/tests/test 2023-07-06 06:00:14.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/test 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -#!/bin/bash - -set -e - -if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then - export CROSS_COMPILE="$DEB_HOST_GNU_TYPE-" -else - export CROSS_COMPILE= -fi - -CROSS_COMPILE=${CROSS_COMPILE} PYTHONPATH="$(pwd)/debian/tests/python" python3 -B -u -m check_build -c debian/tests/ztest/programs.toml -v -- $1 diff -Nru libzstd-1.5.5+dfsg2/debian/tests/tox.ini libzstd-1.5.5+dfsg2/debian/tests/tox.ini --- libzstd-1.5.5+dfsg2/debian/tests/tox.ini 2023-03-05 10:42:21.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/tox.ini 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -[tox] -envlist = - ruff - ruff-all - black - pep8 - mypy - pylint - unit-tests - functional -isolated_build = True - -[defs] -pyfiles = - python/check_build - python/tests - -[testenv:black] -skip_install = True -tags = - check -deps = - black >= 23, < 24 -commands = - black --check -- {[defs]pyfiles} - -[testenv:black-reformat] -skip_install = True -tags = - format - manual -deps = - black >= 23, < 24 -commands = - black -- {[defs]pyfiles} - -[testenv:pep8] -skip_install = True -tags = - check -deps = - flake8 >= 6, < 7 -commands = - flake8 -- {[defs]pyfiles} - -[testenv:mypy] -skip_install = True -tags = - check -deps = - -r requirements/install.txt - mypy >= 1, < 2 - tomli >= 2, < 3 -commands = - mypy -- {[defs]pyfiles} - -[testenv:pylint] -skip_install = True -tags = - check -deps = - -r requirements/install.txt - pylint >= 2.16, < 2.17 -commands = - pylint -- {[defs]pyfiles} - -[testenv:ruff] -skip_install = True -tags = - check -deps = - ruff >= 0.0.245, < 0.1 -commands = - ruff check --config .config/ruff-most/pyproject.toml -- {[defs]pyfiles} - -[testenv:ruff-all] -skip_install = True -tags = - check -deps = - ruff == 0.0.245 -commands = - ruff check --config .config/ruff-all/pyproject.toml -- {[defs]pyfiles} - -[testenv:unit-tests] -tags = - tests -deps = - -r requirements/install.txt - -r requirements/tests.txt -commands = - pytest -s -vv python/tests - -[testenv:functional] -tags = - tests -deps = - -r requirements/install.txt -allowlist_externals = - sh -commands = - sh -c '! check-build' - check-build -c c/programs.toml -v -- trivial diff -Nru libzstd-1.5.5+dfsg2/debian/tests/ztest/pkg-make/Makefile libzstd-1.5.5+dfsg2/debian/tests/ztest/pkg-make/Makefile --- libzstd-1.5.5+dfsg2/debian/tests/ztest/pkg-make/Makefile 2023-07-06 06:00:14.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/ztest/pkg-make/Makefile 2023-02-12 23:12:46.000000000 +0000 @@ -4,7 +4,7 @@ SRCS= ztest.c OBJS= ztest.o -CC?= ${CROSS_COMPILE}gcc +CC?= cc CPPFLAGS_STD?= -D_POSIX_SOURCE=200809L -D_XOPEN_SOURCE=700 @@ -13,12 +13,12 @@ CFLAGS_STD?= -std=c99 -pedantic CFLAGS_OPT?= -g -O -pipe CFLAGS_WARN?= -Wall -W -Wextra -CFLAGS_ZSTD?= $(shell ${CROSS_COMPILE}pkg-config --cflags libzstd) +CFLAGS_ZSTD?= $(shell pkg-config --cflags libzstd) CFLAGS?= ${CFLAGS_OPT} CFLAGS+= ${CFLAGS_STD} -LIBS_ZSTD?= $(shell ${CROSS_COMPILE}pkg-config --libs libzstd) +LIBS_ZSTD?= $(shell pkg-config --libs libzstd) LDFLAGS?= diff -Nru libzstd-1.5.5+dfsg2/debian/tests/ztest/programs.toml libzstd-1.5.5+dfsg2/debian/tests/ztest/programs.toml --- libzstd-1.5.5+dfsg2/debian/tests/ztest/programs.toml 2023-07-06 06:00:14.000000000 +0000 +++ libzstd-1.5.5+dfsg2/debian/tests/ztest/programs.toml 2023-06-22 22:59:04.000000000 +0000 @@ -7,7 +7,7 @@ [program.pkg-make.commands] clean = [["make", "clean"]] -build = [["make", "CROSS_COMPILE=${CROSS_COMPILE}"]] +build = [["make"]] test = [["make", "test"]] [program.cmake] @@ -15,5 +15,5 @@ [program.cmake.commands] clean = [["make", "clean"]] -build = [["cmake", ".", "-DCMAKE_C_COMPILER=/usr/bin/${CROSS_COMPILE}gcc", "-DCMAKE_CXX_COMPILER=/usr/bin/${CROSS_COMPILE}g++"], ["make"]] +build = [["cmake", "."], ["make"]] test = [["./ztest"]]