From add499678c7bcf7457c353ff98d82bd99972545d Mon Sep 17 00:00:00 2001
From: Virgile Prevosto <virgile.prevosto@m4x.org>
Date: Tue, 20 Sep 2022 15:31:39 +0200
Subject: [PATCH] [scripts] ensures $@/running gets erased even when Frama-C
 calls fails

---
 share/analysis-scripts/analysis.mk | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/share/analysis-scripts/analysis.mk b/share/analysis-scripts/analysis.mk
index f029ddd5773..0970e1d96a2 100644
--- a/share/analysis-scripts/analysis.mk
+++ b/share/analysis-scripts/analysis.mk
@@ -184,7 +184,9 @@ SHELL        := $(shell which bash)
 	      -metrics -metrics-log a:$@/metrics.log \
 	      -save $@/framac.sav \
 	      -print -ocode $@/framac.ast -then -no-print \
-	    || ($(RM) $@/stats.txt && false) # Prevents having error code reporting in stats.txt
+	    || (mv -f $@/{running,command} &&
+	        $(RM) $@/stats.txt &&
+	        false) # Prevents having error code reporting in stats.txt
 	} 2>&1 |
 	  $(SED_UNBUFFERED) '/\[metrics\]/,999999d' |
 	  tee $@/parse.log
@@ -220,14 +222,16 @@ endef
 	      -scope-log w:$@/warnings.log \
 	      -eva-log w:$@/warnings.log \
 	      -then \
-              -remove-projects @all_but_current -save $@/framac.sav \
+	      -remove-projects @all_but_current -save $@/framac.sav \
 	      -then \
 	      -report-csv $@/alarms.csv -report-no-proven \
 	      -report-log w:$@/warnings.log \
 	      -metrics-eva-cover \
 	      -metrics-log a:$@/metrics.log \
 	      -nonterm -nonterm-log a:$@/nonterm.log \
-	    || ($(RM) $@/stats.txt && false) # Prevents having error code reporting in stats.txt
+	    || (mv -f $@/{running,command} &&
+	        $(RM) $@/stats.txt &&
+	        false) # Prevents having error code reporting in stats.txt
 	} 2>&1 |
 	  $(SED_UNBUFFERED) '/\[eva\] Values at end of function/,999999d' |
 	  tee $@/eva.log
@@ -260,7 +264,9 @@ endef
 	      -then \
 	      -report-csv $@/alarms.csv -report-no-proven \
 	      -report-log w:$@/warnings.log \
-	    || ($(RM) $@/stats.txt && false) # Prevents having error code reporting in stats.txt
+	    || (mv -f $@/{running,command} &&
+	        $(RM) $@/stats.txt &&
+	        false) # Prevents having error code reporting in stats.txt
 	} 2>&1 |
 	  tee $@/wp.log
 	{
-- 
GitLab