Skip to content

Commit 707bd01

Browse files
author
Alan Christie
committed
Now checks CWD (for yamllint and data-manager)
Now an error to have no tests pass Doc tweak
1 parent f1473c6 commit 707bd01

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

README.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,22 @@ Data Manager Job implementation repositories against the Job's
66
container image.
77

88
Job implementations are required to provide a Job Definition (in the
9-
Job repository's ``data-manager`` directory) and at least one test, located in
10-
the repository's ``data-manager/tests`` directory. ``jote`` runs the tests
9+
Job repository's ``data-manager`` directory). The Job Definition should define
10+
at least one test for every Job in the file. ``jote`` runs the tests
1111
but also ensures the repository structure meets the Data Manager requirements.
1212

13-
Tests are dined in the Job definition file in the block where the the test
14-
is defined. Here's a snippet illustrating a test called ``simple-execution``
15-
that defines an input option defining a file and some other command
16-
options along with a ``checks`` section that defines the exit criteria
17-
of a successful test::
13+
Tests are defined in the Job definition file. Here's a snippet illustrating a
14+
Job (``max-min-picker``) with a test called ``simple-execution``.
15+
16+
The test defines an input option (a file) and some other command options.
17+
The ``checks`` section defines the exit criteria of a successful test.
18+
In this case the container must exit with code ``0`` and the file
19+
``diverse.smi`` must be found (in the mounted project directory), i.e
20+
it must *exist* and contain ``100`` lines::
1821

1922
jobs:
2023
[...]
21-
shard:
24+
max-min-picker:
2225
[...]
2326
tests:
2427
simple-execution:

jote/jote.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
6283
def _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

Comments
 (0)