|
30 | 30 | _DEFAULT_MANIFEST: str = os.path.join(_DEFINITION_DIRECTORY, "manifest.yaml") |
31 | 31 | # Where can we expect to find test data? |
32 | 32 | _DATA_DIRECTORY: str = "data" |
| 33 | +_DATA_DIRECTORY_PATH: str = f"{_DATA_DIRECTORY}/" |
33 | 34 |
|
34 | 35 | # Our yamllint configuration file |
35 | 36 | # from the same directory as us. |
@@ -346,16 +347,14 @@ def _copy_inputs(test_inputs: List[str], project_path: str) -> bool: |
346 | 347 | """Copies all the test files into the test project directory.""" |
347 | 348 |
|
348 | 349 | # The files are assumed to reside in the repo's 'data' directory. |
349 | | - print(f'# Copying inputs (from "${{PWD}}/{_DATA_DIRECTORY}")...') |
350 | | - |
351 | | - expected_prefix: str = f"{_DATA_DIRECTORY}/" |
| 350 | + print(f'# Copying inputs (from "${{PWD}}/{_DATA_DIRECTORY_PATH}")...') |
352 | 351 | for test_input in test_inputs: |
353 | 352 |
|
354 | 353 | print(f"# + {test_input}") |
355 | 354 |
|
356 | | - if not test_input.startswith(expected_prefix): |
| 355 | + if not test_input.startswith(_DATA_DIRECTORY_PATH): |
357 | 356 | print("! FAILURE") |
358 | | - print(f'! Input file {test_input} must start with "{expected_prefix}"') |
| 357 | + print(f'! Input file {test_input} must start with "{_DATA_DIRECTORY_PATH}"') |
359 | 358 | return False |
360 | 359 | if not os.path.isfile(test_input): |
361 | 360 | print("! FAILURE") |
@@ -663,12 +662,23 @@ def _run_a_test( |
663 | 662 | == "molecules" |
664 | 663 | ): |
665 | 664 | value = job_definition.tests[job_test_name].inputs[variable] |
666 | | - job_variables[variable] = value |
667 | 665 | prefix = _get_test_input_url_prefix(value) |
668 | 666 | if prefix: |
669 | | - # There's a prefix so it's a file (not a molecule string) |
670 | | - # The input file for "file://one.sdf" is the basename "one.sdf" |
671 | | - input_files.append(value[len(prefix) :]) |
| 667 | + # There's a prefix so it's a file (not a molecule string). |
| 668 | + # The input file is expected to be something like |
| 669 | + # "file://data/one.sdf". In this case |
| 670 | + # the input file list is extended with the value "data/one.sdf" |
| 671 | + # and the variable (passed to the test) becomes "file://one.sdf" |
| 672 | + file_path_and_name: str = value[len(prefix) :] |
| 673 | + input_files.append(file_path_and_name) |
| 674 | + data_relative_file = file_path_and_name |
| 675 | + if file_path_and_name.startswith(_DATA_DIRECTORY_PATH): |
| 676 | + data_relative_file = file_path_and_name[ |
| 677 | + len(_DATA_DIRECTORY_PATH) : |
| 678 | + ] |
| 679 | + job_variables[variable] = f"{prefix}{data_relative_file}" |
| 680 | + else: |
| 681 | + job_variables[variable] = value |
672 | 682 | else: |
673 | 683 | # It is an input (not an option). |
674 | 684 | # The input is a list if it's declared as 'multiple'. |
|
0 commit comments