[libvirt PATCH 07/10] clang-tidy: Add shuffle
Tim Wiederhake
twiederh at redhat.com
Fri Feb 12 13:25:31 UTC 2021
Randomizing the order of files to scan has no impact for local use of the
script. The same holds true for use in the CI, if the amount of cached
files is big enough for the entire scan to finish before timeout.
If the cache is empty or not filled enough to ensure timely completion,
randomizing the order of files makes it more likely to spent time on caching
new files rather than hashing already cached files to check for the presence
of a cache file.
Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
scripts/run-clang-tidy.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/scripts/run-clang-tidy.py b/scripts/run-clang-tidy.py
index 54eb0ea584..1d1038df0f 100755
--- a/scripts/run-clang-tidy.py
+++ b/scripts/run-clang-tidy.py
@@ -6,6 +6,7 @@ import json
import multiprocessing
import os
import queue
+import random
import re
import shlex
import subprocess
@@ -61,6 +62,11 @@ def parse_args():
dest="allow_timeout",
action="store_true",
help="Do not treat timeout as failure if set")
+ parser.add_argument(
+ "--shuffle-input",
+ dest="shuffle_input",
+ action="store_true",
+ help="Randomize order of files to check")
return parser.parse_args()
@@ -188,6 +194,8 @@ for _ in range(args.thread_num):
with open(os.path.join(args.build_dir, "compile_commands.json")) as f:
compile_commands = json.load(f)
+ if args.shuffle_input:
+ random.shuffle(compile_commands)
for compile_command in compile_commands:
items.put(compile_command)
--
2.26.2
More information about the libvir-list
mailing list