dtoc: Move main program into its own function

Use a function for the main program so everything there doesn't look like
a global variable to pylint.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2022-07-30 20:57:08 -06:00
parent ad744222f5
commit a8ad9aacd3

View File

@ -799,9 +799,8 @@ def run_tests(args, processes):
return (0 if result.wasSuccessful() else 1) return (0 if result.wasSuccessful() else 1)
if __name__ != '__main__': def main():
sys.exit(1) """Main program for this tool"""
parser = OptionParser() parser = OptionParser()
parser.add_option('-B', '--build-dir', type='string', default='b', parser.add_option('-B', '--build-dir', type='string', default='b',
help='Directory containing the build output') help='Directory containing the build output')
@ -816,6 +815,11 @@ parser.add_option('-T', '--test-coverage', action='store_true',
# Run our meagre tests # Run our meagre tests
if options.test: if options.test:
ret_code = run_tests(args, options.processes) ret_code = run_tests(args, options.processes)
sys.exit(ret_code) return ret_code
elif options.test_coverage: if options.test_coverage:
run_test_coverage(options.build_dir) run_test_coverage(options.build_dir)
return 0
if __name__ == '__main__':
sys.exit(main())
sys.exit(1)