diff --git a/.gitattributes b/.gitattributes index 27d14cb..418e35c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ *m4n100k0p100t3000_cr_lf.inp -text +*.test text eol=lf diff --git a/.github/workflows/moocore.yml b/.github/workflows/moocore.yml index 0387791..046073a 100644 --- a/.github/workflows/moocore.yml +++ b/.github/workflows/moocore.yml @@ -101,3 +101,38 @@ jobs: name: failed-tests-${{ matrix.os }}-${{ matrix.cc }}-${{ github.run_id }} path: failed-test-outputs/ if-no-files-found: ignore + + test-windows: + name: Run testsuite on Windows (MSYS2) + runs-on: windows-latest + env: + PYTHONIOENCODING: utf-8 + defaults: + run: + shell: msys2 {0} + + steps: + - name: Checkout moocore + uses: actions/checkout@v6 + with: + repository: multi-objective/moocore + sparse-checkout: c + + - name: Checkout testsuite + uses: actions/checkout@v6 + with: + path: testsuite + + - uses: msys2/setup-msys2@v2 + with: + msystem: UCRT64 + install: >- + make + xz + mingw-w64-ucrt-x86_64-gcc + mingw-w64-ucrt-x86_64-python + mingw-w64-ucrt-x86_64-python-joblib + mingw-w64-ucrt-x86_64-python-rich + + - name: make test (DEBUG=1, -O3 -flto) + run: make -C c test OPT_CFLAGS="-O3 -flto" diff --git a/regtest.py b/regtest.py index 5b2bb05..7692291 100755 --- a/regtest.py +++ b/regtest.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import os +import pathlib import subprocess import sys import glob @@ -121,9 +122,18 @@ def runcmd(command, cwd=None, env=None, outfile=subprocess.DEVNULL): full_env["ASAN_OPTIONS"] = ASAN_OPTIONS full_env["UBSAN_OPTIONS"] = UBSAN_OPTIONS stdout = outfile if outfile == subprocess.DEVNULL else subprocess.PIPE + bash = "bash" + if os.name == "nt": + msys_bash = ( + pathlib.Path(sys.executable).parent.parent.parent + / "usr" + / "bin" + / "bash.exe" + ) + if msys_bash.is_file(): + bash = str(msys_bash) result = subprocess.run( - command, - shell=True, + [bash, "-c", command], env=full_env, check=False, cwd=cwd, @@ -194,7 +204,13 @@ def main(): print("\t for example:", sys.argv[0], "../bin/hv") sys.exit(1) - program = os.path.realpath(os.path.expanduser(sys.argv[1])) + program = pathlib.Path(os.path.realpath(os.path.expanduser(sys.argv[1]))).as_posix() + if ( + os.name == "nt" + and not os.path.isfile(program) + and os.path.isfile(program + ".exe") + ): + program += ".exe" if not is_exe(program): print(f"error: '{program}' not found or not executable!") sys.exit(1) @@ -214,7 +230,10 @@ def main(): ntotal = len(tests) elapsed_time = time.time() - ok = Parallel(n_jobs=-2)(delayed(run_test)(test, program=program) for test in tests) + prefer = "threads" if os.name == "nt" else "processes" + ok = Parallel(n_jobs=-2, prefer=prefer)( + delayed(run_test)(test, program=program) for test in tests + ) elapsed_time = time.time() - elapsed_time npassed = sum(ok) nfailed = ntotal - npassed