61 for path in ['LDConfig.ldr', 'ldconfig.ldr'] |
61 for path in ['LDConfig.ldr', 'ldconfig.ldr'] |
62 if (library_path / path).is_file() |
62 if (library_path / path).is_file() |
63 ] |
63 ] |
64 |
64 |
65 import argparse |
65 import argparse |
|
66 |
|
67 def default_problem_message(message): |
|
68 if callable(message): |
|
69 import inspect |
|
70 spec = inspect.getfullargspec(message) |
|
71 args = {} |
|
72 assert not spec.varargs and not spec.varkw |
|
73 for argname in spec.args + spec.kwonlyargs: |
|
74 args[argname] = '<' + argname.replace('_', ' ') + '>' |
|
75 return message(**args) |
|
76 else: |
|
77 return message |
|
78 |
66 class ListTestSuiteAction(argparse.Action): |
79 class ListTestSuiteAction(argparse.Action): |
67 def __init__(self, option_strings, dest, nargs = None, **kwargs): |
80 def __init__(self, option_strings, dest, nargs = None, **kwargs): |
68 super().__init__(option_strings, dest, nargs = 0, **kwargs) |
81 super().__init__(option_strings, dest, nargs = 0, **kwargs) |
69 def __call__(self, *args, **kwargs): |
82 def __call__(self, *args, **kwargs): |
70 from testsuite import load_tests |
83 from testsuite import load_tests, all_warning_types |
71 from sys import exit |
84 from sys import exit |
72 from re import sub |
85 from re import sub |
73 test_suite = load_tests() |
86 test_suite = load_tests() |
74 for test_name in sorted(test_suite['tests'].keys()): |
87 for warning_type in sorted(all_warning_types(test_suite), key = lambda k: k.name): |
75 test_function = test_suite['tests'][test_name] |
88 print(str.format('{name}: {severity}: "{message}"', |
76 help = sub(r'\s+', ' ', test_function.__doc__ or '').strip() |
89 name = warning_type.name, |
77 print(test_name + ': ' + help) |
90 severity = warning_type.severity, |
|
91 message = default_problem_message(warning_type.message), |
|
92 )) |
78 exit(0) |
93 exit(0) |
79 |
94 |
80 if __name__ == '__main__': |
95 if __name__ == '__main__': |
81 from sys import argv |
96 from sys import argv |
82 parser = argparse.ArgumentParser() |
97 parser = argparse.ArgumentParser() |