From df75777ed9d256f84359e6de99d7bbb3b9bec81b Mon Sep 17 00:00:00 2001 From: Philipp Wendler Date: Thu, 27 Jun 2024 07:54:04 +0200 Subject: [PATCH] Optimization of CPAchecker's tool-info module We do not need to scan through the src directory of CPAchecker if we are not going to use the information anyway. So check this first. --- benchexec/tools/cpachecker.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/benchexec/tools/cpachecker.py b/benchexec/tools/cpachecker.py index 07044226f..041f24879 100644 --- a/benchexec/tools/cpachecker.py +++ b/benchexec/tools/cpachecker.py @@ -70,14 +70,17 @@ def executable(self, tool_locator): # If this is a source checkout of CPAchecker, we heuristically check that # sources are not newer than binaries (cpachecker.jar or files in bin/). try: - if os.path.isdir(src_dir): + has_jar = os.path.isfile(jar_file) + has_cls = os.path.isdir(cls_dir) + + if os.path.isdir(src_dir) and (has_jar or has_cls): src_mtime = self._find_newest_mtime(src_dir) - if os.path.isfile(jar_file): + if has_jar: if src_mtime > os.stat(jar_file).st_mtime: sys.exit("CPAchecker JAR is not uptodate, run 'ant jar'!") - elif os.path.isdir(cls_dir): + elif has_cls: if src_mtime > self._find_newest_mtime(cls_dir): sys.exit("CPAchecker build is not uptodate, run 'ant'!") except OSError as e: