diff --git a/llvm/utils/lit/lit/builtin_commands/diff.py b/llvm/utils/lit/lit/builtin_commands/diff.py index f2b5869b35889..f0c51fec9e09b 100644 --- a/llvm/utils/lit/lit/builtin_commands/diff.py +++ b/llvm/utils/lit/lit/builtin_commands/diff.py @@ -219,7 +219,7 @@ def main(argv): args = argv[1:] try: - opts, args = getopt.gnu_getopt(args, "wbuI:U:r", ["strip-trailing-cr"]) + opts, args = getopt.gnu_getopt(args, "wcbuI:U:r", ["strip-trailing-cr"]) except getopt.GetoptError as err: sys.stderr.write("Unsupported: 'diff': %s\n" % str(err)) sys.exit(1) @@ -249,6 +249,8 @@ def main(argv): flags.recursive_diff = True elif o == "--strip-trailing-cr": flags.strip_trailing_cr = True + elif o == "-c": + continue else: assert False, "unhandled option" diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell/diff-c.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-c.txt new file mode 100644 index 0000000000000..3e76d8d0d7101 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-c.txt @@ -0,0 +1,14 @@ +# Check that the -c option for the internal diff implementation works. + +# RUN: echo 1 > %t.foo +# RUN: echo 2 >> %t.foo +# RUN: echo 3 >> %t.foo +# RUN: echo 4 >> %t.foo +# RUN: echo 5 >> %t.foo + +# RUN: echo 1 > %t.bar +# RUN: echo 2 >> %t.bar +# RUN: echo 4 >> %t.bar +# RUN: echo 5 >> %t.bar + +# RUN: diff -c %t.foo %t.bar diff --git a/llvm/utils/lit/tests/shtest-shell.py b/llvm/utils/lit/tests/shtest-shell.py index 8f2b865f333a5..d99df45a7f363 100644 --- a/llvm/utils/lit/tests/shtest-shell.py +++ b/llvm/utils/lit/tests/shtest-shell.py @@ -44,6 +44,23 @@ # CHECK-NEXT: # error: command failed with exit status: 1 # CHECK: *** +# CHECK: FAIL: shtest-shell :: diff-c.txt +# CHECK: *** TEST 'shtest-shell :: diff-c.txt' FAILED *** +# CHECK: diff -c {{[^"]*}}.foo {{[^"]*}}.bar +# CHECK: # .---command stdout{{-*}} +# CHECK-NEXT: # | *** {{[^"]*}}.foo +# CHECK-NEXT: # | --- {{[^"]*}}.bar +# CHECK-NEXT: # | *************** +# CHECK-NEXT: # | *** 1,5 **** +# CHECK-NEXT: # | 1 +# CHECK-NEXT: # | 2 +# CHECK-NEXT: # | - 3 +# CHECK-NEXT: # | 4 +# CHECK-NEXT: # | 5 +# CHECK-NEXT: # | --- 1,4 ---- +# CHECK-NEXT: # `---{{-*}} +# CHECK-NEXT: # error: command failed with exit status: 1 +# CHECK: *** # CHECK: FAIL: shtest-shell :: diff-encodings.txt # CHECK: *** TEST 'shtest-shell :: diff-encodings.txt' FAILED *** @@ -635,4 +652,4 @@ # CHECK: PASS: shtest-shell :: valid-shell.txt # CHECK: Unresolved Tests (1) -# CHECK: Failed Tests (36) +# CHECK: Failed Tests (37)