From 6f0f2645c21b3c3ce36ea08dcbc1b5df3248bd52 Mon Sep 17 00:00:00 2001
From: Jannis Harder <me@jix.one>
Date: Fri, 19 Jan 2024 14:51:16 +0100
Subject: [PATCH] tests: Support testing an installed SBY using the SBY_CMD
 make variable

---
 tests/Makefile        | 5 +++++
 tests/make/run_sby.py | 4 ++++
 2 files changed, 9 insertions(+)
 create mode 100644 tests/make/run_sby.py

diff --git a/tests/Makefile b/tests/Makefile
index 805d190..6a586b6 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -18,7 +18,12 @@ help:
 
 export SBY_WORKDIR_GITIGNORE := 1
 
+ifeq ($(SBY_CMD),)
 SBY_MAIN := $(realpath $(dir $(firstword $(MAKEFILE_LIST)))/../sbysrc/sby.py)
+else
+SBY_MAIN := $(realpath $(dir $(firstword $(MAKEFILE_LIST)))/make/run_sby.py)
+endif
+
 ifeq (nt-unix-like,$(OS_NAME))
 SBY_MAIN := $(shell cygpath -w $(SBY_MAIN))
 endif
diff --git a/tests/make/run_sby.py b/tests/make/run_sby.py
new file mode 100644
index 0000000..9fb7de4
--- /dev/null
+++ b/tests/make/run_sby.py
@@ -0,0 +1,4 @@
+import os
+import sys
+prog = os.environ.get("SBY_CMD", "sby")
+os.execvp(prog, [prog, *sys.argv[1:]])