Skip to content

Commit

Permalink
make_test_list.py: Parse the version out of Makefile.envs
Browse files Browse the repository at this point in the history
This fixes `make_test_list.py` so it can be run with any version of Python as
opposed to having to match the Python version Pyodide uses.
  • Loading branch information
hoodmane committed Nov 8, 2024
1 parent a5386c8 commit bb3d600
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/tests/make_test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,41 @@

import os
from pathlib import Path
from sys import version
from typing import Any
import subprocess

import ruamel.yaml

yaml = ruamel.yaml.YAML()
PYODIDE_ROOT = Path(__file__).parents[2]
LIB_DIR = PYODIDE_ROOT / "cpython/build" f"/Python-{version.split(' ')[0]}" f"/Lib/"

PYTHON_TESTS_YAML = Path(__file__).parent / "python_tests.yaml"


def get_makefile_envs():
result = subprocess.run(
["make", "-f", str(PYODIDE_ROOT / "Makefile.envs"), ".output_vars"],
capture_output=True,
text=True,
env={"PYODIDE_ROOT": str(PYODIDE_ROOT)},
)

if result.returncode != 0:
logger.error("ERROR: Failed to load environment variables from Makefile.envs")
exit_with_stdio(result)

environment = {}
for line in result.stdout.splitlines():
equalPos = line.find("=")
if equalPos != -1:
varname = line[0:equalPos]

value = line[equalPos + 1 :]
value = value.strip("'").strip()
environment[varname] = value

return environment


def get_old_yaml():
try:
with open(PYTHON_TESTS_YAML) as fp:
Expand Down Expand Up @@ -69,6 +92,8 @@ def update_tests(doc_group, tests):

if __name__ == "__main__":
doc = get_old_yaml()
version = get_makefile_envs()["PYVERSION"]
LIB_DIR = PYODIDE_ROOT / "cpython/build" f"/Python-{version}/Lib/"
update_tests(doc, collect_tests(LIB_DIR / "test"))

yaml.dump(doc, PYTHON_TESTS_YAML)

0 comments on commit bb3d600

Please sign in to comment.