Skip to content

Commit 688db2b

Browse files
authored
Merge pull request #20961 from compnerd/remote-run
remote-run: make tests partially pass on Windows
2 parents be0bdd1 + 043912f commit 688db2b

File tree

11 files changed

+26
-13
lines changed

11 files changed

+26
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
RUN: %utils/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
1+
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
22

33
CHECK: /usr/bin/ssh -n
44
CHECK-DAG: -p 12345

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
RUN: %utils/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
1+
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
22

33
CHECK-INPUT: /usr/bin/ssh -n some_user@some_host -- '/usr/bin/env' '/bin/mkdir' '-p' '{{.+}}-REMOTE/input/upload'
44
CHECK-INPUT-NEXT: /usr/bin/sftp
@@ -10,7 +10,7 @@ CHECK-INPUT: /usr/bin/ssh -n some_user@some_host -- '/usr/bin/env' 'ls'
1010
RUN: %empty-directory(%t)
1111
RUN: %empty-directory(%t/nested)
1212
RUN: touch %t/nested/input %t/nested/BAD
13-
RUN: %utils/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
13+
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
1414

1515
CHECK-OUTPUT: /usr/bin/ssh -n some_user@some_host -- '/usr/bin/env' '/bin/mkdir' '-p' '{{.+}}-REMOTE/output/nested'
1616
CHECK-OUTPUT-NEXT: /usr/bin/sftp

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
REQUIRES: shell
2+
13
RUN: %empty-directory(%t)
24
RUN: %debug-remote-run -n --input-prefix %S/Inputs/ ls %S/Inputs/upload/1.txt %S/Inputs/upload/2.txt 2>&1 >/dev/null | %FileCheck -check-prefix CHECK-INPUT %s
35
RUN: test -z "`ls %t`"

test/remote-run/env.test-sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
REQUIRES: shell
2+
13
RUN: env REMOTE_RUN_CHILD_FOO=foo REMOTE_RUN_CHILD_BAR=bar %debug-remote-run sh -c 'echo ":${FOO}:" ":${BAR}:"' | %FileCheck %s
24
RUN: env REMOTE_RUN_CHILD_FOO=foo REMOTE_RUN_CHILD_BAR=bar %debug-remote-run -v sh -c 'echo ":${FOO}:" ":${BAR}:"' 2>&1 >/dev/null | %FileCheck -check-prefix VERBOSE %s
35

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
REQUIRES: shell
2+
13
RUN: not %debug-remote-run false >%t.txt 2>%t.errs.txt
24
RUN: test -f %t.txt -a ! -s %t.txt
35
RUN: test -f %t.errs.txt -a ! -s %t.errs.txt

test/remote-run/identity.test-sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
RUN: %utils/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
1+
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
22

33
CHECK: /usr/bin/ssh -n
44
CHECK-DAG: -p 12345
@@ -32,7 +32,7 @@ CHECK-DAG: -get '/xyz-REMOTE/output/nested/output' '{{.+}}/nested/output'
3232
CHECK-DAG: -get '/xyz-REMOTE/output/nested/input' '{{.+}}/nested/input'
3333

3434
# Make sure things work without a port.
35-
RUN: %utils/remote-run -n --remote-dir /xyz-REMOTE -i spiderman --output-prefix %t some_user@some_host cp %t/nested/input %t/nested/output 2>&1 >/dev/null | %FileCheck -check-prefix CHECK-PORTLESS %s
35+
RUN: %remote-run -n --remote-dir /xyz-REMOTE -i spiderman --output-prefix %/t some_user@some_host cp %/t/nested/input %/t/nested/output 2>&1 >/dev/null | %FileCheck -check-prefix CHECK-PORTLESS %s
3636

3737
CHECK-PORTLESS: /usr/bin/sftp
3838
CHECK-PORTLESS-SAME: -i spiderman

test/remote-run/lit.local.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
config.substitutions = list(config.substitutions)
33

44
config.substitutions.insert(0, ('%debug-remote-run',
5-
'%utils/remote-run --debug-as-local %sftp-server --remote-dir %t-REMOTE') )
5+
r'%r %%utils/remote-run --debug-as-local %%sftp-server --remote-dir %%t-REMOTE' % (sys.executable,)))
6+
config.substitutions.insert(0, ('%remote-run',
7+
r'%r %%utils/remote-run' % (sys.executable,)))

test/remote-run/port.test-sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
RUN: %utils/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
1+
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
22

33
CHECK: /usr/bin/ssh -n -p 12345 some_user@some_host -- '/usr/bin/env' '/bin/mkdir' '-p' '{{.+}}-REMOTE/output/nested'
44
CHECK-NEXT: /usr/bin/sftp

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
REQUIRES: shell
2+
13
RUN: %debug-remote-run echo hello | %FileCheck %s
24
RUN: %debug-remote-run -v echo hello 2>&1 >/dev/null | %FileCheck -check-prefix VERBOSE %s
35

test/remote-run/stderr.test-sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
REQUIRES: shell
2+
13
RUN: %debug-remote-run sh -c "echo hello; echo goodbye >&2" > %t.stdout.txt 2> %t.stderr.txt
24
RUN: %FileCheck -check-prefix CHECK-STDOUT %s < %t.stdout.txt
35
RUN: %FileCheck -check-prefix CHECK-STDERR %s < %t.stderr.txt

utils/remote-run

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
from __future__ import print_function
1515

1616
import argparse
17-
import os.path
17+
import os
18+
import posixpath
1819
import subprocess
1920
import sys
2021

@@ -28,7 +29,7 @@ class CommandRunner(object):
2829

2930
@staticmethod
3031
def _dirnames(files):
31-
return sorted(set(os.path.dirname(f) for f in files))
32+
return sorted(set(posixpath.dirname(f) for f in files))
3233

3334
def popen(self, command, **kwargs):
3435
if self.verbose:
@@ -136,8 +137,8 @@ class LocalCommandRunner(CommandRunner):
136137
return ['/usr/bin/sftp', '-b', '-', '-q', '-D', self.sftp_server_path]
137138

138139
def find_transfers(args, source_prefix, dest_prefix):
139-
if source_prefix.endswith(os.path.sep):
140-
source_prefix = source_prefix[:-len(os.path.sep)]
140+
if source_prefix.endswith(posixpath.sep):
141+
source_prefix = source_prefix[:-len(posixpath.sep)]
141142
return dict((arg, dest_prefix + arg[len(source_prefix):])
142143
for arg in args if arg.startswith(source_prefix))
143144

@@ -202,14 +203,14 @@ def main():
202203
remote_test_specific_dir = None
203204
if args.input_prefix:
204205
assert not args.remote_input_prefix.startswith("..")
205-
remote_dir = os.path.join(args.remote_dir, args.remote_input_prefix)
206+
remote_dir = posixpath.join(args.remote_dir, args.remote_input_prefix)
206207
input_files = find_transfers(args.command, args.input_prefix,
207208
remote_dir)
208209
assert not any(upload_files.has_key(f) for f in input_files)
209210
upload_files.update(input_files)
210211
if args.output_prefix:
211212
assert not args.remote_output_prefix.startswith("..")
212-
remote_dir = os.path.join(args.remote_dir, args.remote_output_prefix)
213+
remote_dir = posixpath.join(args.remote_dir, args.remote_output_prefix)
213214
test_files = find_transfers(args.command, args.output_prefix,
214215
remote_dir)
215216
assert not any(upload_files.has_key(f) for f in test_files)

0 commit comments

Comments
 (0)