Skip to content

Commit 4a8b4aa

Browse files
author
Alan Christie
committed
Jote now injects a value for CODE_DIRECTORY
1 parent bea9de5 commit 4a8b4aa

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

README.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ You can display the utility's help with::
6060

6161
jote --help
6262

63+
Built-in variables
64+
------------------
65+
66+
Job definition command-expansion relies on a number of *built in* variables.
67+
Some are provided by the Data Manager when the Job runs under its control
68+
(i.e. ``DM_INSTANCE_DIRECTORY``) others are built-in to ``jote``.
69+
70+
The set of variables injected into the command expansion by ``jote``
71+
are: -
72+
73+
- ``DM_INSTANCE_DIRECTORY``. Set to the path of the simulated instance
74+
directory created by ``jote``
75+
- ``CODE_DIRECTORY``. Set to the root of the repository clone under test
76+
6377
Ignoring tests
6478
--------------
6579

src/jote/compose.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,13 @@ def run(self, timeout_minutes: int = DEFAULT_TEST_TIMEOUT_M)\
183183
A non-zero exit code does not necessarily mean the test has failed.
184184
"""
185185

186+
execution_directory: str = self.get_test_path()
187+
186188
print('# Executing the test ("docker-compose up")...')
189+
print(f'# Execution directory is "{execution_directory}"')
187190

188191
cwd = os.getcwd()
189-
os.chdir(self.get_test_path())
192+
os.chdir(execution_directory)
190193

191194
try:
192195
# Run the container

src/jote/jote.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ def _run_nextflow(command: str,
322322
print('! You cannot test Jobs and have your own config file')
323323
return 1, '', ''
324324

325+
print('# Executing the test ("nextflow")...')
326+
print(f'# Execution directory is "{project_path}"')
327+
325328
cwd = os.getcwd()
326329
os.chdir(project_path)
327330

@@ -479,9 +482,13 @@ def _test(args: argparse.Namespace,
479482
decoded_command: str = ''
480483
if test_status:
481484

482-
# Job variables must contain 'built-in' variables: -
485+
# Jote injects Job variables that are expected.
486+
# 'DM_' variables are injected by the Data Manager,
487+
# other are injected by Jote.
483488
# - DM_INSTANCE_DIRECTORY
484489
job_variables['DM_INSTANCE_DIRECTORY'] = INSTANCE_DIRECTORY
490+
# - CODE_DIRECTORY
491+
job_variables['CODE_DIRECTORY'] = os.getcwd()
485492

486493
# Get the raw (encoded) command from the job definition...
487494
raw_command: str = job_definition.command

0 commit comments

Comments
 (0)