|
19 | 19 | import ramble.pipeline |
20 | 20 | import ramble.workspace |
21 | 21 | from ramble.error import RambleCommandError |
22 | | -from ramble.main import RambleCommand |
| 22 | +from ramble.main import RambleCommand, main |
23 | 23 | from ramble.namespace import namespace |
24 | 24 | from ramble.test.dry_run_helpers import search_files_for_string |
25 | 25 | from ramble.util import constants |
@@ -1053,6 +1053,40 @@ def test_edit_override_gets_correct_path(): |
1053 | 1053 | assert output == config_path |
1054 | 1054 |
|
1055 | 1055 |
|
| 1056 | +def test_edit_with_faulty_config(workspace_name, capsys): |
| 1057 | + """Tests that `ramble workspace edit` works with a faulty config.""" |
| 1058 | + bad_config = """ |
| 1059 | +ramble # Missing colon! |
| 1060 | + variables: |
| 1061 | + mpi_command: 'mpirun -n {n_ranks} -ppn {processes_per_node}' |
| 1062 | + batch_submit: 'batch_submit {execute_experiment}' |
| 1063 | + processes_per_node: 1 |
| 1064 | + n_nodes: 1 |
| 1065 | + applications: |
| 1066 | + basic: |
| 1067 | + workloads: |
| 1068 | + test_wl: |
| 1069 | + experiments: |
| 1070 | + test_experiment: {} |
| 1071 | +""" |
| 1072 | + try: |
| 1073 | + ws = ramble.workspace.create(workspace_name) |
| 1074 | + ws.write() |
| 1075 | + |
| 1076 | + config_path = os.path.join(ws.config_dir, ramble.workspace.config_file_name) |
| 1077 | + with open(config_path, "w") as f: |
| 1078 | + f.write(bad_config) |
| 1079 | + |
| 1080 | + argv = ["-w", workspace_name, "workspace", "edit", "-c", "-p"] |
| 1081 | + # Use main instead of RambleCommand, as this tests the error handling |
| 1082 | + # only in the former. |
| 1083 | + main(argv) |
| 1084 | + captured = capsys.readouterr() |
| 1085 | + assert config_path in captured.out |
| 1086 | + finally: |
| 1087 | + main(["-w", workspace_name, "workspace", "remove", "-y"]) |
| 1088 | + |
| 1089 | + |
1056 | 1090 | def test_dryrun_setup(workspace_name): |
1057 | 1091 | test_config = """ |
1058 | 1092 | ramble: |
|
0 commit comments