aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2024-04-25 10:30:28 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-04-29 15:25:02 +0000
commitbf6af36235b7dbc81147ce038a0e2f20a128ceb6 (patch)
tree2aea1e533920d4b865ab1a9e2e268a35cab3c9bc
parent6159257e5f2cd397777637e99448e55ceaef89c9 (diff)
downloadtoolchain-utils-bf6af36235b7dbc81147ce038a0e2f20a128ceb6.tar.gz
remove `__name__ == "__main__"` from newly non-executable modules
Since these are run through pytest and python_wrapper now, these `__name__ == "__main__"` blocks should be dead code. Please note that a decent number of `main` invocations took sys.argv without slicing. Those were fixed up to take sys.argv[1:], which is what our wrapper passes. BUG=b:334932020 TEST=python tests Change-Id: I451774a1632d7fcdb37892d5c6f8206cc1a2d2a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/5490906 Tested-by: George Burgess <gbiv@chromium.org> Reviewed-by: Jordan Abrahams-Whitehead <ajordanr@google.com> Commit-Queue: George Burgess <gbiv@chromium.org>
-rw-r--r--afdo_redaction/redact_profile.py4
-rw-r--r--afdo_redaction/redact_profile_test.py4
-rw-r--r--afdo_redaction/remove_cold_functions.py4
-rw-r--r--afdo_redaction/remove_cold_functions_test.py4
-rw-r--r--afdo_redaction/remove_indirect_calls.py4
-rw-r--r--afdo_redaction/remove_indirect_calls_test.py4
-rw-r--r--afdo_tools/bisection/afdo_prof_analysis.py6
-rw-r--r--afdo_tools/bisection/afdo_prof_analysis_e2e_test.py6
-rw-r--r--afdo_tools/bisection/afdo_prof_analysis_test.py4
-rw-r--r--afdo_tools/generate_afdo_from_tryjob.py4
-rw-r--r--afdo_tools/run_afdo_tryjob.py4
-rw-r--r--afdo_tools/update_kernel_afdo.py4
-rw-r--r--afdo_tools/update_kernel_afdo_test.py4
-rw-r--r--auto_abandon_cls.py4
-rw-r--r--build_chromeos.py7
-rw-r--r--build_tc.py5
-rw-r--r--buildbot_test_toolchains.py7
-rw-r--r--check_portable_toolchains.py4
-rw-r--r--chromiumos_image_diff.py6
-rw-r--r--[-rwxr-xr-x]compiler_wrapper/build.py0
-rw-r--r--crate_ebuild_help.py4
-rw-r--r--cros_utils/bugs_test.py4
-rw-r--r--cros_utils/buildbot_utils_test.py4
-rw-r--r--cros_utils/command_executer_test.py4
-rw-r--r--cros_utils/command_executer_timeout_test.py4
-rw-r--r--cros_utils/email_sender_test.py4
-rw-r--r--cros_utils/git_utils_test.py4
-rw-r--r--cros_utils/misc_test.py4
-rw-r--r--cros_utils/perf_diff.py4
-rw-r--r--cros_utils/tabulator_test.py4
-rw-r--r--cros_utils/timeline_test.py4
-rw-r--r--cros_utils/tiny_render_test.py4
-rw-r--r--cwp/cr_os/fetch_gn_descs.py4
-rw-r--r--cwp/cr_os/fetch_gn_descs_test.py4
-rw-r--r--debug_info_test/debug_info_test.py8
-rw-r--r--go/chromeos/setup_chromeos_testing.py7
-rw-r--r--image_chromeos.py9
-rw-r--r--llvm_extra/create_ebuild_file.py4
-rw-r--r--llvm_tools/atomic_write_file_test.py4
-rw-r--r--llvm_tools/bb_add.py4
-rw-r--r--llvm_tools/bb_add_test.py4
-rw-r--r--llvm_tools/check_clang_diags.py4
-rw-r--r--llvm_tools/check_clang_diags_test.py4
-rw-r--r--llvm_tools/chroot_test.py4
-rw-r--r--llvm_tools/clean_up_old_llvm_patches.py4
-rw-r--r--llvm_tools/clean_up_old_llvm_patches_test.py4
-rw-r--r--llvm_tools/copy_helpers_to_chromiumos_overlay.py4
-rw-r--r--llvm_tools/cros_cls_test.py4
-rw-r--r--llvm_tools/fetch_cq_size_diff.py4
-rw-r--r--llvm_tools/fetch_cros_sdk_rolls.py4
-rw-r--r--llvm_tools/generate_llvm_revert_report.py4
-rw-r--r--llvm_tools/get_llvm_hash.py4
-rw-r--r--llvm_tools/get_llvm_hash_test.py4
-rw-r--r--llvm_tools/get_patch.py4
-rw-r--r--llvm_tools/get_patch_test.py4
-rw-r--r--llvm_tools/get_upstream_patch.py4
-rw-r--r--llvm_tools/git_llvm_rev.py4
-rw-r--r--llvm_tools/git_llvm_rev_test.py8
-rw-r--r--llvm_tools/git_test.py4
-rw-r--r--llvm_tools/llvm_next_test.py4
-rw-r--r--llvm_tools/llvm_simple_bisect.py4
-rw-r--r--llvm_tools/manifest_utils_test.py4
-rw-r--r--llvm_tools/nightly_revert_checker.py4
-rw-r--r--llvm_tools/nightly_revert_checker_test.py4
-rw-r--r--llvm_tools/patch_manager.py4
-rw-r--r--llvm_tools/patch_manager_test.py4
-rw-r--r--llvm_tools/patch_utils_test.py3
-rw-r--r--llvm_tools/revert_checker.py4
-rw-r--r--llvm_tools/setup_for_workon.py4
-rw-r--r--llvm_tools/stabilize_all_llvm_packages.py4
-rw-r--r--llvm_tools/update_packages_and_run_tests.py4
-rw-r--r--llvm_tools/update_packages_and_run_tests_test.py4
-rw-r--r--llvm_tools/upload_llvm_testing_helper_cl.py4
-rw-r--r--llvm_tools/upload_llvm_testing_helper_cl_test.py4
-rw-r--r--llvm_tools/werror_logs.py4
-rw-r--r--llvm_tools/werror_logs_test.py4
-rw-r--r--make_root_writable.py7
-rw-r--r--pgo_tools/benchmark_pgo_profiles.py4
-rw-r--r--pgo_tools/benchmark_pgo_profiles_test.py4
-rw-r--r--pgo_tools/create_chroot_and_generate_pgo_profile.py4
-rw-r--r--pgo_tools/create_chroot_and_generate_pgo_profile_test.py4
-rw-r--r--pgo_tools/ensure_pgo_is_a_win.py4
-rw-r--r--pgo_tools/ensure_pgo_is_a_win_test.py4
-rw-r--r--pgo_tools/generate_pgo_profile.py4
-rw-r--r--pgo_tools/generate_pgo_profile_test.py4
-rw-r--r--pgo_tools/pgo_utils_test.py4
-rw-r--r--pgo_tools_rust/pgo_rust.py8
-rw-r--r--remote_test.py4
-rw-r--r--run_tests_for.py4
-rw-r--r--rust_tools/auto_update_rust_bootstrap.py4
-rw-r--r--rust_tools/auto_update_rust_bootstrap_test.py4
-rw-r--r--rust_tools/copy_rust_bootstrap.py4
-rw-r--r--rust_tools/rust_uprev.py4
-rw-r--r--rust_tools/rust_uprev_test.py4
-rw-r--r--rust_tools/rust_watch.py4
-rw-r--r--rust_tools/rust_watch_test.py4
-rw-r--r--seccomp_tools/mass_seccomp_editor/mass_seccomp_editor.py4
-rw-r--r--seccomp_tools/mass_seccomp_editor/mass_seccomp_editor_test.py4
-rw-r--r--tc_enter_chroot.py5
-rwxr-xr-xtoolchain_utils_githooks/check-presubmit.py4
-rw-r--r--update_telemetry_defaults.py5
101 files changed, 21 insertions, 416 deletions
diff --git a/afdo_redaction/redact_profile.py b/afdo_redaction/redact_profile.py
index 3e6f5892..e7b0ba86 100644
--- a/afdo_redaction/redact_profile.py
+++ b/afdo_redaction/redact_profile.py
@@ -248,7 +248,3 @@ def _main():
summary_output_file=sys.stderr,
profile_output_file=sys.stdout,
)
-
-
-if __name__ == "__main__":
- _main()
diff --git a/afdo_redaction/redact_profile_test.py b/afdo_redaction/redact_profile_test.py
index 93c65510..71cf13af 100644
--- a/afdo_redaction/redact_profile_test.py
+++ b/afdo_redaction/redact_profile_test.py
@@ -133,7 +133,3 @@ class Tests(unittest.TestCase):
self.assertIn("Retained 1/101 functions", summary)
self.assertIn("Retained 1,575/84,275 samples, total", summary)
self.assertIn("Retained 1,083/34,583 top-level samples", summary)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/afdo_redaction/remove_cold_functions.py b/afdo_redaction/remove_cold_functions.py
index b35b34bd..d9258cab 100644
--- a/afdo_redaction/remove_cold_functions.py
+++ b/afdo_redaction/remove_cold_functions.py
@@ -206,7 +206,3 @@ def main():
run(stdin, stdout, args.number, cwp, benchmark)
else:
run(stdin, stdout, args.number)
-
-
-if __name__ == "__main__":
- main()
diff --git a/afdo_redaction/remove_cold_functions_test.py b/afdo_redaction/remove_cold_functions_test.py
index 89a87f82..87622803 100644
--- a/afdo_redaction/remove_cold_functions_test.py
+++ b/afdo_redaction/remove_cold_functions_test.py
@@ -146,7 +146,3 @@ class Test(unittest.TestCase):
" profiles",
output,
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/afdo_redaction/remove_indirect_calls.py b/afdo_redaction/remove_indirect_calls.py
index 34a7b1c9..453b9eff 100644
--- a/afdo_redaction/remove_indirect_calls.py
+++ b/afdo_redaction/remove_indirect_calls.py
@@ -77,7 +77,3 @@ def main():
with open(args.input) as stdin:
with open(args.output, "w") as stdout:
run(stdin, stdout)
-
-
-if __name__ == "__main__":
- main()
diff --git a/afdo_redaction/remove_indirect_calls_test.py b/afdo_redaction/remove_indirect_calls_test.py
index 640b747f..ece2205e 100644
--- a/afdo_redaction/remove_indirect_calls_test.py
+++ b/afdo_redaction/remove_indirect_calls_test.py
@@ -60,7 +60,3 @@ class Test(unittest.TestCase):
""".strip().splitlines()
self.assertEqual(_run_test(profile_lines), expected_lines)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/afdo_tools/bisection/afdo_prof_analysis.py b/afdo_tools/bisection/afdo_prof_analysis.py
index c47fe2c5..6f50dd6a 100644
--- a/afdo_tools/bisection/afdo_prof_analysis.py
+++ b/afdo_tools/bisection/afdo_prof_analysis.py
@@ -431,7 +431,7 @@ def parse_args():
return parser.parse_args()
-def main(flags):
+def main_impl(flags):
logging.getLogger().setLevel(logging.INFO)
if not flags.no_resume and flags.seed: # conflicting seeds
raise RuntimeError(
@@ -481,5 +481,5 @@ def main(flags):
return results
-if __name__ == "__main__":
- main(parse_args())
+def main():
+ main_impl(parse_args())
diff --git a/afdo_tools/bisection/afdo_prof_analysis_e2e_test.py b/afdo_tools/bisection/afdo_prof_analysis_e2e_test.py
index a6e5135e..4390807e 100644
--- a/afdo_tools/bisection/afdo_prof_analysis_e2e_test.py
+++ b/afdo_tools/bisection/afdo_prof_analysis_e2e_test.py
@@ -277,7 +277,7 @@ class AfdoProfAnalysisE2ETest(unittest.TestCase):
self.addCleanup(rm_state)
- actual = analysis.main(
+ actual = analysis.main_impl(
ObjectWithFields(
good_prof=good_prof_file,
bad_prof=bad_prof_file,
@@ -292,7 +292,3 @@ class AfdoProfAnalysisE2ETest(unittest.TestCase):
actual_seed = actual.pop("seed") # nothing to check
self.assertEqual(actual, expected)
return actual_seed
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/afdo_tools/bisection/afdo_prof_analysis_test.py b/afdo_tools/bisection/afdo_prof_analysis_test.py
index ba04b13e..de63ec90 100644
--- a/afdo_tools/bisection/afdo_prof_analysis_test.py
+++ b/afdo_tools/bisection/afdo_prof_analysis_test.py
@@ -159,7 +159,3 @@ class AfdoProfAnalysisTest(unittest.TestCase):
DeciderClass(), self.good_items, self.bad_items
)
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/afdo_tools/generate_afdo_from_tryjob.py b/afdo_tools/generate_afdo_from_tryjob.py
index 099c80a4..6b8a3f8c 100644
--- a/afdo_tools/generate_afdo_from_tryjob.py
+++ b/afdo_tools/generate_afdo_from_tryjob.py
@@ -169,7 +169,3 @@ def main(argv: List[str]):
shutil.rmtree(temp_dir, ignore_errors=True)
else:
print("Artifacts are available at", temp_dir)
-
-
-if __name__ == "__main__":
- sys.exit(main(sys.argv[1:]))
diff --git a/afdo_tools/run_afdo_tryjob.py b/afdo_tools/run_afdo_tryjob.py
index bd04b575..920c9062 100644
--- a/afdo_tools/run_afdo_tryjob.py
+++ b/afdo_tools/run_afdo_tryjob.py
@@ -174,7 +174,3 @@ def main():
print(" ".join(pipes.quote(a) for a in args))
if not dry_run:
sys.exit(subprocess.call(args))
-
-
-if __name__ == "__main__":
- main()
diff --git a/afdo_tools/update_kernel_afdo.py b/afdo_tools/update_kernel_afdo.py
index 2496fac3..63227c23 100644
--- a/afdo_tools/update_kernel_afdo.py
+++ b/afdo_tools/update_kernel_afdo.py
@@ -803,7 +803,3 @@ def main(argv: List[str]) -> None:
"above logs. Most likely the things you're looking for are logged "
"at the ERROR level."
)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/afdo_tools/update_kernel_afdo_test.py b/afdo_tools/update_kernel_afdo_test.py
index 8af4abae..4cef7dcc 100644
--- a/afdo_tools/update_kernel_afdo_test.py
+++ b/afdo_tools/update_kernel_afdo_test.py
@@ -298,7 +298,3 @@ TOTAL: 2 objects, 1234 bytes (1.1KiB)
self.assertEqual(
tmpdir, update_kernel_afdo.find_chromeos_tree_root(test_subdir)
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/auto_abandon_cls.py b/auto_abandon_cls.py
index 87e57a1c..060207bc 100644
--- a/auto_abandon_cls.py
+++ b/auto_abandon_cls.py
@@ -109,7 +109,3 @@ def main(argv: List[str]) -> None:
dry_run=opts.dry_run,
internal=True,
)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/build_chromeos.py b/build_chromeos.py
index 0a8c393c..73a3c0ee 100644
--- a/build_chromeos.py
+++ b/build_chromeos.py
@@ -134,7 +134,7 @@ def Main(argv):
),
)
- options = parser.parse_args(argv[1:])
+ options = parser.parse_args(argv)
if options.chromeos_root is None:
Usage(parser, "--chromeos_root must be set")
@@ -367,8 +367,3 @@ def Main(argv):
)
return ret
-
-
-if __name__ == "__main__":
- retval = Main(sys.argv)
- sys.exit(retval)
diff --git a/build_tc.py b/build_tc.py
index 7c314ddc..915d2071 100644
--- a/build_tc.py
+++ b/build_tc.py
@@ -408,8 +408,3 @@ def Main(argv):
finally:
print("Exiting...")
return rv
-
-
-if __name__ == "__main__":
- retval = Main(sys.argv[1:])
- sys.exit(retval)
diff --git a/buildbot_test_toolchains.py b/buildbot_test_toolchains.py
index 105b6af1..8eda67fb 100644
--- a/buildbot_test_toolchains.py
+++ b/buildbot_test_toolchains.py
@@ -389,7 +389,7 @@ def Main(argv):
"Artifacts stored in /tmp/toolchain-tests",
)
- options = parser.parse_args(argv[1:])
+ options = parser.parse_args(argv)
if not options.board:
print("Please give a board.")
return 1
@@ -417,8 +417,3 @@ def Main(argv):
chrome_src=options.chrome_src,
)
return fc.DoAll()
-
-
-if __name__ == "__main__":
- retval = Main(sys.argv)
- sys.exit(retval)
diff --git a/check_portable_toolchains.py b/check_portable_toolchains.py
index 062ab789..70e03f5f 100644
--- a/check_portable_toolchains.py
+++ b/check_portable_toolchains.py
@@ -217,7 +217,3 @@ def parse_args() -> argparse.Namespace:
help="Top level gs:// path. (default: %(default)s)",
)
return parser.parse_args()
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/chromiumos_image_diff.py b/chromiumos_image_diff.py
index dfec33c4..b58ad488 100644
--- a/chromiumos_image_diff.py
+++ b/chromiumos_image_diff.py
@@ -345,7 +345,7 @@ def Main(argv):
required=True,
help=("Image 2 file name."),
)
- options = parser.parse_args(argv[1:])
+ options = parser.parse_args(argv)
if options.mount_basename and options.mount_basename.find("/") >= 0:
logger.GetLogger().LogError(
@@ -409,7 +409,3 @@ def Main(argv):
image_comparator.Cleanup()
return 0 if result else 1
-
-
-if __name__ == "__main__":
- Main(sys.argv)
diff --git a/compiler_wrapper/build.py b/compiler_wrapper/build.py
index bea888db..bea888db 100755..100644
--- a/compiler_wrapper/build.py
+++ b/compiler_wrapper/build.py
diff --git a/crate_ebuild_help.py b/crate_ebuild_help.py
index 69105e17..9a9dc5af 100644
--- a/crate_ebuild_help.py
+++ b/crate_ebuild_help.py
@@ -170,7 +170,3 @@ def main():
j = i + 1
print(f"[{j}/{crates_len}] {s}")
print()
-
-
-if __name__ == "__main__":
- main()
diff --git a/cros_utils/bugs_test.py b/cros_utils/bugs_test.py
index 21ed2154..70156a20 100644
--- a/cros_utils/bugs_test.py
+++ b/cros_utils/bugs_test.py
@@ -239,7 +239,3 @@ class Tests(unittest.TestCase):
bugs.AppendToExistingBug(1, "body", directory=tmpdir)
json_files = list(Path(tmpdir).glob("*.json"))
self.assertEqual(len(json_files), 1, json_files)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/cros_utils/buildbot_utils_test.py b/cros_utils/buildbot_utils_test.py
index 9e006f20..37dca650 100644
--- a/cros_utils/buildbot_utils_test.py
+++ b/cros_utils/buildbot_utils_test.py
@@ -230,7 +230,3 @@ class TrybotTest(unittest.TestCase):
image,
f"{IMAGE_DIR}/R83-13003.0.0-30196-8884755532184725",
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/cros_utils/command_executer_test.py b/cros_utils/command_executer_test.py
index 7cd46a71..c85930bb 100644
--- a/cros_utils/command_executer_test.py
+++ b/cros_utils/command_executer_test.py
@@ -27,7 +27,3 @@ class CommandExecuterTest(unittest.TestCase):
)
end = time.time()
self.assertTrue(round(end - start) == timeout)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/cros_utils/command_executer_timeout_test.py b/cros_utils/command_executer_timeout_test.py
index 3af9bd3e..c7cfd5cd 100644
--- a/cros_utils/command_executer_timeout_test.py
+++ b/cros_utils/command_executer_timeout_test.py
@@ -30,7 +30,3 @@ def Main(argv):
ce = command_executer.GetCommandExecuter()
ce.RunCommand(command, command_timeout=1)
return 0
-
-
-if __name__ == "__main__":
- Main(sys.argv[1:])
diff --git a/cros_utils/email_sender_test.py b/cros_utils/email_sender_test.py
index 784556ac..493b0fa2 100644
--- a/cros_utils/email_sender_test.py
+++ b/cros_utils/email_sender_test.py
@@ -116,7 +116,3 @@ class Test(unittest.TestCase):
"html_body": "html",
},
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/cros_utils/git_utils_test.py b/cros_utils/git_utils_test.py
index 3c9521bb..7d87008c 100644
--- a/cros_utils/git_utils_test.py
+++ b/cros_utils/git_utils_test.py
@@ -120,7 +120,3 @@ class Test(unittest.TestCase):
),
[7190037],
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/cros_utils/misc_test.py b/cros_utils/misc_test.py
index 9e2d1107..309043a7 100644
--- a/cros_utils/misc_test.py
+++ b/cros_utils/misc_test.py
@@ -61,7 +61,3 @@ class UtilsTest(unittest.TestCase):
self.assertEqual(
new_env_string, " ".join([env_string, expected_new_env])
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/cros_utils/perf_diff.py b/cros_utils/perf_diff.py
index 85348eca..866a71cf 100644
--- a/cros_utils/perf_diff.py
+++ b/cros_utils/perf_diff.py
@@ -349,7 +349,3 @@ def Main(argv):
pass
return 0
-
-
-if __name__ == "__main__":
- sys.exit(Main(sys.argv))
diff --git a/cros_utils/tabulator_test.py b/cros_utils/tabulator_test.py
index 91ce8fd5..6c1b2828 100644
--- a/cros_utils/tabulator_test.py
+++ b/cros_utils/tabulator_test.py
@@ -207,7 +207,3 @@ class TabulatorTest(unittest.TestCase):
for row in cell_table[1:]:
for cell in row:
self.assertTrue(cell.colspan == 1)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/cros_utils/timeline_test.py b/cros_utils/timeline_test.py
index aceab2df..785c6482 100644
--- a/cros_utils/timeline_test.py
+++ b/cros_utils/timeline_test.py
@@ -55,7 +55,3 @@ class TimeLineTest(unittest.TestCase):
t = time.time()
t1 = tl.GetLastEventTime()
self.assertEqual(int(t1 - t), 0)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/cros_utils/tiny_render_test.py b/cros_utils/tiny_render_test.py
index e1e4a2eb..c213ad5c 100644
--- a/cros_utils/tiny_render_test.py
+++ b/cros_utils/tiny_render_test.py
@@ -194,7 +194,3 @@ class Test(unittest.TestCase):
)
),
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/cwp/cr_os/fetch_gn_descs.py b/cwp/cr_os/fetch_gn_descs.py
index 9491b74f..d30067f0 100644
--- a/cwp/cr_os/fetch_gn_descs.py
+++ b/cwp/cr_os/fetch_gn_descs.py
@@ -203,7 +203,3 @@ def main(args):
with open(results_intermed, "w", encoding="utf-8") as f:
json.dump(results, f)
os.rename(results_intermed, results_file)
-
-
-if __name__ == "__main__":
- sys.exit(main(sys.argv[1:]))
diff --git a/cwp/cr_os/fetch_gn_descs_test.py b/cwp/cr_os/fetch_gn_descs_test.py
index 7631c136..468d0b12 100644
--- a/cwp/cr_os/fetch_gn_descs_test.py
+++ b/cwp/cr_os/fetch_gn_descs_test.py
@@ -117,7 +117,3 @@ class Test(unittest.TestCase):
warnings, desc_json = fetch_gn_descs._parse_gn_desc_output(gn_desc)
self.assertEqual(warnings, "")
self.assertEqual(desc_json, {"bar": "baz"})
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/debug_info_test/debug_info_test.py b/debug_info_test/debug_info_test.py
index af0c7563..2954beae 100644
--- a/debug_info_test/debug_info_test.py
+++ b/debug_info_test/debug_info_test.py
@@ -39,12 +39,12 @@ def scanelf(root):
def Main(argv):
- if len(argv) < 2:
+ if not argv:
print("usage: %s [file|dir]")
return 1
files = []
- cand = argv[1]
+ cand = argv[0]
if os.path.isfile(cand):
files = [cand]
elif os.path.isdir(cand):
@@ -62,7 +62,3 @@ def Main(argv):
if failed:
return 1
return 0
-
-
-if __name__ == "__main__":
- sys.exit(Main(sys.argv))
diff --git a/go/chromeos/setup_chromeos_testing.py b/go/chromeos/setup_chromeos_testing.py
index f7a8668d..3a49e775 100644
--- a/go/chromeos/setup_chromeos_testing.py
+++ b/go/chromeos/setup_chromeos_testing.py
@@ -235,7 +235,7 @@ def Main(argv):
"-v", "--verbose", dest="verbose", default=False, action="store_true"
)
- options = parser.parse_args(argv[1:])
+ options = parser.parse_args(argv)
if options.verbose:
DEBUG = True
@@ -273,8 +273,3 @@ def Main(argv):
)
return 0
-
-
-if __name__ == "__main__":
- val = Main(sys.argv)
- sys.exit(val)
diff --git a/image_chromeos.py b/image_chromeos.py
index 4bdee824..2527a944 100644
--- a/image_chromeos.py
+++ b/image_chromeos.py
@@ -94,7 +94,7 @@ def FindChromeOSImage(image_file, chromeos_root):
return path_util.ToChrootPath(image_file, source_path=chromeos_root)
-def DoImage(argv):
+def Main(argv):
"""Image ChromeOS."""
parser = argparse.ArgumentParser()
@@ -147,7 +147,7 @@ def DoImage(argv):
help="Do not clobber the stateful partition.",
)
- options = parser.parse_args(argv[1:])
+ options = parser.parse_args(argv)
if not options.log_level in command_executer.LOG_LEVEL:
Usage(parser, "--logging_level must be 'quiet', 'average' or 'verbose'")
@@ -552,8 +552,3 @@ def EnsureMachineUp(chromeos_root, remote, log_level):
)
if not ret:
return True
-
-
-if __name__ == "__main__":
- retval = DoImage(sys.argv)
- sys.exit(retval)
diff --git a/llvm_extra/create_ebuild_file.py b/llvm_extra/create_ebuild_file.py
index 5ccb601d..3816d5fc 100644
--- a/llvm_extra/create_ebuild_file.py
+++ b/llvm_extra/create_ebuild_file.py
@@ -149,7 +149,3 @@ def main():
outfile.write("".join(text))
return 0
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/llvm_tools/atomic_write_file_test.py b/llvm_tools/atomic_write_file_test.py
index 8c00f9ef..ffa9c1a2 100644
--- a/llvm_tools/atomic_write_file_test.py
+++ b/llvm_tools/atomic_write_file_test.py
@@ -45,7 +45,3 @@ class TestAtomicWrite(unittest.TestCase):
with filepath.open(encoding="utf-8") as f:
lines = f.readlines()
self.assertEqual(lines[0], new_contents)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/bb_add.py b/llvm_tools/bb_add.py
index 6d8ceabe..71982ae0 100644
--- a/llvm_tools/bb_add.py
+++ b/llvm_tools/bb_add.py
@@ -197,7 +197,3 @@ def main(argv: List[str]) -> None:
logging.info("Running `bb add` command: %s...", shlex.join(cmd))
# execvp raises if it fails, so no need to check.
os.execvp(cmd[0], cmd)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/llvm_tools/bb_add_test.py b/llvm_tools/bb_add_test.py
index 407beb82..f7a5c8d1 100644
--- a/llvm_tools/bb_add_test.py
+++ b/llvm_tools/bb_add_test.py
@@ -94,7 +94,3 @@ class Test(unittest.TestCase):
]
+ _ARBITRARY_BOTS,
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/check_clang_diags.py b/llvm_tools/check_clang_diags.py
index 02c4bf0b..3d0b7414 100644
--- a/llvm_tools/check_clang_diags.py
+++ b/llvm_tools/check_clang_diags.py
@@ -218,7 +218,3 @@ def main(argv: List[str]) -> None:
with open(new_state_file_path, "w", encoding="utf-8") as f:
json.dump(new_state_file, f)
os.rename(new_state_file_path, state_file)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/llvm_tools/check_clang_diags_test.py b/llvm_tools/check_clang_diags_test.py
index 91cee923..c8e97078 100644
--- a/llvm_tools/check_clang_diags_test.py
+++ b/llvm_tools/check_clang_diags_test.py
@@ -106,7 +106,3 @@ class Test(unittest.TestCase):
self.assertEqual(
len(create_new_bug_mock.call_args_list), len(expected_calls)
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/chroot_test.py b/llvm_tools/chroot_test.py
index f4bd7d4d..bd716277 100644
--- a/llvm_tools/chroot_test.py
+++ b/llvm_tools/chroot_test.py
@@ -65,7 +65,3 @@ class HelperFunctionsTest(unittest.TestCase):
),
[expected_abs_path],
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/clean_up_old_llvm_patches.py b/llvm_tools/clean_up_old_llvm_patches.py
index dae4be28..9ed26132 100644
--- a/llvm_tools/clean_up_old_llvm_patches.py
+++ b/llvm_tools/clean_up_old_llvm_patches.py
@@ -285,7 +285,3 @@ def main(argv: List[str]) -> None:
logging.info("Uploading changes...")
upload_changes(cros_overlay, gerrit_tool_cwd)
logging.info("Change sent for review.")
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/llvm_tools/clean_up_old_llvm_patches_test.py b/llvm_tools/clean_up_old_llvm_patches_test.py
index 0205a2a9..0a032dea 100644
--- a/llvm_tools/clean_up_old_llvm_patches_test.py
+++ b/llvm_tools/clean_up_old_llvm_patches_test.py
@@ -55,7 +55,3 @@ class Test(test_helpers.TempDirTestCase):
),
123456,
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/copy_helpers_to_chromiumos_overlay.py b/llvm_tools/copy_helpers_to_chromiumos_overlay.py
index e3319c2d..3dfc7dfc 100644
--- a/llvm_tools/copy_helpers_to_chromiumos_overlay.py
+++ b/llvm_tools/copy_helpers_to_chromiumos_overlay.py
@@ -63,7 +63,3 @@ def main():
dest = os.path.join(filesdir, f)
print("%r => %r" % (source, dest))
shutil.copyfile(source, dest)
-
-
-if __name__ == "__main__":
- main()
diff --git a/llvm_tools/cros_cls_test.py b/llvm_tools/cros_cls_test.py
index d564c14d..e6b66197 100644
--- a/llvm_tools/cros_cls_test.py
+++ b/llvm_tools/cros_cls_test.py
@@ -152,7 +152,3 @@ class Test(unittest.TestCase):
),
"R122-15711.0.0",
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/fetch_cq_size_diff.py b/llvm_tools/fetch_cq_size_diff.py
index 477a0e3f..1fcfbbd9 100644
--- a/llvm_tools/fetch_cq_size_diff.py
+++ b/llvm_tools/fetch_cq_size_diff.py
@@ -359,7 +359,3 @@ def main(argv: List[str]) -> None:
artifact = DebugInfoArtifact()
opts.func(opts, artifact)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/llvm_tools/fetch_cros_sdk_rolls.py b/llvm_tools/fetch_cros_sdk_rolls.py
index 5b0118a2..b6c14b6e 100644
--- a/llvm_tools/fetch_cros_sdk_rolls.py
+++ b/llvm_tools/fetch_cros_sdk_rolls.py
@@ -108,7 +108,3 @@ def main():
logging.debug("Keeping around tempdir %r to aid debugging", tempdir)
else:
shutil.rmtree(tempdir)
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/llvm_tools/generate_llvm_revert_report.py b/llvm_tools/generate_llvm_revert_report.py
index 3018974c..7ce5b1e7 100644
--- a/llvm_tools/generate_llvm_revert_report.py
+++ b/llvm_tools/generate_llvm_revert_report.py
@@ -152,7 +152,3 @@ def main(argv: List[str]):
print()
print("CSV summary of reverts:")
write_reverts_as_csv(sys.stdout, reverts)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/llvm_tools/get_llvm_hash.py b/llvm_tools/get_llvm_hash.py
index ae43caee..ddd13c36 100644
--- a/llvm_tools/get_llvm_hash.py
+++ b/llvm_tools/get_llvm_hash.py
@@ -505,7 +505,3 @@ def main() -> None:
else:
assert cur_llvm_version == "tot"
print(new_llvm_hash.GetTopOfTrunkGitHash())
-
-
-if __name__ == "__main__":
- main()
diff --git a/llvm_tools/get_llvm_hash_test.py b/llvm_tools/get_llvm_hash_test.py
index 313bc81e..1627cf4c 100644
--- a/llvm_tools/get_llvm_hash_test.py
+++ b/llvm_tools/get_llvm_hash_test.py
@@ -203,7 +203,3 @@ class TestGetLLVMHash(test_helpers.TempDirTestCase):
get_llvm_hash.LLVMHash().GetCrOSLLVMNextHash(),
llvm_next.LLVM_NEXT_HASH,
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/get_patch.py b/llvm_tools/get_patch.py
index 9a5d28e9..4ec7cd49 100644
--- a/llvm_tools/get_patch.py
+++ b/llvm_tools/get_patch.py
@@ -715,7 +715,3 @@ def main() -> None:
)
for patch_source in args.patch_sources:
ctx.apply_patches(patch_source)
-
-
-if __name__ == "__main__":
- main()
diff --git a/llvm_tools/get_patch_test.py b/llvm_tools/get_patch_test.py
index 65cb3311..1f47d888 100644
--- a/llvm_tools/get_patch_test.py
+++ b/llvm_tools/get_patch_test.py
@@ -231,7 +231,3 @@ class TestGetPatch(unittest.TestCase):
finally:
self.ctx.dry_run = old_dry_run
self.patches_json_file.unlink()
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/get_upstream_patch.py b/llvm_tools/get_upstream_patch.py
index 4ee9fe6a..61df8424 100644
--- a/llvm_tools/get_upstream_patch.py
+++ b/llvm_tools/get_upstream_patch.py
@@ -586,7 +586,3 @@ def main():
skip_dependencies=args.skip_dependencies,
platforms=args.platform,
)
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/llvm_tools/git_llvm_rev.py b/llvm_tools/git_llvm_rev.py
index cd70359e..253a719a 100644
--- a/llvm_tools/git_llvm_rev.py
+++ b/llvm_tools/git_llvm_rev.py
@@ -481,7 +481,3 @@ def main(argv: List[str]) -> None:
else:
sha = translate_rev_to_sha(config, Rev.parse(opts.rev))
print(sha)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/llvm_tools/git_llvm_rev_test.py b/llvm_tools/git_llvm_rev_test.py
index 3e9435fa..f54d102f 100644
--- a/llvm_tools/git_llvm_rev_test.py
+++ b/llvm_tools/git_llvm_rev_test.py
@@ -20,6 +20,10 @@ def get_llvm_config() -> git_llvm_rev.LLVMConfig:
class Test(unittest.TestCase):
"""Test cases for git_llvm_rev."""
+ @classmethod
+ def setUpClass(cls):
+ llvm_project.ensure_up_to_date()
+
def rev_to_sha_with_round_trip(self, rev: git_llvm_rev.Rev) -> str:
config = get_llvm_config()
sha = git_llvm_rev.translate_rev_to_sha(config, rev)
@@ -170,7 +174,3 @@ class Test(unittest.TestCase):
# FIXME: When release/10.x happens, it may be nice to have a test-case
# generally covering that, since it's the first branch that we have to travel
# back to the base commit for.
-
-if __name__ == "__main__":
- llvm_project.ensure_up_to_date()
- unittest.main()
diff --git a/llvm_tools/git_test.py b/llvm_tools/git_test.py
index 6a5977bc..e58bb491 100644
--- a/llvm_tools/git_test.py
+++ b/llvm_tools/git_test.py
@@ -154,7 +154,3 @@ class HelperFunctionsTest(unittest.TestCase):
"https://chromium-review.googlesource.com/c/chromiumos/overlays/"
"chromiumos-overlay/+/193147",
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/llvm_next_test.py b/llvm_tools/llvm_next_test.py
index 9b7ecd24..00aa9705 100644
--- a/llvm_tools/llvm_next_test.py
+++ b/llvm_tools/llvm_next_test.py
@@ -16,7 +16,3 @@ class Test(unittest.TestCase):
def test_all_cls_have_patchesets(self):
for cl in llvm_next.LLVM_NEXT_TESTING_CLS:
self.assertIsNotNone(cl.patch_set, f"CL {cl} needs a patch-set")
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/llvm_simple_bisect.py b/llvm_tools/llvm_simple_bisect.py
index bc756758..643361d0 100644
--- a/llvm_tools/llvm_simple_bisect.py
+++ b/llvm_tools/llvm_simple_bisect.py
@@ -344,7 +344,3 @@ def main():
except Exception:
logging.exception("Uncaught Exception in main")
abort(opts.never_abort)
-
-
-if __name__ == "__main__":
- main()
diff --git a/llvm_tools/manifest_utils_test.py b/llvm_tools/manifest_utils_test.py
index 21a12640..2df6e25a 100644
--- a/llvm_tools/manifest_utils_test.py
+++ b/llvm_tools/manifest_utils_test.py
@@ -86,7 +86,3 @@ class TestManifestUtils(unittest.TestCase):
manifest_utils.extract_current_llvm_hash_from_xml(root),
"abcd",
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/nightly_revert_checker.py b/llvm_tools/nightly_revert_checker.py
index 65138e4e..d0f67042 100644
--- a/llvm_tools/nightly_revert_checker.py
+++ b/llvm_tools/nightly_revert_checker.py
@@ -627,7 +627,3 @@ def main(argv: List[str]) -> int:
_write_state(state_file, new_state)
return 0
-
-
-if __name__ == "__main__":
- sys.exit(main(sys.argv[1:]))
diff --git a/llvm_tools/nightly_revert_checker_test.py b/llvm_tools/nightly_revert_checker_test.py
index 9e0734f6..8faf0f07 100644
--- a/llvm_tools/nightly_revert_checker_test.py
+++ b/llvm_tools/nightly_revert_checker_test.py
@@ -302,7 +302,3 @@ class Test(unittest.TestCase):
"checker's SHA autodetection may need an update. Please file a "
"bug at go/crostc-bug if an update is needed. Thanks!",
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/patch_manager.py b/llvm_tools/patch_manager.py
index bd2a8b95..016d76d8 100644
--- a/llvm_tools/patch_manager.py
+++ b/llvm_tools/patch_manager.py
@@ -313,7 +313,3 @@ def main(sys_argv: List[str]):
if args_output.failure_mode in dispatch_table:
dispatch_table[args_output.failure_mode](args_output)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/llvm_tools/patch_manager_test.py b/llvm_tools/patch_manager_test.py
index 9c8e675f..ebf8a996 100644
--- a/llvm_tools/patch_manager_test.py
+++ b/llvm_tools/patch_manager_test.py
@@ -211,7 +211,3 @@ class PatchManagerTest(unittest.TestCase):
_apply_patch_entry_mock3,
patch_manager.GitBisectionCode.SKIP,
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/patch_utils_test.py b/llvm_tools/patch_utils_test.py
index 75c50125..11f775d5 100644
--- a/llvm_tools/patch_utils_test.py
+++ b/llvm_tools/patch_utils_test.py
@@ -406,6 +406,3 @@ index c5fd68299eb..4c6e15eeeb9 100644
// Now we need to do some global optimization transforms.
// FIXME: It would seem like these should come first in the optimization
"""
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/revert_checker.py b/llvm_tools/revert_checker.py
index 17914ba8..25c56e36 100644
--- a/llvm_tools/revert_checker.py
+++ b/llvm_tools/revert_checker.py
@@ -315,7 +315,3 @@ def _main() -> None:
else revert.reverted_sha
)
print(f"{sha_fmt} claims to revert {reverted_sha_fmt}")
-
-
-if __name__ == "__main__":
- _main()
diff --git a/llvm_tools/setup_for_workon.py b/llvm_tools/setup_for_workon.py
index 6b51553a..e8eef5c6 100644
--- a/llvm_tools/setup_for_workon.py
+++ b/llvm_tools/setup_for_workon.py
@@ -293,7 +293,3 @@ def main(argv: List[str]) -> None:
logging.info(
"Successfully workon-ed: %s", shlex.join([str(c) for c in cmd])
)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/llvm_tools/stabilize_all_llvm_packages.py b/llvm_tools/stabilize_all_llvm_packages.py
index f763c68e..0f4f3430 100644
--- a/llvm_tools/stabilize_all_llvm_packages.py
+++ b/llvm_tools/stabilize_all_llvm_packages.py
@@ -134,7 +134,3 @@ def main(argv: List[str]) -> None:
stdin=subprocess.DEVNULL,
).returncode
sys.exit(return_code)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/llvm_tools/update_packages_and_run_tests.py b/llvm_tools/update_packages_and_run_tests.py
index b37623e5..f85684dd 100644
--- a/llvm_tools/update_packages_and_run_tests.py
+++ b/llvm_tools/update_packages_and_run_tests.py
@@ -400,7 +400,3 @@ def main(argv: List[str]) -> None:
if opts.retry_state:
write_last_tried_sha(opts.retry_state, new_sha)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/llvm_tools/update_packages_and_run_tests_test.py b/llvm_tools/update_packages_and_run_tests_test.py
index d6c30792..49f03eb6 100644
--- a/llvm_tools/update_packages_and_run_tests_test.py
+++ b/llvm_tools/update_packages_and_run_tests_test.py
@@ -77,7 +77,3 @@ class Test(unittest.TestCase):
),
)
mock_run.assert_called_once()
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/upload_llvm_testing_helper_cl.py b/llvm_tools/upload_llvm_testing_helper_cl.py
index c70e8dca..b59e2118 100644
--- a/llvm_tools/upload_llvm_testing_helper_cl.py
+++ b/llvm_tools/upload_llvm_testing_helper_cl.py
@@ -177,7 +177,3 @@ def main(argv: List[str]) -> None:
branch=git_utils.CROS_MAIN_BRANCH,
ref=helper_sha,
)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/llvm_tools/upload_llvm_testing_helper_cl_test.py b/llvm_tools/upload_llvm_testing_helper_cl_test.py
index b513ae99..f978fa39 100644
--- a/llvm_tools/upload_llvm_testing_helper_cl_test.py
+++ b/llvm_tools/upload_llvm_testing_helper_cl_test.py
@@ -62,7 +62,3 @@ class Test(test_helpers.TempDirTestCase):
self.assertIn(
upload_llvm_testing_helper_cl.DISABLE_WARNINGS_BLOCK, new_contents
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/llvm_tools/werror_logs.py b/llvm_tools/werror_logs.py
index 416644db..08c5a36f 100644
--- a/llvm_tools/werror_logs.py
+++ b/llvm_tools/werror_logs.py
@@ -570,7 +570,3 @@ def main(argv: List[str]) -> None:
assert getattr(opts, "func", None), "Unknown subcommand?"
opts.func(opts)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/llvm_tools/werror_logs_test.py b/llvm_tools/werror_logs_test.py
index 53b7f9b0..a35a9cf4 100644
--- a/llvm_tools/werror_logs_test.py
+++ b/llvm_tools/werror_logs_test.py
@@ -412,7 +412,3 @@ class Test(test_helpers.TempDirTestCase):
unpack_dir, download_dir, gs_urls
)
self.assertEqual(run_mock.call_count, 3)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/make_root_writable.py b/make_root_writable.py
index b1bfb217..a558eadc 100644
--- a/make_root_writable.py
+++ b/make_root_writable.py
@@ -155,7 +155,7 @@ def Main(argv):
"a script that calls this one).",
)
- options = parser.parse_args(argv[1:])
+ options = parser.parse_args(argv)
# Common initializations
log_level = "average"
@@ -251,8 +251,3 @@ def Main(argv):
)
return ret
-
-
-if __name__ == "__main__":
- retval = Main(sys.argv)
- sys.exit(retval)
diff --git a/pgo_tools/benchmark_pgo_profiles.py b/pgo_tools/benchmark_pgo_profiles.py
index 33de26d8..9270500b 100644
--- a/pgo_tools/benchmark_pgo_profiles.py
+++ b/pgo_tools/benchmark_pgo_profiles.py
@@ -280,7 +280,3 @@ def main(argv: List[str]):
validate_profiles(parser, profiles)
run_benchmark(opts.thinlto, profiles)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/pgo_tools/benchmark_pgo_profiles_test.py b/pgo_tools/benchmark_pgo_profiles_test.py
index 56ff63cf..baa7d7d6 100644
--- a/pgo_tools/benchmark_pgo_profiles_test.py
+++ b/pgo_tools/benchmark_pgo_profiles_test.py
@@ -45,7 +45,3 @@ class Test(unittest.TestCase):
self.assertIs(
profile, benchmark_pgo_profiles.parse_profile_path(str(profile))
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/pgo_tools/create_chroot_and_generate_pgo_profile.py b/pgo_tools/create_chroot_and_generate_pgo_profile.py
index 71339512..40f02918 100644
--- a/pgo_tools/create_chroot_and_generate_pgo_profile.py
+++ b/pgo_tools/create_chroot_and_generate_pgo_profile.py
@@ -255,7 +255,3 @@ def main(argv: List[str]):
bootstrap_chroot_info.chroot_name,
bootstrap_chroot_info.out_dir_name,
)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/pgo_tools/create_chroot_and_generate_pgo_profile_test.py b/pgo_tools/create_chroot_and_generate_pgo_profile_test.py
index c3f1fa4e..41671ee8 100644
--- a/pgo_tools/create_chroot_and_generate_pgo_profile_test.py
+++ b/pgo_tools/create_chroot_and_generate_pgo_profile_test.py
@@ -69,7 +69,3 @@ class Test(unittest.TestCase):
),
repo_root / "my-out" / "tmp/file/path",
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/pgo_tools/ensure_pgo_is_a_win.py b/pgo_tools/ensure_pgo_is_a_win.py
index 69087e23..6d1b8ae0 100644
--- a/pgo_tools/ensure_pgo_is_a_win.py
+++ b/pgo_tools/ensure_pgo_is_a_win.py
@@ -84,7 +84,3 @@ def main(argv: List[str]):
f"Minimum speedup of {minimum_speedup} is greater than "
f"observed speedup of {pgo_speedup}. Exiting with error."
)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/pgo_tools/ensure_pgo_is_a_win_test.py b/pgo_tools/ensure_pgo_is_a_win_test.py
index 531bc37e..1aab7580 100644
--- a/pgo_tools/ensure_pgo_is_a_win_test.py
+++ b/pgo_tools/ensure_pgo_is_a_win_test.py
@@ -46,7 +46,3 @@ class Test(unittest.TestCase):
self.assertEqual(
ensure_pgo_is_a_win.calculate_pgo_speedup(no_profile, profile), 1.5
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/pgo_tools/generate_pgo_profile.py b/pgo_tools/generate_pgo_profile.py
index 3cc3524e..bd67b231 100644
--- a/pgo_tools/generate_pgo_profile.py
+++ b/pgo_tools/generate_pgo_profile.py
@@ -470,7 +470,3 @@ def main(argv: List[str]):
logging.info("Removing now-obsolete tempdir")
shutil.rmtree(tempdir)
logging.info("PGO profile is available at %s.", output)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/pgo_tools/generate_pgo_profile_test.py b/pgo_tools/generate_pgo_profile_test.py
index a506016d..47fe6847 100644
--- a/pgo_tools/generate_pgo_profile_test.py
+++ b/pgo_tools/generate_pgo_profile_test.py
@@ -106,7 +106,3 @@ class Test(unittest.TestCase):
self.assertIn(p, run_cmd)
self.assertNotIn(not_a_profile, run_cmd)
self.assertIn(f"--output={result}", run_cmd)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/pgo_tools/pgo_utils_test.py b/pgo_tools/pgo_utils_test.py
index 6d0a9c89..03efa0ae 100644
--- a/pgo_tools/pgo_utils_test.py
+++ b/pgo_tools/pgo_utils_test.py
@@ -102,7 +102,3 @@ class Test(unittest.TestCase):
# This test ensures this `with`'s `__exit__` block doesn't `raise`.
with pgo_utils.temporary_file("foo_bar_") as tmp:
tmp.unlink()
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/pgo_tools_rust/pgo_rust.py b/pgo_tools_rust/pgo_rust.py
index 00607ba6..2eee81c2 100644
--- a/pgo_tools_rust/pgo_rust.py
+++ b/pgo_tools_rust/pgo_rust.py
@@ -560,7 +560,7 @@ def main(argv: List[str]) -> int:
)
parser = argparse.ArgumentParser(
- prog=argv[0],
+ prog=sys.argv[0],
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
@@ -662,7 +662,7 @@ def main(argv: List[str]) -> int:
"rustc versions",
)
- args = parser.parse_args(argv[1:])
+ args = parser.parse_args(argv)
(LOCAL_BASE / "crates").mkdir(parents=True, exist_ok=True)
(LOCAL_BASE / "llvm-profraw").mkdir(parents=True, exist_ok=True)
@@ -672,7 +672,3 @@ def main(argv: List[str]) -> int:
args.func(args)
return 0
-
-
-if __name__ == "__main__":
- sys.exit(main(sys.argv))
diff --git a/remote_test.py b/remote_test.py
index 01f3fe89..f7c98b86 100644
--- a/remote_test.py
+++ b/remote_test.py
@@ -108,7 +108,3 @@ def Main(argv):
board = ce.CrosLearnBoard(options.chromeos_root, options.remote)
print(board)
return 0
-
-
-if __name__ == "__main__":
- Main(sys.argv[1:])
diff --git a/run_tests_for.py b/run_tests_for.py
index 0fb75102..ecbcd510 100644
--- a/run_tests_for.py
+++ b/run_tests_for.py
@@ -222,7 +222,3 @@ def main(argv):
pool, tests_to_run, args.timeout, show_all_output
)
return 0 if success else 1
-
-
-if __name__ == "__main__":
- sys.exit(main(sys.argv[1:]))
diff --git a/rust_tools/auto_update_rust_bootstrap.py b/rust_tools/auto_update_rust_bootstrap.py
index 80acc61d..c665514f 100644
--- a/rust_tools/auto_update_rust_bootstrap.py
+++ b/rust_tools/auto_update_rust_bootstrap.py
@@ -850,7 +850,3 @@ def main(argv: List[str]):
if had_recoverable_error:
sys.exit("Exiting uncleanly due to above error(s).")
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/rust_tools/auto_update_rust_bootstrap_test.py b/rust_tools/auto_update_rust_bootstrap_test.py
index 9987ca07..2af5bd83 100644
--- a/rust_tools/auto_update_rust_bootstrap_test.py
+++ b/rust_tools/auto_update_rust_bootstrap_test.py
@@ -495,7 +495,3 @@ class Test(unittest.TestCase):
auto_update_rust_bootstrap.maybe_delete_old_rust_bootstrap_ebuilds(
tempdir, rust_bootstrap, dry_run=True
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/rust_tools/copy_rust_bootstrap.py b/rust_tools/copy_rust_bootstrap.py
index 67d6c48e..a6ec32a4 100644
--- a/rust_tools/copy_rust_bootstrap.py
+++ b/rust_tools/copy_rust_bootstrap.py
@@ -197,7 +197,3 @@ def main(argv: List[str]):
)
else:
_upload(file_to_upload, target_path, opts.force)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/rust_tools/rust_uprev.py b/rust_tools/rust_uprev.py
index 0eec569d..c5e14697 100644
--- a/rust_tools/rust_uprev.py
+++ b/rust_tools/rust_uprev.py
@@ -1190,7 +1190,3 @@ def main() -> None:
run_step(
"create rust uprev CL", lambda: create_new_commit(args.uprev)
)
-
-
-if __name__ == "__main__":
- main()
diff --git a/rust_tools/rust_uprev_test.py b/rust_tools/rust_uprev_test.py
index 95156268..e7942cad 100644
--- a/rust_tools/rust_uprev_test.py
+++ b/rust_tools/rust_uprev_test.py
@@ -775,7 +775,3 @@ class RustUprevOtherStagesTests(unittest.TestCase):
["sudo", "emerge", "-j", "-G"]
+ [f"cross-{x}/gcc" for x in cros_targets + ["arm-none-eabi"]]
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/rust_tools/rust_watch.py b/rust_tools/rust_watch.py
index 8da3ea2c..8333e0b4 100644
--- a/rust_tools/rust_watch.py
+++ b/rust_tools/rust_watch.py
@@ -425,7 +425,3 @@ def main(argv: List[str]) -> None:
last_gentoo_sha=newest_sha,
),
)
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
diff --git a/rust_tools/rust_watch_test.py b/rust_tools/rust_watch_test.py
index 0df7c00b..c383b7f8 100644
--- a/rust_tools/rust_watch_test.py
+++ b/rust_tools/rust_watch_test.py
@@ -180,7 +180,3 @@ class Test(unittest.TestCase):
newest_release=rust_watch.RustReleaseVersion(1, 0, 0),
)
)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/seccomp_tools/mass_seccomp_editor/mass_seccomp_editor.py b/seccomp_tools/mass_seccomp_editor/mass_seccomp_editor.py
index 4d7bc263..ee4d4b89 100644
--- a/seccomp_tools/mass_seccomp_editor/mass_seccomp_editor.py
+++ b/seccomp_tools/mass_seccomp_editor/mass_seccomp_editor.py
@@ -280,7 +280,3 @@ def parse_args() -> Any:
" Does nothing without --edit.",
)
return parser.parse_args()
-
-
-if __name__ == "__main__":
- main()
diff --git a/seccomp_tools/mass_seccomp_editor/mass_seccomp_editor_test.py b/seccomp_tools/mass_seccomp_editor/mass_seccomp_editor_test.py
index 3d24ae0c..bfd6308c 100644
--- a/seccomp_tools/mass_seccomp_editor/mass_seccomp_editor_test.py
+++ b/seccomp_tools/mass_seccomp_editor/mass_seccomp_editor_test.py
@@ -32,7 +32,3 @@ class TestMassSeccompEditor(unittest.TestCase):
["fstat", "dup", "fizzbuzz"], TEST_FP
)
self.assertEqual(out, set(["dup", "fizzbuzz"]))
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tc_enter_chroot.py b/tc_enter_chroot.py
index f996182b..4d0f0edf 100644
--- a/tc_enter_chroot.py
+++ b/tc_enter_chroot.py
@@ -340,8 +340,3 @@ def CreateSymlink(target, link_name):
command = "rm -rf " + link_name
command_executer.GetCommandExecuter().RunCommand(command)
os.symlink(target, link_name)
-
-
-if __name__ == "__main__":
- retval = Main(sys.argv)
- sys.exit(retval)
diff --git a/toolchain_utils_githooks/check-presubmit.py b/toolchain_utils_githooks/check-presubmit.py
index 127726ad..1c458026 100755
--- a/toolchain_utils_githooks/check-presubmit.py
+++ b/toolchain_utils_githooks/check-presubmit.py
@@ -761,8 +761,9 @@ def check_tests(
files: List[str],
) -> CheckResult:
"""Runs tests."""
+ run_tests_for = os.path.join(toolchain_utils_root, "py", "bin", "run_tests_for.py")
exit_code, stdout_and_stderr = run_command_unchecked(
- [os.path.join(toolchain_utils_root, "run_tests_for.py"), "--"] + files,
+ [run_tests_for, "--"] + files,
toolchain_utils_root,
)
return CheckResult(
@@ -1071,6 +1072,5 @@ def main(argv: List[str]) -> int:
return 1
return 0
-
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
diff --git a/update_telemetry_defaults.py b/update_telemetry_defaults.py
index 49145ac6..34b157e3 100644
--- a/update_telemetry_defaults.py
+++ b/update_telemetry_defaults.py
@@ -199,8 +199,3 @@ def Main():
while not done:
done = defaults.GetUserInput()
return 0
-
-
-if __name__ == "__main__":
- retval = Main()
- sys.exit(retval)