diff --git a/makesure.awk b/makesure.awk index e30f8cb..4e1c118 100755 --- a/makesure.awk +++ b/makesure.awk @@ -219,7 +219,7 @@ function registerUseLib(goalName) { function handleGoal( i,goalName) { started("goal") - if (registerGoal(isPriv(), goalName=$2)) + if (registerGoal(parsePriv(), goalName=$2)) if ("@params" == $3) { if (3 == NF) addError("missing parameters") for (i=4; i <= NF; i++) @@ -255,14 +255,18 @@ function calcGlob(goalName, pattern, script, file) { quicksort(GlobFiles,0,arrLen(GlobFiles)-1) } -function isPriv() { if ("@private" != $NF) return 0; NF--; return 1 } +function parsePriv() { if ("@private" != $NF) return 0; NF--; return 1 } -function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern) { +function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern,nfMax) { started("goal_glob") - priv = isPriv() - goalName = $2; pattern = $4 - if ("@glob" == goalName) { - goalName = ""; pattern = $3 + priv = parsePriv() + if ("@glob" == goalName = $2) { + goalName = ""; pattern = $(nfMax=3) + } else + pattern = $(nfMax=4) + if (NF > nfMax) { + addError("nothing allowed after glob pattern") + return } calcGlob(goalName, pattern) globAllGoal = goalName ? goalName : pattern diff --git a/tests/12_errors.sh b/tests/12_errors.sh index 8f145a4..51ee9ce 100644 --- a/tests/12_errors.sh +++ b/tests/12_errors.sh @@ -44,3 +44,19 @@ echo 'more code in prelude' @depends_on unknown1 @lib lib2 + +@goal @private + echo 'private goal without name' + +@goal g15 should not have anything after goal name +@goal g16 # but comment is OK + +@goal g17 @glob '*.txt' should not have anything after glob pattern +@goal g18 @glob '*.txt' # but comment is OK + +@goal @glob '*.txt' should not have anything after glob pattern +@goal @glob '*.txt' should_not_have_anything_after_glob_pattern +@goal @glob '*.txt' # but comment is OK + +@goal @glob # absent glob pattern +@goal g19 @glob # absent glob pattern diff --git a/tests/12_errors.tush b/tests/12_errors.tush index 7725271..58abdaf 100644 --- a/tests/12_errors.tush +++ b/tests/12_errors.tush @@ -38,6 +38,16 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/12_errors.sh @ tests/12_errors.sh:38: @use_lib lib2 @ Lib 'lib2' is already defined: @ tests/12_errors.sh:46: @lib lib2 +@ Goal must have a name: +@ tests/12_errors.sh:48: @goal @private +@ nothing allowed after goal name: +@ tests/12_errors.sh:51: @goal g15 should not have anything after goal name +@ nothing allowed after glob pattern: +@ tests/12_errors.sh:54: @goal g17 @glob '*.txt' should not have anything after glob pattern +@ nothing allowed after glob pattern: +@ tests/12_errors.sh:57: @goal @glob '*.txt' should not have anything after glob pattern +@ nothing allowed after glob pattern: +@ tests/12_errors.sh:58: @goal @glob '*.txt' should_not_have_anything_after_glob_pattern @ Goal 'g1' has unknown dependency 'unknown': @ tests/12_errors.sh:18: @depends_on unknown @ Goal 'g2' uses unknown lib 'unknown':