@@ -59,6 +59,27 @@ def _lint(definition_file: str) -> bool:
5959 return True
6060
6161
62+ def _check_cwd () -> bool :
63+ """Checks the execution directory for sanity (cwd). Here we must find
64+ a .yamllint file and a data-manager directory?
65+ """
66+ expected_files : List [str ] = [_YAMLLINT_FILE ]
67+ for expected_file in expected_files :
68+ if not os .path .isfile (expected_file ):
69+ print (f'! Expected file "{ expected_file } "'
70+ ' but it is not here' )
71+ return False
72+
73+ expected_directories : List [str ] = [_DEFINITION_DIRECTORY ]
74+ for expected_directory in expected_directories :
75+ if not os .path .isdir (expected_directory ):
76+ print (f'! Expected directory "{ expected_directory } "'
77+ ' but it is not here' )
78+ return False
79+
80+ return True
81+
82+
6283def _load (skip_lint : bool = False ) -> Tuple [List [DefaultMunch ], int ]:
6384 """Loads definition files (all the YAML files in a given directory)
6485 and extracts the definitions that contain at least one test.
@@ -373,6 +394,12 @@ def main() -> None:
373394 # Args are OK if we get here.
374395 test_fail_count : int = 0
375396
397+ # Check CWD
398+ if not _check_cwd ():
399+ print ('! FAILURE' )
400+ print ('! The directory does not look correct' )
401+ arg_parser .error ('Done (FAILURE)' )
402+
376403 # Load all the files we can and then run the tests.
377404 job_definitions , num_tests = _load (args .skip_lint )
378405 if num_tests < 0 :
@@ -417,15 +444,19 @@ def main() -> None:
417444 break
418445
419446 # Success or failure?
447+ # It's an error to find no tests.
420448 print (' ---' )
421449 num_tests_passed : int = num_tests - test_fail_count
422450 dry_run : str = '[DRY RUN]' if args .dry_run else ''
423451 if test_fail_count :
424- print ()
425452 arg_parser .error ('Done (FAILURE)'
426453 f' passed={ num_tests_passed } '
427454 f' failed={ test_fail_count } '
428455 f' { dry_run } ' )
456+ elif num_tests_passed == 0 :
457+ arg_parser .error ('Done (FAILURE)'
458+ f' passed={ num_tests_passed } '
459+ f' (at least one test must pass) { dry_run } ' )
429460 else :
430461 print (f'Done (OK) passed={ num_tests_passed } { dry_run } ' )
431462
0 commit comments