mirror of
https://github.com/YosysHQ/sby.git
synced 2025-07-24 15:18:58 +00:00
tests: Windows fixes
Make tests runnable on Windows, as long as a unix like environment as e.g. provided by MSYS2 is available.
This commit is contained in:
parent
ab98938faa
commit
ea7fc7dc2c
3 changed files with 50 additions and 16 deletions
|
@ -4,7 +4,8 @@ import re
|
|||
tests = []
|
||||
checked_dirs = []
|
||||
|
||||
SAFE_PATH = re.compile(r"^[a-zA-Z0-9_./]*$")
|
||||
SAFE_PATH = re.compile(r"^[a-zA-Z0-9_./\\]*$")
|
||||
|
||||
|
||||
def collect(path):
|
||||
# don't pick up any paths that need escaping nor any sby workdirs
|
||||
|
@ -15,8 +16,6 @@ def collect(path):
|
|||
for entry in path.glob("*.sby"):
|
||||
filename = str(entry)
|
||||
if not SAFE_PATH.match(filename):
|
||||
continue
|
||||
if not re.match(r"^[a-zA-Z0-9_./]*$", filename):
|
||||
print(f"skipping {filename!r}, use only [a-zA-Z0-9_./] in filenames")
|
||||
continue
|
||||
tests.append(entry)
|
||||
|
@ -25,6 +24,10 @@ def collect(path):
|
|||
collect(entry)
|
||||
|
||||
|
||||
def unix_path(path):
|
||||
return "/".join(path.parts)
|
||||
|
||||
|
||||
collect(Path("."))
|
||||
collect(Path("../docs/examples"))
|
||||
|
||||
|
@ -33,16 +36,18 @@ out_file.parent.mkdir(exist_ok=True)
|
|||
|
||||
with out_file.open("w") as output:
|
||||
|
||||
|
||||
for checked_dir in checked_dirs:
|
||||
print(f"{out_file}: {checked_dir}", file=output)
|
||||
|
||||
for test in tests:
|
||||
print(f"make/rules/test/{test}.mk: {test}", file=output)
|
||||
test_unix = unix_path(test)
|
||||
print(f"make/rules/test/{test_unix}.mk: {test_unix}", file=output)
|
||||
for ext in [".sh", ".py"]:
|
||||
script_file = test.parent / (test.stem + ext)
|
||||
if script_file.exists():
|
||||
print(f"make/rules/test/{test}.mk: {script_file}", file=output)
|
||||
print(f"make/rules/test/{test}.mk: make/test_rules.py", file=output)
|
||||
script_file_unix = unix_path(script_file)
|
||||
print(f"make/rules/test/{test_unix}.mk: {script_file_unix}", file=output)
|
||||
print(f"make/rules/test/{test_unix}.mk: make/test_rules.py", file=output)
|
||||
for test in tests:
|
||||
print(f"-include make/rules/test/{test}.mk", file=output)
|
||||
test_unix = unix_path(test)
|
||||
print(f"-include make/rules/test/{test_unix}.mk", file=output)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue