|
3 | 3 | # vi: set ft=python sts=4 ts=4 sw=4 et:
|
4 | 4 | """Tests for the engine workflows module
|
5 | 5 | """
|
| 6 | +from glob import glob |
6 | 7 | import os
|
7 | 8 | from shutil import rmtree
|
8 | 9 | from itertools import product
|
@@ -229,3 +230,46 @@ def pick_first(l):
|
229 | 230 | assert os.path.exists(
|
230 | 231 | os.path.join(wf.base_dir, wf.name, n4.name,
|
231 | 232 | 'file1.txt')) is keep_inputs
|
| 233 | + |
| 234 | + |
| 235 | +def _test_function4(): |
| 236 | + raise FileNotFoundError('Generic error') |
| 237 | + |
| 238 | + |
| 239 | +def test_config_setting(tmpdir): |
| 240 | + tmpdir.chdir() |
| 241 | + wf = pe.Workflow('config') |
| 242 | + wf.base_dir = os.getcwd() |
| 243 | + |
| 244 | + crashdir = os.path.join(os.getcwd(), 'crashdir') |
| 245 | + os.mkdir(crashdir) |
| 246 | + wf.config = {"execution": {"crashdump_dir": crashdir}} |
| 247 | + |
| 248 | + n1 = pe.Node(niu.Function(function=_test_function4), |
| 249 | + name='errorfunc') |
| 250 | + wf.add_nodes([n1]) |
| 251 | + try: |
| 252 | + wf.run() |
| 253 | + except RuntimeError: |
| 254 | + pass |
| 255 | + |
| 256 | + fl = glob(os.path.join(crashdir, 'crash*')) |
| 257 | + assert len(fl) == 1 |
| 258 | + |
| 259 | + # Now test node overwrite |
| 260 | + crashdir2 = os.path.join(os.getcwd(), 'crashdir2') |
| 261 | + os.mkdir(crashdir2) |
| 262 | + crashdir3 = os.path.join(os.getcwd(), 'crashdir3') |
| 263 | + os.mkdir(crashdir3) |
| 264 | + wf.config = {"execution": {"crashdump_dir": crashdir3}} |
| 265 | + n1.config = {"execution": {"crashdump_dir": crashdir2}} |
| 266 | + |
| 267 | + try: |
| 268 | + wf.run() |
| 269 | + except RuntimeError: |
| 270 | + pass |
| 271 | + |
| 272 | + fl = glob(os.path.join(crashdir2, 'crash*')) |
| 273 | + assert len(fl) == 1 |
| 274 | + fl = glob(os.path.join(crashdir3, 'crash*')) |
| 275 | + assert len(fl) == 0 |
0 commit comments