From 445b2239d912f4a362f85c2c147c9019fa6092b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Lain=C3=A9?= Date: Thu, 2 Nov 2023 00:03:54 +0100 Subject: [PATCH] Remove "test" script, use Makefile instead We also drop some unused scripts: - clean-branches - vagrant-test --- .github/workflows/tests.yml | 17 +---- .gitignore | 1 - Makefile | 57 +++-------------- scripts/build-debug-python | 33 ---------- scripts/clean-branches | 120 ------------------------------------ scripts/test | 46 -------------- scripts/test-examples | 18 ++++++ scripts/vagrant-test | 7 --- 8 files changed, 31 insertions(+), 268 deletions(-) delete mode 100755 scripts/build-debug-python delete mode 100755 scripts/clean-branches delete mode 100755 scripts/test create mode 100755 scripts/test-examples delete mode 100755 scripts/vagrant-test diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index edca189f9..9a1375f7e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -86,10 +86,7 @@ jobs: scripts/build - name: Test - run: | - . scripts/activate.sh ffmpeg-${{ matrix.config.ffmpeg }} - python -m av --version # Assert it can import. - scripts/test + run: make test - name: Docs if: matrix.config.extras @@ -101,19 +98,11 @@ jobs: if: matrix.config.extras run: | . scripts/activate.sh ffmpeg-${{ matrix.config.ffmpeg }} - scripts/test doctest + make -C docs test - name: Examples if: matrix.config.extras - run: | - . scripts/activate.sh ffmpeg-${{ matrix.config.ffmpeg }} - scripts/test examples - - - name: Source Distribution - if: matrix.config.extras - run: | - . scripts/activate.sh ffmpeg-${{ matrix.config.ffmpeg }} - scripts/test sdist + run: make test-examples windows: name: "py-${{ matrix.config.python }} lib-${{ matrix.config.ffmpeg }} ${{matrix.config.os}}" diff --git a/.gitignore b/.gitignore index bc6c09077..6e5a2b48e 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,6 @@ # Testing. *.spyderproject .idea -/.vagrant /sandbox /tests/assets /tests/samples diff --git a/Makefile b/Makefile index fd4d4ed51..ef657e202 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ PYAV_PYTHON ?= python PYTHON := $(PYAV_PYTHON) -.PHONY: default build cythonize clean clean-all info lint test fate-suite test-assets docs +.PHONY: default build clean docs fate-suite lint test test-examples default: build @@ -13,21 +13,13 @@ default: build build: CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) $(PYTHON) setup.py build_ext --inplace --debug -cythonize: - $(PYTHON) setup.py cythonize - - - -wheel: build-mingw32 - $(PYTHON) setup.py bdist_wheel - -build-mingw32: - # before running, set PKG_CONFIG_PATH to the pkgconfig dir of the ffmpeg build. - # set PKG_CONFIG_PATH=D:\dev\3rd\media-autobuild_suite\local32\bin-video\ffmpegSHARED\lib\pkgconfig - CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) $(PYTHON) setup.py build_ext --inplace -c mingw32 - mv *.pyd av - - +clean: + - find av -name '*.so' -delete + - rm -rf build + - rm -rf sandbox + - rm -rf src + - rm -rf tmp + - make -C docs clean fate-suite: # Grab ALL of the samples from the ffmpeg site. @@ -41,15 +33,8 @@ lint: test: $(PYTHON) setup.py test - - -vagrant: - vagrant box list | grep -q precise32 || vagrant box add precise32 http://files.vagrantup.com/precise32.box - -vtest: - vagrant ssh -c /vagrant/scripts/vagrant-test - - +test-examples: + scripts/test-examples tmp/ffmpeg-git: @ mkdir -p tmp/ffmpeg-git @@ -67,25 +52,3 @@ docs: tmp/tagfile.xml deploy-docs: docs ./docs/upload docs - - - - -clean-build: - - rm -rf build - - find av -name '*.so' -delete - -clean-sandbox: - - rm -rf sandbox/201* - - rm sandbox/last - -clean-src: - - rm -rf src - -clean-docs: - - rm tmp/Doxyfile - - rm tmp/tagfile.xml - - make -C docs clean - -clean: clean-build clean-sandbox clean-src -clean-all: clean-build clean-sandbox clean-src clean-docs diff --git a/scripts/build-debug-python b/scripts/build-debug-python deleted file mode 100755 index 757946f14..000000000 --- a/scripts/build-debug-python +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -export PYAV_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.."; pwd)" - -export PYAV_PYTHON_VERSION="2.7.13" -export PYAV_PLATFORM_SLUG="$(uname -s).$(uname -r)" -export PYAV_VENV_NAME="$PYAV_PLATFORM_SLUG.cpython-$PYAV_PYTHON_VERSION-debug" -export PYAV_VENV="$PYAV_ROOT/venvs/$PYAV_VENV_NAME" - - -export PYAV_PYTHON_SRC="$PYAV_ROOT/vendor/Python-$PYAV_PYTHON_VERSION" - -if [[ ! -d "$PYAV_PYTHON_SRC" ]]; then - url="https://www.python.org/ftp/python/$PYAV_PYTHON_VERSION/Python-$PYAV_PYTHON_VERSION.tgz" - echo "Downloading $url" - wget -O "$PYAV_PYTHON_SRC.tgz" "$url" || exit 2 - tar -C "$PYAV_ROOT/vendor" -xvzf "$PYAV_PYTHON_SRC.tgz" || exit 3 -fi - -cd "$PYAV_PYTHON_SRC" || exit 4 - -# TODO: Make generic. -export CPPFLAGS="-I$(brew --prefix openssl)/include" -export LDFLAGS="-L$(brew --prefix openssl)/lib" - -# --with-pymalloc \ -./configure \ - --with-pydebug \ - --prefix "$PYAV_VENV" \ - || exit 5 - -make -j 12 || exit 6 - diff --git a/scripts/clean-branches b/scripts/clean-branches deleted file mode 100755 index 83f82f6fb..000000000 --- a/scripts/clean-branches +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env python - -import subprocess - - -# These are remote branches that got rebased or something, but I don't have -# control over. -ignored_hashes = set(''' - 078daa1148a84849ea0890b388353acd7333fcea - 0832d2bdaa048fca1393f3d3810b8b8810535f9f - 08e86996736d77df7d694d0a67a126fc7eac7e94 - 097631535fa4cdb87204980541d3f9bb9c7a9ffb - 16ce34ba1d1f1ed4327326a10565f1a9f07107b0 - 183cf1447571aa48baf0665d17d41be1e48f2cc6 - 245a4dca69cf0fff674c6ad5bcfb7929c7347bf6 - 28b4b3988981471ff173679db3643418ff3f5aaa - 3977b5d5be22922f2eb4288e2682f1de8fad8e12 - 5b9f192165855942918f9bd957c30e918b97cbeb - 6091e89de0ae4aff2ba76d21b1110409ef174b78 - 636afe3f0b5b07233edae8e333db35c044c36b30 - 74f79ef74ec281f5e0da51bcfd0b1051aa53edbf - 7737ef6e9e7307c40f326e61cc9291047540bc49 - 8618940d333f44ff960d561dda34167d4dbb81d4 - a2fb55e97788809b5f33b1b0c9241fc77312f606 - aa044b3f62a6d7bf4dde18cba91b1d0dd8a0816a - aa7d01ba458025ede1757e56b638002375bb864a - aafe064e209b667f565c4f57a94b098474d0b184 - afac2d8f89673c012d1f4b845b006911f55d1d86 - b115786b950c87ef9c422752e014297903bca393 - b737c6ceb6750d00f62dfdaa40fee3e757c680a3 - b7bf427a485736e6e1c71605bdce101214bae09f - ba02afa7ea160328b5a3be111c7e276fb9d3c961 - bc5ffe456345286a64ce33ffe5ce6a2ee8b63f40 - c45a337fe49875b1cc28a0501a704890be444765 - c6b1a5ac03e775ea46bffac7bbfea9d73cd03b87 - c9c0d63b09c450d494fba1c4073fbe18851dfaff - cc270d6790c02e6c5e93313d1e6499ce534350b9 - cdd8e4c085a55e258bd551f7bcf4fee60474aa05 - eac71881c24d42f801e9c18e448855a402333960 - efd12926b1f446c32f5a239c0b2d351fa2d78101 - f04dce0e80b4f290482eba4fb3c3ec68f353bf01 - f0d1e82dee788085cf4afad7656a90966e40f7a0 - f518f6e7bf47e00fe0c73a5098ae40813920400f - f779c4371fdace76ee572053b4acb3999ffd4107 -'''.strip().split()) - - -def get_branches(*args): - cmd = ['git', 'branch', '-v', '--abbrev=40'] - cmd.extend(args) - res = {} - for line in subprocess.check_output(cmd).decode().splitlines(): - parts = line[2:].strip().split() - name = parts[0] - hash_ = parts[1] - res[name] = hash_ - return res - -def rm(*args): - subprocess.check_call(('git', 'branch', '-D') + args) - - -# Clean up everything that was merged -for line in subprocess.check_output(['git', 'branch', '--merged']).decode().splitlines(): - line = line.strip() - if not line: - continue - parts = line.split() - if parts[0] == '*': - continue - if parts[-1] in ('develop', 'master'): - continue - rm(parts[-1]) - -for line in subprocess.check_output(['git', 'branch', '-r', '--merged']).decode().splitlines(): - name = line.strip().split()[-1] - if not name: - continue - if name.split('/', 1)[-1] in ('develop', 'master'): - continue - rm('-r', name) - - -our_branches = get_branches() -for name, hash_ in get_branches('-r').items(): - - if hash_ in ignored_hashes: - print("Removing ignored", name) - rm('-r', name) - continue - - if name.startswith('origin/'): - our_branches[name] = hash_ - - -for name in get_branches('-r', '--merged'): - if name.startswith('origin/'): - continue - print("Removing merged", name) - rm('-r', name) - -for name, hash_ in get_branches('-r', '--no-merged').items(): - - remote, branch = name.split('/', 1) - if remote == 'origin': - continue - - for prefix in '', 'origin/': - our_name = prefix + branch - if our_branches.get(our_name) == hash_: - print("Removing identical", name) - rm('-r', name) - break - -# Anything that doesn't root at the same place as us. -for name in get_branches('-r', '--no-contains', 'e105c0b4e64a0471f3f5375a86342c33cb942e23'): - rm('-r', name) - - - diff --git a/scripts/test b/scripts/test deleted file mode 100755 index 3eca2feb7..000000000 --- a/scripts/test +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -# Exit as soon as something errors. -set -e - -if [[ ! "$_PYAV_ACTIVATED" ]]; then - export here="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" - source "$here/activate.sh" -fi - -cd "$PYAV_ROOT" - - -TESTSUITE="${1-main}" - -istest() { - [[ "$TESTSUITE" == all || "$TESTSUITE" == "$1" ]] - return $? -} - -if istest main; then - $PYAV_PYTHON setup.py test -fi - -if istest sdist; then - $PYAV_PYTHON setup.py build_ext - $PYAV_PYTHON setup.py sdist -fi - -if istest doctest; then - make -C docs test -fi - -if istest examples; then - for name in $(find examples -name '*.py'); do - echo - echo === $name - cd "$PYAV_ROOT" - mkdir -p "sandbox/$1" - cd "sandbox/$1" - if ! python "$PYAV_ROOT/$name"; then - echo FAILED $name with code $? - exit $? - fi - done -fi diff --git a/scripts/test-examples b/scripts/test-examples new file mode 100755 index 000000000..d433748d5 --- /dev/null +++ b/scripts/test-examples @@ -0,0 +1,18 @@ +#!/bin/bash + +# Exit as soon as something errors. +set -e + +PYAV_ROOT=$PWD + +for name in $(find examples -name '*.py'); do + echo + echo === $name + cd "$PYAV_ROOT" + mkdir -p "sandbox/$1" + cd "sandbox/$1" + if ! python "$PYAV_ROOT/$name"; then + echo FAILED $name with code $? + exit $? + fi +done diff --git a/scripts/vagrant-test b/scripts/vagrant-test deleted file mode 100755 index dbdab607a..000000000 --- a/scripts/vagrant-test +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -cd /vagrant - -./scripts/build-deps -./scripts/build -./scripts/test