mirror of
https://github.com/YosysHQ/sby.git
synced 2026-07-30 16:14:01 +00:00
fix: reject Windows drive path task conflicts
This commit is contained in:
parent
fea6e467d0
commit
0358e6188a
4 changed files with 73 additions and 0 deletions
|
|
@ -224,6 +224,16 @@ def read_sbyconfig(sbydata, taskname):
|
|||
found_task_tag = False
|
||||
task_skip_line = False
|
||||
|
||||
windows_drive_path = re.match(r"^([A-Za-z]):[\\/]", line)
|
||||
if windows_drive_path and windows_drive_path.group(1) in task_tags_all:
|
||||
drive = windows_drive_path.group(1)
|
||||
print(
|
||||
f'ERROR: Task or group name "{drive}" conflicts with Windows path "{line}". '
|
||||
"Rename the task or group.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
for t in task_tags_all:
|
||||
if line.startswith(t+":"):
|
||||
line = line[len(t)+1:].lstrip()
|
||||
|
|
|
|||
57
tests/config_parser/windows_drive_task_names.py
Normal file
57
tests/config_parser/windows_drive_task_names.py
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def run_sby(sby_main, config):
|
||||
return subprocess.run(
|
||||
[sys.executable, sby_main, "--dumptasks"],
|
||||
input=config,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
|
||||
def expect_drive_conflict(sby_main, tasks, drive_path):
|
||||
result = run_sby(
|
||||
sby_main,
|
||||
f"""[tasks]
|
||||
{tasks}
|
||||
|
||||
[options]
|
||||
mode prep
|
||||
|
||||
[files]
|
||||
{drive_path}
|
||||
""",
|
||||
)
|
||||
|
||||
drive = drive_path[0]
|
||||
expected = (
|
||||
f'ERROR: Task or group name "{drive}" conflicts with Windows path '
|
||||
f'"{drive_path}". Rename the task or group.'
|
||||
)
|
||||
assert result.returncode == 1, result
|
||||
assert expected in result.stderr, result.stderr
|
||||
|
||||
|
||||
def main():
|
||||
sby_main = sys.argv[1]
|
||||
|
||||
expect_drive_conflict(sby_main, "C", r"C:\src\example.sv")
|
||||
expect_drive_conflict(sby_main, "task D", "D:/src/example.sv")
|
||||
|
||||
result = run_sby(
|
||||
sby_main,
|
||||
"""[tasks]
|
||||
C
|
||||
|
||||
[options]
|
||||
C: mode prep
|
||||
""",
|
||||
)
|
||||
assert result.returncode == 0, result
|
||||
assert "C" in result.stdout.splitlines(), result.stdout
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
2
tests/config_parser/windows_drive_task_names.sby
Normal file
2
tests/config_parser/windows_drive_task_names.sby
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[options]
|
||||
mode prep
|
||||
4
tests/config_parser/windows_drive_task_names.sh
Normal file
4
tests/config_parser/windows_drive_task_names.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
python3 windows_drive_task_names.py "$SBY_MAIN"
|
||||
Loading…
Add table
Add a link
Reference in a new issue