From d150e86dfcf4c4423aced36ddceddce6c544fc85 Mon Sep 17 00:00:00 2001
From: Andre Maroneze <andre.maroneze@cea.fr>
Date: Mon, 27 Jul 2020 18:38:52 +0200
Subject: [PATCH] [analysis-scripts] check if the target is a directory before
 listing sub-targets

---
 share/analysis-scripts/summary.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/share/analysis-scripts/summary.py b/share/analysis-scripts/summary.py
index 0b2fc9c9fba..81285a7cc2d 100755
--- a/share/analysis-scripts/summary.py
+++ b/share/analysis-scripts/summary.py
@@ -46,6 +46,9 @@ def build_env(framac):
         return { **os.environ,  'PATH' : bindir + ':' + os.environ['PATH'] }
 
 def list_targets(dir):
+    if not os.path.isdir(dir):
+        raise OperationException(f"target is not a directory: {dir}")
+
     env = build_env(framac)
     res = subprocess.run(
         ["make", "--directory", dir, "--quiet", "display-targets"],
@@ -56,10 +59,9 @@ def list_targets(dir):
     res = []
     for target in targets:
         if target.endswith(".eva") or target.endswith(".parse"):
-            res.append(dir + "/" + target)
+            res += [f"{dir}/{target}"]
         else:
-            res += [dir + "/" + t for t in list_targets(target)]
-    print(f"list_targets returning: {res}")
+            res += list_targets(target)
     return res
 
 def clone_frama_c(clonedir, hash):
-- 
GitLab