Skip to content

Commit

Permalink
Allow @glob goals to be parameterized #155
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Jan 5, 2024
1 parent 5f8c46d commit b393af9
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
3 changes: 2 additions & 1 deletion makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern,nfMax,
registerGoal(globSingle ? priv : 1, gi = globGoal(i))
for (j = 0; j in globPgParams; j++)
GoalParams[gi, GoalParamsCnt[gi]++] = globPgParams[j]
} if (!globSingle) { # glob on single file
}
if (!globSingle) { # glob on single file
registerGoal(priv, globAllGoal)
for (j = 0; j in globPgParams; j++)
GoalParams[globAllGoal, GoalParamsCnt[globAllGoal]++] = globPgParams[j]
Expand Down
70 changes: 70 additions & 0 deletions tests/29_glob_plus_pg.tush
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ $ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh -l
| g3pg@salut
| gpg@salut

$ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh -la
| Available goals:
| g1
| g2
| g3
| gpg@hello
| gpg@glob_test/1.txt@hello
| gpg@glob_test/2.txt@hello
| gpg@hi
| gpg@glob_test/1.txt@hi
| gpg@glob_test/2.txt@hi
| g3pg@salut
| gpg@salut
| gpg@glob_test/1.txt@salut
| gpg@glob_test/2.txt@salut

$ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh g1
| goal 'gpg@glob_test/1.txt@hello' ...
| glob_test/1.txt hello
Expand Down Expand Up @@ -49,6 +65,22 @@ $ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh -l
| g3pg@salut
| 'glob_test/*.txt@salut'

$ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh -la
| Available goals:
| g1
| g2
| g3
| 'glob_test/*.txt@hello'
| glob_test/1.txt@hello
| glob_test/2.txt@hello
| 'glob_test/*.txt@hi'
| glob_test/1.txt@hi
| glob_test/2.txt@hi
| g3pg@salut
| 'glob_test/*.txt@salut'
| glob_test/1.txt@salut
| glob_test/2.txt@salut

$ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh g1
| goal 'glob_test/1.txt@hello' ...
| glob_test/1.txt hello
Expand Down Expand Up @@ -78,3 +110,41 @@ $ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh g3
| goal 'glob_test/*.txt@salut' [empty].
| goal 'g3pg@salut' [empty].
| goal 'g3' [empty].

$ ./$MAKESURE -f tests/29_glob_plus_pg_3.sh -l
| Available goals:
| g1
| g2
| g3
| glob_test/1.txt@hello
| glob_test/1.txt@hi
| g3pg@salut
| glob_test/1.txt@salut

$ ./$MAKESURE -f tests/29_glob_plus_pg_3.sh -la
| Available goals:
| g1
| g2
| g3
| glob_test/1.txt@hello
| glob_test/1.txt@hi
| g3pg@salut
| glob_test/1.txt@salut

$ ./$MAKESURE -f tests/29_glob_plus_pg_3.sh g1
| goal 'glob_test/1.txt@hello' ...
| glob_test/1.txt hello
| goal 'g1' [empty].

$ ./$MAKESURE -f tests/29_glob_plus_pg_3.sh g2
| goal 'glob_test/1.txt@hello' ...
| glob_test/1.txt hello
| goal 'glob_test/1.txt@hi' ...
| glob_test/1.txt hi
| goal 'g2' [empty].

$ ./$MAKESURE -f tests/29_glob_plus_pg_3.sh g3
| goal 'glob_test/1.txt@salut' ...
| glob_test/1.txt salut
| goal 'g3pg@salut' [empty].
| goal 'g3' [empty].
16 changes: 16 additions & 0 deletions tests/29_glob_plus_pg_3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

@goal @glob 'glob_test/1.txt' @params P
echo "$ITEM $P"

@goal g1
@depends_on 'glob_test/1.txt' @args 'hello'

@goal g2
@depends_on 'glob_test/1.txt' @args 'hello'
@depends_on 'glob_test/1.txt' @args 'hi'

@goal g3
@depends_on g3pg @args 'salut'

@goal g3pg @params X
@depends_on 'glob_test/1.txt' @args X

0 comments on commit b393af9

Please sign in to comment.