Skip to content

Commit 6b37a77

Browse files
committed
handle ctrl-c
1 parent 2069d58 commit 6b37a77

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

failLoopster.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env bash
2-
echo "${this_new_name},${model_name},${diff},${loopster_count},fail" >> score.csv
2+
echo "${this_new_name},${model_name},${diff},${loopster_count},loopster-fail" >> score.csv

fantasyloop.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@ for h_lib in $(ls ./src/*lib.h); do
1313
done
1414
}
1515

16+
add_score() {
17+
SCORE_MESSAGE=$1
18+
echo "${this_new_name},${model_name},${diff},${loopster_count},${SCORE_MESSAGE}" >> score.csv
19+
}
20+
21+
# Function to be called when Ctrl+C is pressed
22+
ctrl_c() {
23+
echo -e "\n** Ouch! SIGINT received (Ctrl+C). Performing cleanup..." >&2
24+
# Add your cleanup logic here (e.g., remove temporary files, stop services)
25+
add_score "interrupt-fail"
26+
#echo "${this_new_name},${model_name},${diff},${loopster_count},interrupt-fail" >> score.csv
27+
echo "** Cleanup complete. Exiting script." >&2
28+
exit 1 # Exit the script after handling the signal
29+
}
30+
# Set the trap: call the ctrl_c function when SIGINT (INT) is received
31+
trap ctrl_c INT
32+
1633
clean_dirty_git () {
1734
if [[ $(git status --porcelain) ]]; then
1835
echo "Git working directory is dirty. committing everything..."
@@ -69,7 +86,8 @@ do_aider () {
6986
set +e
7087
bats test/full.bats
7188
if [[ ! $? -eq 0 ]]; then
72-
echo "${this_new_name},${model_name},${diff},fail" > score.csv
89+
add_score "initial-fail"
90+
#echo "${this_new_name},${model_name},${diff},${loopster_count},initial-fail" >> score.csv
7391
loopster -c 5 \
7492
--success-cleanup ./successLoopster.sh \
7593
--fail-cleanup ./failLoopster.sh \
@@ -78,7 +96,8 @@ do_aider () {
7896
else
7997
clean_dirty_git
8098
git checkout -b "${this_new_name}_success"
81-
echo "${this_new_name},${model_name},${diff},${loopster_count},eagle" >> score.csv
99+
add_score "eagle"
100+
#echo "${this_new_name},${model_name},${diff},${loopster_count},eagle" >> score.csv
82101
fi
83102
#set -e
84103
echo $reads|grep "src/$this_lib_file" > /dev/null

successLoopster.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env bash
2-
echo "${this_new_name},${model_name},${diff},${loopster_count},success" >> score.csv
2+
echo "${this_new_name},${model_name},${diff},${loopster_count},loopster-success" >> score.csv

0 commit comments

Comments
 (0)