From 8463c22955617b4948047e5aeb3e65f683decee7 Mon Sep 17 00:00:00 2001 From: xonix Date: Sun, 4 Sep 2022 00:07:48 +0300 Subject: [PATCH] Add missing tests for `@lib` #111 and fix the problem with `@goal @glob` + `@lib` --- makesure.awk | 6 ++++-- tests/11_goal_glob.tush | 30 ++++++++++++++++++++++++++++++ tests/11_goal_glob_lib.sh | 14 ++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 tests/11_goal_glob_lib.sh diff --git a/makesure.awk b/makesure.awk index 2d0f1d6..6632c3a 100755 --- a/makesure.awk +++ b/makesure.awk @@ -11,6 +11,7 @@ BEGIN { split("",Options) split("",GoalNames) # list split("",GoalsByName) # name -> private + split("",CodePre) # name -> pre-body (should also go before lib) split("",Code) # name -> body split("",DefineOverrides) # k -> "" DefinesCode="" @@ -421,6 +422,7 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) { goalBody[0] = "" addLine(goalBody, preludeCode) + addLine(goalBody, CodePre[goalName]) if (goalName in GoalToLib) addLine(goalBody, Lib[GoalToLib[goalName]]) @@ -548,8 +550,8 @@ function addCodeLine(line, goalName, name, i) { Lib[name] = addL(Lib[name], line) } else if ("goal_glob" == Mode) { for (i=0; i < GlobCnt; i++){ - if (!Code[goalName = globGoal(i)]) - addCodeLineToGoal(goalName, makeGlobVarsCode(i)) + if (!CodePre[goalName = globGoal(i)]) + CodePre[goalName] = makeGlobVarsCode(i) addCodeLineToGoal(goalName, line) } } else diff --git a/tests/11_goal_glob.tush b/tests/11_goal_glob.tush index e176c94..e949d2e 100644 --- a/tests/11_goal_glob.tush +++ b/tests/11_goal_glob.tush @@ -56,3 +56,33 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh glob_goal_name | goal 'glob_goal_name@11_goal_glob_10.txt' ... | glob_goal_name ::: 11_goal_glob_10.txt :: 3 :: 4 | goal 'glob_goal_name' [empty]. + +$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob_lib.sh '11_goal_glob*.txt' +| goal '11_goal_glob_1.txt' ... +| Unnamed lib ::: 11_goal_glob_1.txt :: 0 :: 4 +| @glob ::: 11_goal_glob_1.txt :: 0 :: 4 +| goal '11_goal_glob_2.txt' ... +| Unnamed lib ::: 11_goal_glob_2.txt :: 1 :: 4 +| @glob ::: 11_goal_glob_2.txt :: 1 :: 4 +| goal '11_goal_glob_3.txt' ... +| Unnamed lib ::: 11_goal_glob_3.txt :: 2 :: 4 +| @glob ::: 11_goal_glob_3.txt :: 2 :: 4 +| goal '11_goal_glob_10.txt' ... +| Unnamed lib ::: 11_goal_glob_10.txt :: 3 :: 4 +| @glob ::: 11_goal_glob_10.txt :: 3 :: 4 +| goal '11_goal_glob*.txt' [empty]. + +$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob_lib.sh glob_goal_name +| goal 'glob_goal_name@11_goal_glob_1.txt' ... +| lib lib_name ::: 11_goal_glob_1.txt :: 0 :: 4 +| glob_goal_name ::: 11_goal_glob_1.txt :: 0 :: 4 +| goal 'glob_goal_name@11_goal_glob_2.txt' ... +| lib lib_name ::: 11_goal_glob_2.txt :: 1 :: 4 +| glob_goal_name ::: 11_goal_glob_2.txt :: 1 :: 4 +| goal 'glob_goal_name@11_goal_glob_3.txt' ... +| lib lib_name ::: 11_goal_glob_3.txt :: 2 :: 4 +| glob_goal_name ::: 11_goal_glob_3.txt :: 2 :: 4 +| goal 'glob_goal_name@11_goal_glob_10.txt' ... +| lib lib_name ::: 11_goal_glob_10.txt :: 3 :: 4 +| glob_goal_name ::: 11_goal_glob_10.txt :: 3 :: 4 +| goal 'glob_goal_name' [empty]. diff --git a/tests/11_goal_glob_lib.sh b/tests/11_goal_glob_lib.sh new file mode 100644 index 0000000..cf4f9bc --- /dev/null +++ b/tests/11_goal_glob_lib.sh @@ -0,0 +1,14 @@ + +@lib + echo "Unnamed lib ::: $ITEM :: $INDEX :: $TOTAL" + +@goal @glob 11_goal_glob*.txt +@use_lib + echo "@glob ::: $ITEM :: $INDEX :: $TOTAL" + +@goal glob_goal_name @glob 11_goal_glob*.txt +@use_lib lib_name + echo "glob_goal_name ::: $ITEM :: $INDEX :: $TOTAL" + +@lib lib_name + echo "lib lib_name ::: $ITEM :: $INDEX :: $TOTAL"