@@ -109,6 +109,7 @@ def wrapper(*args: str, **kwargs: Any) -> Any:
109109 return _extended_submission_test
110110
111111
112+
112113def run_tests () -> None :
113114 """
114115 Must be called by the test script to execute all tests.
@@ -136,7 +137,7 @@ def run_tests() -> None:
136137 if not isinstance (ret , bool ):
137138 raise RefUtilsError ("Function with the @environment_test decorator must return a bool" )
138139 task_passed &= ret
139- all_tests_passed = False
140+ all_tests_passed &= ret
140141
141142 #Do not run submission tests if the environ is invalid
142143 if not task_passed :
@@ -150,7 +151,15 @@ def run_tests() -> None:
150151
151152 print_ok ('[+] Testing submission...' )
152153 if tests .submission_test :
153- ret = tests .submission_test ()
154+ try :
155+ ret = tests .submission_test ()
156+ except RefUtilsError as e :
157+ print_err (str (e ))
158+ ret = False
159+ except KeyboardInterrupt :
160+ print_err ('[-] Keyboard Interrupt' )
161+ ret = False
162+
154163 if isinstance (ret , bool ):
155164 ret = _TestResult (task_name , ret , None )
156165 elif isinstance (ret , TestResult ):
@@ -160,14 +169,16 @@ def run_tests() -> None:
160169
161170 task_test_results .append (ret )
162171 task_passed &= ret .success
163- all_tests_passed = False
172+ all_tests_passed &= ret . success
164173 else :
165174 # If there is no test, we consider this to be an success.
166175 task_test_results .append (_TestResult (task_name , True , None ))
167176 print_ok ("[+] No test found" )
168177
169178 if not task_passed and has_multiple_tasks :
170179 # Avoid printing errors twice.
180+ # If this is the only task, i.e., !has_multiple_tasks,
181+ # we will print the error message further below.
171182 print_err ('[!] Task failed!' )
172183 elif task_passed :
173184 print_ok ('[+] Test passed' )
0 commit comments