3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-10-09 01:11:58 +00:00

tests/pyosys: print log on failed test, fix make clean

This commit is contained in:
Mohamed Gaber 2025-09-23 08:05:04 +03:00
parent 54799bb8be
commit dc88906c91
No known key found for this signature in database
3 changed files with 29 additions and 20 deletions

View file

@ -2,6 +2,7 @@ name: Build Wheels for PyPI
# run every Sunday at 10 AM
on:
push: # TODO: REMOVE THIS, DO NOT MERGE TO UPSTREAM THIS IS JUST SO I DON'T HAVE TO MANUALLY RUN THE WORKFLOW WITH EVERY PUSH
workflow_dispatch:
schedule:
- cron: "0 10 * * 0"
@ -107,7 +108,7 @@ jobs:
makeFlags='CONFIG=clang'
PATH="$PWD/bison/src:$PATH"
CIBW_BEFORE_BUILD: bash ./.github/workflows/wheels/cibw_before_build.sh
CIBW_TEST_COMMAND: python3 {project}/tests/pyosys/run_tests.py python3
CIBW_TEST_COMMAND: python3 {project}/tests/pyosys/run_tests.py
- uses: actions/upload-artifact@v4
with:
name: python-wheels-${{ matrix.os.runner }}

View file

@ -344,6 +344,8 @@ ifeq ($(ENABLE_LIBYOSYS),1)
TARGETS += libyosys.so
endif
PY_WRAPPER_FILE = pyosys/wrappers
ifeq ($(ENABLE_PYOSYS),1)
# python-config --ldflags includes -l and -L, but LINKFLAGS is only -L
LINKFLAGS += $(filter-out -l%,$(shell $(PYTHON_CONFIG) --ldflags))
@ -353,7 +355,6 @@ PYBIND11_INCLUDE ?= $(shell $(PYTHON_EXECUTABLE) -m pybind11 --includes)
CXXFLAGS += -I$(PYBIND11_INCLUDE) -DWITH_PYTHON
CXXFLAGS += $(shell $(PYTHON_CONFIG) --includes) -DWITH_PYTHON
PY_WRAPPER_FILE = pyosys/wrappers
OBJS += $(PY_WRAPPER_FILE).o
PY_GEN_SCRIPT = pyosys/generator.py
PY_WRAP_INCLUDES := $(shell $(PYTHON_EXECUTABLE) $(PY_GEN_SCRIPT) --print-includes)
@ -1110,9 +1111,9 @@ docs: docs/prep
clean:
rm -rf share
rm -rf kernel/*.pyh
rm -f $(OBJS) $(GENFILES) $(TARGETS) $(EXTRA_TARGETS) $(EXTRA_OBJS) $(PY_WRAP_INCLUDES) $(PY_WRAPPER_FILE).cc
rm -f $(OBJS) $(GENFILES) $(TARGETS) $(EXTRA_TARGETS) $(EXTRA_OBJS) $(PY_WRAP_INCLUDES) $(PY_WRAPPER_FILE).inc.cc $(PY_WRAPPER_FILE).cc
rm -f kernel/version_*.o kernel/version_*.cc
rm -f kernel/python_wrappers.o
rm -f $(PY_WRAPPER_FILE).o
rm -f libs/*/*.d frontends/*/*.d passes/*/*.d backends/*/*.d kernel/*.d techlibs/*/*.d
rm -rf tests/asicworld/*.out tests/asicworld/*.log
rm -rf tests/hana/*.out tests/hana/*.log

View file

@ -1,39 +1,46 @@
from pathlib import Path
import shutil
import subprocess
import sys
import shutil
import shlex
import subprocess
from pathlib import Path
__file_dir__ = Path(__file__).absolute().parent
if len(sys.argv) != 2:
print(f"Usage: {sys.argv[0]} {sys.argv[1]}")
if len(sys.argv) > 2 or len(sys.argv) == 2 and sys.argv[1] != 'yosys':
print(f"Usage: {sys.argv[0]} [yosys]")
exit(64)
binary = []
if sys.argv[1] in ["yosys"]:
binary = [__file_dir__.parents[1] / "yosys", "-Qy"]
if len(sys.argv) == 2:
binary = [str(__file_dir__.parents[1] / "yosys"), "-Qy"]
else:
binary = [sys.argv[1]]
binary = [sys.executable or shutil.which("python3") or "python3"] # sys.executable can actually be None
tests = __file_dir__.glob("test_*.py")
errors = False
log_dir = __file_dir__ / "logs"
try:
shutil.rmtree(log_dir)
except FileNotFoundError:
pass
fail_logs = set()
for test in tests:
print(f"* {test.name} ", end="")
log_dir.mkdir(parents=True, exist_ok=True)
log = log_dir / (test.stem + ".log")
result = subprocess.run([
*binary,
test
], stdout=open(log, "w"), stderr=subprocess.STDOUT)
cmd = [*binary, str(test)]
log_file = open(log, "w", encoding="utf8")
log_file.write(f"$ {shlex.join(cmd)}\n")
log_file.flush()
result = subprocess.run(cmd, stdout=log_file, stderr=subprocess.STDOUT)
if result.returncode == 0:
print("OK!")
else:
print(f"FAILED: {log}")
errors = True
if errors:
fail_logs.add(log)
log_file.close()
for log in fail_logs:
print(f">>> {log}")
with open(log, encoding="utf8") as f:
print(f.read())
if len(fail_logs):
exit(1)