From 6fb3bcebd2cdb555260b209132062e80dec8f5da Mon Sep 17 00:00:00 2001 From: xonix Date: Thu, 26 Jan 2023 02:24:16 +0200 Subject: [PATCH] Parameterized goals #115 --- makesure.awk | 26 ++++++++++++++------------ tests/12_errors.tush | 4 ++++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/makesure.awk b/makesure.awk index 4155320..f9f72b9 100755 --- a/makesure.awk +++ b/makesure.awk @@ -260,23 +260,25 @@ function parsePriv() { if ("@private" != $NF) return 0; NF--; return 1 } function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern,nfMax) { started("goal_glob") priv = parsePriv() - if ("@glob" == goalName = $2) { + if ("@glob" == (goalName = $2)) { goalName = ""; pattern = $(nfMax=3) } else pattern = $(nfMax=4) - if (NF > nfMax) { + if (NF > nfMax) addError("nothing allowed after glob pattern") - return - } - calcGlob(goalName, pattern) - globAllGoal = goalName ? goalName : pattern - globSingle = GlobCnt == 1 && globAllGoal == globGoal(0) - for (i=0; i < GlobCnt; i++) - registerGoal(globSingle ? priv : 1, globGoal(i)) - if (!globSingle) { # glob on single file - registerGoal(priv, globAllGoal) + else if (pattern=="") + addError("absent glob pattern") + else { + calcGlob(goalName, pattern) + globAllGoal = goalName ? goalName : pattern + globSingle = GlobCnt == 1 && globAllGoal == globGoal(0) for (i=0; i < GlobCnt; i++) - registerDependency(globAllGoal, globGoal(i)) + registerGoal(globSingle ? priv : 1, globGoal(i)) + if (!globSingle) { # glob on single file + registerGoal(priv, globAllGoal) + for (i=0; i < GlobCnt; i++) + registerDependency(globAllGoal, globGoal(i)) + } } } diff --git a/tests/12_errors.tush b/tests/12_errors.tush index 58abdaf..6daf041 100644 --- a/tests/12_errors.tush +++ b/tests/12_errors.tush @@ -48,6 +48,10 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/12_errors.sh @ 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 +@ absent glob pattern: +@ tests/12_errors.sh:61: @goal @glob # absent glob pattern +@ absent glob pattern: +@ tests/12_errors.sh:62: @goal g19 @glob # absent glob pattern @ Goal 'g1' has unknown dependency 'unknown': @ tests/12_errors.sh:18: @depends_on unknown @ Goal 'g2' uses unknown lib 'unknown':