Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions filecheck/FileCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ def similar(a, b):
return SequenceMatcher(None, a, b).ratio()


def print_help():
print("USAGE: FileCheck-macOS [options] <check-file>")
print("")

print("OPTIONS:")
print("")

print("General options:")
print("")
print(" --match-full-lines - Require all positive matches to cover an entire input line.")
print(" Allows leading and trailing whitespace if --strict-whitespace")
print(" is not also passed.")
print(" --strict-whitespace - Do not treat all horizontal whitespace as equivalent")
print("")

print("Generic options:")
print("")
print("--help - Display available options")


def escape_non_regex_or_skip(match_obj):
non_regex = match_obj.group('non_regex')
if non_regex:
Expand Down Expand Up @@ -75,6 +95,11 @@ def dump_check(check):
print("<check-file> not specified")
exit(2)

for arg in sys.argv:
if arg == '--help':
print_help()
exit(0)

check_file = sys.argv[1]
if not os.path.isfile(check_file):
sys.stdout.flush()
Expand Down
19 changes: 19 additions & 0 deletions tests/integration/tests/options/--help/sample.itest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; RUN: (%FILECHECK_EXEC --help 2>&1; test $? = 0) | %FILECHECK_TESTER_EXEC %s --strict-whitespace --match-full-lines
; CHECK:{{^.*}}FileCheck{{(\.py)?$}}
; CHECK-NEXT:{{^USAGE: FileCheck.* \[options\] <check-file>$}}
; CHECK-EMPTY:
; CHECK-NEXT:OPTIONS:
; CHECK-EMPTY:

; FileCheck C++ prints options without -- but with - only.
; FileCheck.py is made consistent so below we use regex matches to accomodate
; for both - and -- versions.
; CHECK:General options:
; CHECK-EMPTY:
; CHECK:{{^ --?match-full-lines - Require all positive matches to cover an entire input line.$}}
; CHECK-NEXT:{{^ ?Allows leading and trailing whitespace if --strict-whitespace$}}
; CHECK-NEXT:{{^ ?is not also passed.$}}
; CHECK-NEXT:{{^ --?strict-whitespace - Do not treat all horizontal whitespace as equivalent$}}

; CHECK:{{Generic [Oo]ptions:}}
; CHECK-EMPTY: