From 7159cab3e09b9e2fdf04dfdefe063713b3cdea73 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Fri, 6 Jun 2025 11:44:34 +0100 Subject: [PATCH 1/5] scripts/test.py: added --show-args for debugging. --- scripts/test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/test.py b/scripts/test.py index 973a404b5..31bcb7a3d 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -144,6 +144,9 @@ [This simply sSets $PYMUPDF_SETUP_PY_LIMITED_API, which is used by PyMuPDF/setup.py.] + --show-args: + Show sys.argv and exit. For debugging. + --sync-paths Do not run anything, instead write required files/directories/checkouts to stdout, one per line. This is to help with automated running on @@ -278,6 +281,7 @@ def main(argv): pyodide_build_version = None pytest_options = '' pytest_prefix = None + show_args = False show_help = False sync_paths = False system_site_packages = False @@ -388,6 +392,8 @@ def main(argv): assert _value in ('0', '1'), f'`-s` must be followed by `0` or `1`, not {_value=}.' env_extra['PYMUPDF_SETUP_PY_LIMITED_API'] = _value + elif arg == '--show-args': + show_args = 1 elif arg == '--sync-paths': sync_paths = True @@ -439,6 +445,12 @@ def main(argv): print(__doc__) return + if show_args: + print(f'sys.argv ({len(sys.argv)}):') + for arg in sys.argv: + print(f' {arg!r}') + return + if os_names: if platform.system().lower() not in os_names: log(f'Not running because {platform.system().lower()=} not in {os_names=}') From 5ddd01209a4922c82058ca9e102483f5fd23c2d8 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Fri, 6 Jun 2025 11:44:58 +0100 Subject: [PATCH 2/5] .github/workflows/test_pyodide.yml: fix breakage, and test with different mupdf's. * Use scripts/test.py directly. * Use .yml matrix to build different pyodide wheels without duplication of .yml code. * Build with default hard-coded mupdf, mupdf master and mupdf release branch. --- .github/workflows/test_pyodide.yml | 56 ++++++++++-------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/.github/workflows/test_pyodide.yml b/.github/workflows/test_pyodide.yml index ab8b652b0..24c2adb6f 100644 --- a/.github/workflows/test_pyodide.yml +++ b/.github/workflows/test_pyodide.yml @@ -1,57 +1,39 @@ name: Build Pyodide wheel +# Builds pyodide wheels. + on: workflow_dispatch: - inputs: - PYMUPDF_SETUP_MUPDF_BUILD: - description: 'Value for PYMUPDF_SETUP_MUPDF_BUILD, e.g.: git:--branch master https://github.com/ArtifexSoftware/mupdf.git' - type: string - #default: 'git:--branch master https://github.com/ArtifexSoftware/mupdf.git' - default: '-' - PYMUPDF_SETUP_PY_LIMITED_API: - type: string - default: '1' - schedule: - cron: '13 5 * * *' jobs: - build_pyodide: - - name: Build pyodide wheel + pyodide: + name: pyodide runs-on: ubuntu-latest - strategy: matrix: - # Python version needs to match emsdk. - python-version: ["3.12"] - - # Avoid cancelling of all runs after a single failure. + args: [ + '', + '-m "git:--branch master https://github.com/ArtifexSoftware/mupdf"', + '-m "git:--branch 1.26.x https://github.com/ArtifexSoftware/mupdf"', + ] fail-fast: false steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} - - - name: build_pyodide_wheel - env: - inputs_sdist: 0 - inputs_PYMUPDF_SETUP_MUPDF_BUILD: ${{inputs.PYMUPDF_SETUP_MUPDF_BUILD}} - PYMUPDF_SETUP_PY_LIMITED_API: ${{inputs.PYMUPDF_SETUP_PY_LIMITED_API}} - inputs_wheels_default: 0 - inputs_wheels_linux_pyodide: 1 + python-version: 3.12 + + - name: pyodide run: - python scripts/gh_release.py build - - - # Upload generated wheels, to be accessible from github Actions page. - # - - uses: actions/upload-artifact@v4 - with: - path: ./wheelhouse/*.whl + python scripts/test.py ${{matrix.args}} pyodide + + # We do not use upload-artifact@v4 because it fails due to us creating + # identically-named wheels. + #- uses: actions/upload-artifact@v4 + # with: + # path: ./wheelhouse/*.whl From b1ba7ce4d21dacafd7e7511fd6181d4a1611d95c Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Fri, 6 Jun 2025 14:44:51 +0100 Subject: [PATCH 3/5] scripts/test.py: fix spurious test failures with valgrind. Running under valgrind with --trace-children=yes results in extra output that breaks some tests. --- scripts/test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/test.py b/scripts/test.py index 31bcb7a3d..db95cd2e5 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -952,7 +952,7 @@ def getmtime(path): command += ( f' valgrind' f' --suppressions={pymupdf_dir_abs}/valgrind.supp' - f' --trace-children=yes' + f' --trace-children=no' f' --num-callers=20' f' --error-exitcode=100' f' --errors-for-leak-kinds=none' @@ -964,7 +964,7 @@ def getmtime(path): command = ( f' valgrind' f' --tool=helgrind' - f' --trace-children=yes' + f' --trace-children=no' f' --num-callers=20' f' --error-exitcode=100' f' --fullpath-after=' From d5ea841e1aab3a08bbe22083700e9f1bc0c1f7a0 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Fri, 6 Jun 2025 15:15:35 +0100 Subject: [PATCH 4/5] .github/workflows/test-valgrind.yml: test different mupdf's - default, master, release branch. --- .github/workflows/test-valgrind.yml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-valgrind.yml b/.github/workflows/test-valgrind.yml index 3ebea9439..41a61a775 100644 --- a/.github/workflows/test-valgrind.yml +++ b/.github/workflows/test-valgrind.yml @@ -1,29 +1,27 @@ name: Test valgrind on: + workflow_dispatch: schedule: - cron: '13 6 * * *' - workflow_dispatch: - inputs: - scripts_test_options: - description: 'Extra options for scripts/test.py.' jobs: valgrind: - name: Test valgrind - runs-on: ${{ matrix.os }} + name: valgrind + runs-on: ubuntu-latest strategy: matrix: - os: [ubuntu-latest] - + args: [ + '', + '-m "git:--branch master https://github.com/ArtifexSoftware/mupdf"', + '-m "git:--branch 1.26.x https://github.com/ArtifexSoftware/mupdf"', + ] + fail-fast: false + steps: - - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - - - name: test_mupdf-master-branch - env: - PYMUDF_SCRIPTS_TEST_options: ${{inputs.scripts_test_options}} + - name: valgrind run: - python scripts/test.py -m 'git:--recursive --depth 1 --shallow-submodules --branch master https://github.com/ArtifexSoftware/mupdf.git' -P 1 --valgrind 1 buildtest + python scripts/test.py ${{matrix.args}} -P 1 --valgrind 1 build test From e7c3bb9edcea8076b744efec8f02780a105d169d Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Fri, 6 Jun 2025 16:26:28 +0100 Subject: [PATCH 5/5] scripts/test.py: fix pytest test directory when using hard-coded mupdf on Windows. We need to specify PyMuPDF's `tests/` subdirectory, otherwise pytest can recurse into downloaded mupdf and get confused. --- scripts/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test.py b/scripts/test.py index db95cd2e5..32e5da997 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -917,7 +917,7 @@ def getmtime(path): for test_name in test_names: pytest_arg += f' {pymupdf_dir_rel}/{test_name}' else: - pytest_arg += f' {pymupdf_dir_rel}' + pytest_arg += f' {pymupdf_dir_rel}/tests' python = gh_release.relpath(sys.executable) log('Running tests with tests/run_compound.py and pytest.')