From 80cb8a376f36d5253744781cfea7d6e08899a8e9 Mon Sep 17 00:00:00 2001 From: xonix Date: Sat, 18 Sep 2021 22:50:23 +0300 Subject: [PATCH] Improvement to `@goal @glob` #46 --- makesure.awk | 14 ++++++++------ tests/11_goal_glob.tush | 29 +++++++++++++++++++++++++---- tests/11_goal_glob_10.txt | 1 + 3 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 tests/11_goal_glob_10.txt diff --git a/makesure.awk b/makesure.awk index abbe9bb..825d389 100755 --- a/makesure.awk +++ b/makesure.awk @@ -12,13 +12,14 @@ BEGIN { split("",Options) split("",GoalNames) # list split("",GoalsByName) # name -> private + split("",Glob) # name -> pattern split("",Code) # name -> body split("",DefineOverrides) # k -> "" DefinesFile="" split("",Dependencies) # name,i -> dep goal split("",DependenciesLineNo) # name,i -> line no. - split("",DependenciesCnt) # name -> dep cnd - split("",Doc) # name -> doc str + split("",DependenciesCnt) # name -> dep cnd + split("",Doc) # name -> doc str split("",ReachedIf) # name -> condition line split("",GlobFiles) # list split("",GlobGoals) # list @@ -214,6 +215,7 @@ function registerGoal(goalName, priv) { } function calcGlob(goalName, pattern, script, file) { + Glob[goalName] = pattern split("",GlobGoals) split("",GlobFiles) script = MyDirScript ";for f in ./" pattern ";do test -e \"$f\" && echo \"$f\";done" @@ -242,19 +244,19 @@ function handleGoalGlob( goalName,g,priv,i,pattern) { goalName = "" } else $3 = "" calcGlob(goalName, pattern = trim($0)) - registerGoal(goalName = goalName ? goalName : pattern, priv) for (i=0; i in GlobGoals; i++){ registerDependency(goalName, g = GlobGoals[i]) registerGoal(g, 1) } + registerGoal(goalName = goalName ? goalName : pattern, priv) } function handleDoc( i) { checkGoalOnly() - if ("goal" == Mode) - registerDoc(currentGoalName()) - else { + registerDoc(currentGoalName()) + + if ("goal_glob" == Mode) { for (i=0; i in GlobGoals; i++){ registerDoc(GlobGoals[i]) } diff --git a/tests/11_goal_glob.tush b/tests/11_goal_glob.tush index 7c84320..fca4e52 100644 --- a/tests/11_goal_glob.tush +++ b/tests/11_goal_glob.tush @@ -1,14 +1,35 @@ -$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh test1 -l +$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh -l | Available goals: -| 11_goal_glob_1.txt : test goal_glob -| 11_goal_glob_2.txt : test goal_glob -| 11_goal_glob_3.txt : test goal_glob +| 11_goal_glob*.txt : test goal_glob +| non-existent-glob* +| test1 +| test2 +| goal_name + +$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh -la +| Available goals: +| 11_goal_glob_1.txt : test goal_glob +| 11_goal_glob_2.txt : test goal_glob +| 11_goal_glob_3.txt : test goal_glob +| 11_goal_glob_10.txt : test goal_glob +| 11_goal_glob*.txt : test goal_glob +| non-existent-glob* | test1 | test2 | goal_name@11_goal_glob_1.txt | goal_name@11_goal_glob_2.txt | goal_name@11_goal_glob_3.txt +| goal_name@11_goal_glob_10.txt +| goal_name + +$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh -d '11_goal_glob*.txt' +| Resolved goals to reach for '11_goal_glob*.txt': +| 11_goal_glob_1.txt +| 11_goal_glob_2.txt +| 11_goal_glob_3.txt +| 11_goal_glob_10.txt +| 11_goal_glob*.txt $ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh test1 | goal '11_goal_glob_1.txt' ... diff --git a/tests/11_goal_glob_10.txt b/tests/11_goal_glob_10.txt new file mode 100644 index 0000000..0dbdfef --- /dev/null +++ b/tests/11_goal_glob_10.txt @@ -0,0 +1 @@ +content 101010