[llvm] e6102dc - [lit] Remove redundant comments from main function
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 28 11:11:13 PDT 2019
Author: Julian Lettner
Date: 2019-10-28T11:10:07-07:00
New Revision: e6102dc5ef8839de04b04a6b3d77a8a16f461e49
URL: https://github.com/llvm/llvm-project/commit/e6102dc5ef8839de04b04a6b3d77a8a16f461e49
DIFF: https://github.com/llvm/llvm-project/commit/e6102dc5ef8839de04b04a6b3d77a8a16f461e49.diff
LOG: [lit] Remove redundant comments from main function
Hopefully the functionality is now clear due to the use of small,
well-named helper functions.
Added:
Modified:
llvm/utils/lit/lit/main.py
Removed:
################################################################################
diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py
index 7e8db0879328..9372886acb4b 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/utils/lit/lit/main.py
@@ -26,7 +26,6 @@ def main(builtinParameters = {}):
userParams = create_user_parameters(builtinParameters, opts)
isWindows = platform.system() == 'Windows'
- # Create the global config object.
litConfig = lit.LitConfig.LitConfig(
progname = os.path.basename(sys.argv[0]),
path = opts.path,
@@ -42,7 +41,6 @@ def main(builtinParameters = {}):
maxFailures = opts.maxFailures,
echo_all_commands = opts.echoAllCommands)
- # Perform test discovery.
tests = lit.discovery.find_tests_for_inputs(litConfig, opts.test_paths)
# Command line overrides configuration for maxIndividualTestTime.
@@ -60,7 +58,6 @@ def main(builtinParameters = {}):
print_suites_or_tests(tests, opts)
return
- # Select and order the tests.
numTotalTests = len(tests)
if opts.filter:
@@ -68,38 +65,28 @@ def main(builtinParameters = {}):
determine_order(tests, opts)
- # Then optionally restrict our attention to a shard of the tests.
if opts.shard:
(run, shards) = opts.shard
tests = filter_by_shard(tests, run, shards, litConfig)
- # Finally limit the number of tests, if desired.
if opts.maxTests is not None:
tests = tests[:opts.maxTests]
- # Don't create more workers than tests.
opts.numWorkers = min(len(tests), opts.numWorkers)
- testing_time = run_tests(tests, litConfig, opts, numTotalTests)
+ elapsed = run_tests(tests, litConfig, opts, numTotalTests)
- # move into print_summary
- if not opts.quiet:
- print('Testing Time: %.2fs' % (testing_time,))
-
- print_summary(tests, opts)
+ print_summary(tests, elapsed, opts)
- # Write out the test data, if requested.
if opts.output_path:
- write_test_results(tests, litConfig, testing_time, opts.output_path)
+ write_test_results(tests, litConfig, elapsed, opts.output_path)
if opts.xunit_output_file:
write_test_results_xunit(tests, opts)
- # If we encountered any additional errors, exit abnormally.
if litConfig.numErrors:
sys.stderr.write('\n%d error(s), exiting.\n' % litConfig.numErrors)
sys.exit(2)
- # Warn about warnings.
if litConfig.numWarnings:
sys.stderr.write('\n%d warning(s) in tests.\n' % litConfig.numWarnings)
@@ -241,7 +228,10 @@ def run_tests_in_tmp_dir(run_callback, litConfig):
# FIXME: Re-try after timeout on Windows.
litConfig.warning("Failed to delete temp directory '%s'" % tmp_dir)
-def print_summary(tests, opts):
+def print_summary(tests, elapsed, opts):
+ if not opts.quiet:
+ print('Testing Time: %.2fs' % elapsed)
+
byCode = {}
for test in tests:
if test.result.code not in byCode:
@@ -288,12 +278,12 @@ def print_summary(tests, opts):
if N:
print(' %s: %d' % (name,N))
-def write_test_results(tests, lit_config, testing_time, output_path):
+def write_test_results(tests, lit_config, elapsed, output_path):
# Construct the data we will write.
data = {}
# Encode the current lit version as a schema version.
data['__version__'] = lit.__versioninfo__
- data['elapsed'] = testing_time
+ data['elapsed'] = elapsed
# FIXME: Record some information on the lit configuration used?
# FIXME: Record information from the individual test suites?
More information about the llvm-commits
mailing list