Skip to content

Commit

Permalink
Add missing tests for @lib #111 and fix the problem with `@goal @gl…
Browse files Browse the repository at this point in the history
…ob` + `@lib`
  • Loading branch information
xonixx committed Sep 3, 2022
1 parent 510fabb commit 8463c22
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
6 changes: 4 additions & 2 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down Expand Up @@ -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]])

Expand Down Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions tests/11_goal_glob.tush
Original file line number Diff line number Diff line change
Expand Up @@ -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].
14 changes: 14 additions & 0 deletions tests/11_goal_glob_lib.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 8463c22

Please sign in to comment.