diff --git a/labgrid/run/run.py b/labgrid/run/run.py index aed999019d14627f0f2a84fea80d4becf272c2a4..fcbb4ba5b7ac9ffe15340b2920fca7d5b84f36a7 100644 --- a/labgrid/run/run.py +++ b/labgrid/run/run.py @@ -322,15 +322,15 @@ def run( stderr.write(f"{line}{linesep}") # Copy the files back from the target - if code == 0: - for unresolved in get: - resolved = unresolved.resolve(temp) - # FIXME: Check if file exists with `@ape//ape:test` instead of assuming any error is due to a missing file - try: - transfer.get(resolved.remote, resolved.local) - except ExecutionError as e: - if not resolved.optional: - raise e + + for unresolved in get: + resolved = unresolved.resolve(temp) + # FIXME: Check if file exists with `@ape//ape:test` instead of assuming any error is due to a missing file + try: + transfer.get(resolved.remote, resolved.local) + except ExecutionError as e: + if not resolved.optional and code == 0: + raise e return code