Skip to content

Commit 167deb1

Browse files
committed
feat: check that script is being run in root of repo
I found that if you run the script from another folder, things react unexpectedly. So it seems like a good idea to double-check.
1 parent 9725c40 commit 167deb1

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

setup/01-manual_testing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import os
22
import sys
33
import re
4-
from setup.static import LOGIN_ROBOT_FILE
4+
from setup.static import LOGIN_ROBOT_FILE, check_running_in_root
5+
56

67
def check_file_exists():
78
if not os.path.isfile(LOGIN_ROBOT_FILE):
@@ -57,6 +58,7 @@ def check_content():
5758
sys.exit(1)
5859

5960
def main():
61+
check_running_in_root()
6062
check_file_exists()
6163
check_content()
6264

setup/static.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import os
2+
import sys
3+
24
ROBOT_ROOT_PATH = os.path.abspath(os.path.join(".", "robot"))
35
LOGIN_ROBOT_FILE = os.path.abspath(os.path.join(ROBOT_ROOT_PATH, "login.robot"))
46
INVALID_LOGIN_ROBOT = os.path.abspath(os.path.join(ROBOT_ROOT_PATH, "invalid_login.robot"))
@@ -8,5 +10,20 @@
810
else:
911
CURRENT_ENV["PYTHONPATH"] = f"setup{os.pathsep}"
1012

13+
1114
def normalize(keyword):
12-
return keyword.strip().title()
15+
return keyword.strip().title()
16+
17+
18+
def check_running_in_root():
19+
current_folder = os.getcwd()
20+
supposed_exercises_folder = os.path.abspath(os.path.join(current_folder, "exercises"))
21+
supposed_setup_folder = os.path.abspath(os.path.join(current_folder, "setup"))
22+
23+
in_root = os.path.isdir(supposed_exercises_folder) and os.path.isdir(supposed_setup_folder)
24+
if not in_root:
25+
print(f"🚩 Hmm. It looks like the script is running in '{current_folder}' instead of the repo root folder.")
26+
print("For the verification to work correctly, you need to run the script from the root of the repository ("
27+
"probably named 'rf-katas').")
28+
print("Try again, but double-check that you're running the verify script from the repository root.")
29+
sys.exit(1)

0 commit comments

Comments
 (0)