Skip to content

Commit c7d5f03

Browse files
authored
Merge pull request #82503 from etcwilde/ewilde/find-rsync
remote-run: Find rsync
2 parents 4686897 + 12e784c commit c7d5f03

15 files changed

+41
-31
lines changed

test/lit.cfg

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,19 +2522,16 @@ check_runtime_libs(runtime_libs)
25222522

25232523
config.substitutions.append(('%target-objc-interop', run_objc_interop))
25242524

2525-
# For testing the remote-run utility itself, see if we can find an sftp-server
2526-
# binary.
2527-
def find_sftp_server():
2528-
paths_to_try = ['/usr/libexec/sftp-server', '/usr/lib/sftp-server',
2529-
'/usr/libexec/openssh/sftp-server',
2530-
'/usr/lib/openssh/sftp-server']
2531-
return next((path for path in paths_to_try if os.path.isfile(path)), None)
2532-
2533-
sftp_server_path = find_sftp_server()
2534-
if sftp_server_path:
2535-
config.available_features.add('sftp_server')
2536-
config.substitutions.append(('%sftp-server',
2537-
sftp_server_path or 'no-sftp-server'))
2525+
2526+
def find_rsync():
2527+
for path in os.getenv("PATH").split(":"):
2528+
rsync_path = os.path.join(path, "rsync")
2529+
if os.path.isfile(rsync_path):
2530+
return rsync_path
2531+
2532+
2533+
if find_rsync():
2534+
config.available_features.add("rsync")
25382535

25392536
subst_target_repl_run_simple_swift = ""
25402537
if 'swift_repl' in config.available_features:

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
REQUIRES: rsync
2+
13
RUN: %remote-run -n --remote-dir /xyz-REMOTE -o FIRST_OPT -o SECOND_OPT --output-prefix %/t some_user@some_host:12345 cp %/t/nested/input %/t/nested/output 2>&1 >/dev/null | %FileCheck %s
24

35
CHECK: /usr/bin/ssh -n
@@ -20,7 +22,7 @@ CHECK-SAME: 'cp'
2022

2123
CHECK-NEXT: {{^}}/bin/mkdir -p {{.+}}
2224

23-
CHECK-NEXT: /usr/bin/rsync
25+
CHECK-NEXT: rsync
2426
CHECK-DAG: '-p' '12345'
2527
CHECK-DAG: '-o' 'FIRST_OPT' '-o' 'SECOND_OPT'
2628
CHECK-SAME: some_user@some_host

test/remote-run/download.test-sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
REQUIRES: sftp_server
1+
REQUIRES: rsync
22

33
RUN: %empty-directory(%t)
44
RUN: %empty-directory(%t-REMOTE)
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
REQUIRES: rsync
2+
13
RUN: %remote-run -n --remote-dir /xyz-REMOTE --input-prefix %S/Inputs/ some_user@some_host ls %S/Inputs/upload/1.txt %S/Inputs/upload/2.txt 2>&1 >/dev/null | %FileCheck -check-prefix CHECK-INPUT %s
24

35
CHECK-INPUT: /usr/bin/ssh -n some_user@some_host -- '/usr/bin/env' '/bin/mkdir' '-p' '{{.+}}-REMOTE/input'
4-
CHECK-INPUT-NEXT: /usr/bin/rsync
6+
CHECK-INPUT-NEXT: rsync
57
CHECK-INPUT-SAME: some_user@some_host
68

79
CHECK-INPUT: /usr/bin/ssh -n some_user@some_host -- '/usr/bin/env' {{.*}}'ls'
@@ -12,11 +14,11 @@ RUN: touch %t/nested/input %t/nested/BAD
1214
RUN: %remote-run -n --remote-dir /xyz-REMOTE --output-prefix %/t some_user@some_host cp %/t/nested/input %/t/nested/output 2>&1 >/dev/null | %FileCheck -check-prefix CHECK-OUTPUT %s
1315

1416
CHECK-OUTPUT: /usr/bin/ssh -n some_user@some_host -- '/usr/bin/env' '/bin/mkdir' '-p' '{{.+}}-REMOTE/output'
15-
CHECK-OUTPUT-NEXT: /usr/bin/rsync
17+
CHECK-OUTPUT-NEXT: rsync
1618
CHECK-OUTPUT-SAME: some_user@some_host
1719

1820
CHECK-OUTPUT: /usr/bin/ssh -n some_user@some_host -- '/usr/bin/env' {{.*}}'cp'
1921
CHECK-OUTPUT-NEXT: {{^}}/bin/mkdir -p {{.+}}
20-
CHECK-OUTPUT-NEXT: /usr/bin/rsync
22+
CHECK-OUTPUT-NEXT: rsync
2123
CHECK-OUTPUT-SAME: some_user@some_host
2224

test/remote-run/dry-run.test-sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
REQUIRES: rsync
12
REQUIRES: shell
23

34
RUN: %empty-directory(%t)
@@ -6,7 +7,7 @@ RUN: test -z "`ls %t`"
67
RUN: test ! -e %t-REMOTE
78

89
CHECK-INPUT: /usr/bin/env /bin/mkdir -p {{.+}}-REMOTE/input
9-
CHECK-INPUT-NEXT: /usr/bin/rsync
10+
CHECK-INPUT-NEXT: rsync
1011
CHECK-INPUT: /usr/bin/env {{.*}}ls
1112

1213
RUN: %empty-directory(%t)
@@ -16,8 +17,8 @@ RUN: %debug-remote-run -n --output-prefix %t cp %t/nested/input %t/nested/output
1617
RUN: test ! -e %t-REMOTE
1718

1819
CHECK-OUTPUT: /usr/bin/env /bin/mkdir -p {{.+}}-REMOTE/output/nested
19-
CHECK-OUTPUT: /usr/bin/rsync
20+
CHECK-OUTPUT: rsync
2021
CHECK-OUTPUT: /usr/bin/env {{.*}}cp
2122
CHECK-OUTPUT-NEXT: {{^}}/bin/mkdir -p {{.+}}
22-
CHECK-OUTPUT-NEXT: /usr/bin/rsync
23+
CHECK-OUTPUT-NEXT: rsync
2324

test/remote-run/env.test-sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
REQUIRES: rsync
12
REQUIRES: shell
23

34
RUN: env REMOTE_RUN_CHILD_FOO=foo REMOTE_RUN_CHILD_BAR=bar %debug-remote-run sh -c 'echo ":${FOO}:" ":${BAR}:"' | %FileCheck %s

test/remote-run/exit-code.test-sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
REQUIRES: rsync
12
REQUIRES: shell
23

34
RUN: export SWIFT_BACKTRACE=

test/remote-run/identity.test-sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
REQUIRES: rsync
2+
13
RUN: %remote-run -n --remote-dir /xyz-REMOTE -i spiderman --output-prefix %/t some_user@some_host:12345 cp %/t/nested/input %/t/nested/output 2>&1 >/dev/null | %FileCheck %s
24

35
CHECK: /usr/bin/ssh -n
@@ -17,7 +19,7 @@ CHECK-SAME: some_user@some_host -- '/usr/bin/env' {{.*}}'cp'
1719

1820
CHECK-NEXT: {{^}}/bin/mkdir -p {{.+}}
1921

20-
CHECK-NEXT: /usr/bin/rsync
22+
CHECK-NEXT: rsync
2123
CHECK-DAG: '-p' '12345'
2224
CHECK-DAG: '-i' 'spiderman'
2325
CHECK-SAME: some_user@some_host

test/remote-run/port.test-sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
REQUIRES: rsync
2+
13
RUN: %remote-run -n --remote-dir /xyz-REMOTE --output-prefix %/t some_user@some_host:12345 cp %/t/nested/input %/t/nested/output 2>&1 >/dev/null | %FileCheck %s
24

35
CHECK: /usr/bin/ssh -n -p 12345 some_user@some_host -- '/usr/bin/env' '/bin/mkdir' '-p' '{{.+}}-REMOTE/output/nested'
46
CHECK: /usr/bin/ssh -n -p 12345 some_user@some_host -- '/usr/bin/env' {{.*}}'cp'
57
CHECK-NEXT: {{^}}/bin/mkdir -p {{.+}}
6-
CHECK-NEXT: /usr/bin/rsync
8+
CHECK-NEXT: rsync
79
CHECK-SAME: '-p' '12345'
810
CHECK-SAME: some_user@some_host

test/remote-run/run-only.test-sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
REQUIRES: rsync
12
REQUIRES: shell
23

34
RUN: %debug-remote-run echo hello | %FileCheck %s

test/remote-run/stderr.test-sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
REQUIRES: rsync
12
REQUIRES: shell
23

34
RUN: %debug-remote-run sh -c "echo hello; echo goodbye >&2" > %t.stdout.txt 2> %t.stderr.txt

test/remote-run/upload-and-download.test-sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
REQUIRES: sftp_server
1+
REQUIRES: rsync
22

33
RUN: %empty-directory(%t)
44
RUN: %empty-directory(%t-REMOTE)
@@ -27,10 +27,10 @@ RUN: ls %t-REMOTE/output/nested/ | %FileCheck -check-prefix CHECK-REMOTE %s
2727
RUN: %debug-remote-run -v --output-prefix %t cp %t/nested/input %t/nested/output 2>&1 >/dev/null | %FileCheck -check-prefix VERBOSE %s
2828

2929
VERBOSE: /usr/bin/env /bin/mkdir -p {{.+}}-REMOTE/output/nested
30-
VERBOSE: /usr/bin/rsync
30+
VERBOSE: rsync
3131
VERBOSE: /usr/bin/env {{.*}}cp
3232
VERBOSE-NEXT: {{^}}/bin/mkdir -p {{.+}}
33-
VERBOSE-NEXT: /usr/bin/rsync
33+
VERBOSE-NEXT: rsync
3434

3535
RUN: %empty-directory(%t)
3636
RUN: touch %t/xyz-1before

test/remote-run/upload-stderr.test-sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
REQUIRES: sftp_server
1+
REQUIRES: rsync
22

33
RUN: %empty-directory(%t)
44
RUN: %empty-directory(%t/REMOTE/input)

test/remote-run/upload.test-sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
REQUIRES: sftp_server
1+
REQUIRES: rsync
22

33
RUN: env REMOTE_RUN_CHILD_FOO=%S/Inputs/upload/3.txt %debug-remote-run --input-prefix %S/Inputs/upload/ ls %S/Inputs/upload/1.txt %S/Inputs/upload/2.txt | %FileCheck -check-prefix CHECK-REMOTE %s
44
RUN: ls %t-REMOTE/input/ | %FileCheck %s
@@ -34,5 +34,5 @@ CHECK-NEXT: {{^3.txt$}}
3434
CHECK-NOT: BAD
3535

3636
VERBOSE-NESTED: /usr/bin/env /bin/mkdir -p {{.+}}-REMOTE/input
37-
VERBOSE-NESTED-NEXT: /usr/bin/rsync
37+
VERBOSE-NESTED-NEXT: rsync
3838
VERBOSE-NESTED: /usr/bin/env {{.*}}ls

utils/remote-run

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class RemoteCommandRunner(CommandRunner):
203203
[quote(arg) for arg in command])
204204

205205
def rsync_invocation(self, source, dest):
206-
return ['/usr/bin/rsync', '-arRz', '--files-from=-',
206+
return ['rsync', '-arRz', '--files-from=-',
207207
'-e', ' '.join([quote(x) for x in
208208
['/usr/bin/ssh'] +
209209
self.common_options(port_flag='-p')]),
@@ -221,7 +221,7 @@ class LocalCommandRunner(CommandRunner):
221221
return command
222222

223223
def rsync_invocation(self, source, dest):
224-
return ['/usr/bin/rsync', '-arz', '--files-from=-', source, dest]
224+
return ['rsync', '-arz', '--files-from=-', source, dest]
225225

226226
def rsync_from_invocation(self, source, dest):
227227
return self.rsync_invocation(source, dest)

0 commit comments

Comments
 (0)