Skip to content

Commit bcb10b5

Browse files
committed
[remote-run] Clear out %t on the remote machine
Really we ought to clear out "%t*", but running wildcards with 'rm' scares me a little too much for that. This still fixes a handful of tests that were relying on %t being an empty directory. Note that this doesn't interfere with generated files persisting between %target-run invocations; they'll be downloaded and then re-uploaded as long as they're mentioned in the invocation.
1 parent ab04797 commit bcb10b5

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

test/remote-run/custom-options.test-sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ RUN: %utils/remote-run -n --remote-dir /xyz-REMOTE -o FIRST_OPT -o SECOND_OPT --
33
CHECK: /usr/bin/ssh -n
44
CHECK-DAG: -p 12345
55
CHECK-DAG: -o FIRST_OPT -o SECOND_OPT
6+
CHECK-SAME: some_user@some_host -- '/usr/bin/env' '/bin/rm' '-rf' '{{.+}}-REMOTE/output'
7+
8+
CHECK-NEXT: /usr/bin/ssh -n
9+
CHECK-DAG: -p 12345
10+
CHECK-DAG: -o FIRST_OPT -o SECOND_OPT
611
CHECK-SAME: some_user@some_host -- '/usr/bin/env' '/bin/mkdir' '-p' '{{.+}}-REMOTE/output/nested'
712

813
CHECK-NEXT: /usr/bin/sftp

test/remote-run/identity.test-sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ RUN: %utils/remote-run -n --remote-dir /xyz-REMOTE -i spiderman --output-prefix
33
CHECK: /usr/bin/ssh -n
44
CHECK-DAG: -p 12345
55
CHECK-DAG: -i spiderman
6+
CHECK-SAME: some_user@some_host -- '/usr/bin/env' '/bin/rm' '-rf' '{{.+}}-REMOTE/output'
7+
8+
CHECK-NEXT: /usr/bin/ssh -n
9+
CHECK-DAG: -p 12345
10+
CHECK-DAG: -i spiderman
611
CHECK-SAME: some_user@some_host -- '/usr/bin/env' '/bin/mkdir' '-p' '{{.+}}-REMOTE/output/nested'
712

813
CHECK-NEXT: /usr/bin/sftp

utils/remote-run

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CommandRunner(object):
2828

2929
@staticmethod
3030
def _dirnames(files):
31-
return list(set(os.path.dirname(f) for f in files))
31+
return sorted(set(os.path.dirname(f) for f in files))
3232

3333
def popen(self, command, **kwargs):
3434
if self.verbose:
@@ -195,23 +195,32 @@ def main():
195195
runner.dry_run = args.dry_run
196196
runner.verbose = args.verbose or args.dry_run
197197

198+
assert not args.remote_dir == '/'
199+
198200
upload_files = dict()
199201
download_files = dict()
202+
remote_test_specific_dir = None
200203
if args.input_prefix:
204+
assert not args.remote_input_prefix.startswith("..")
201205
remote_dir = os.path.join(args.remote_dir, args.remote_input_prefix)
202206
input_files = find_transfers(args.command, args.input_prefix,
203207
remote_dir)
204208
assert not any(upload_files.has_key(f) for f in input_files)
205209
upload_files.update(input_files)
206210
if args.output_prefix:
211+
assert not args.remote_output_prefix.startswith("..")
207212
remote_dir = os.path.join(args.remote_dir, args.remote_output_prefix)
208213
test_files = find_transfers(args.command, args.output_prefix,
209214
remote_dir)
210215
assert not any(upload_files.has_key(f) for f in test_files)
211216
upload_files.update(test_files)
212217
assert not any(download_files.has_key(f) for f in test_files)
213218
download_files.update(test_files)
219+
remote_test_specific_dir = remote_dir
214220

221+
if remote_test_specific_dir:
222+
assert remote_test_specific_dir.startswith(args.remote_dir)
223+
runner.run_remote(['/bin/rm', '-rf', remote_test_specific_dir])
215224
if upload_files:
216225
runner.send(upload_files)
217226

0 commit comments

Comments
 (0)