Skip to content

Commit

Permalink
Make @use_lib apply also to @reached_if xonixx#76 : minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Nov 20, 2021
1 parent 613d634 commit 6ab7417
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
1 change: 0 additions & 1 deletion makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ function die(msg, out) {
}

function checkConditionReached(goalName, definesLine, conditionStr, script) {

script = definesLine # need this to initialize variables for check conditions
if (goalName in GoalToLib)
script = script "\n" Lib[GoalToLib[goalName]]
Expand Down
10 changes: 8 additions & 2 deletions tests/15_lib.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

@define HELLO="Hello"

@lib
f1 () {
echo "Hello $1"
echo "$HELLO $1"
}

@goal g1
Expand All @@ -18,7 +19,12 @@ f2 World
echo "Hello lib_name $1"
}

@goal g5
@goal g3
@use_lib
@reached_if [ "$(f1 World)" = "Hello World" ]
echo "Should not see this"

@goal g4
@use_lib lib_name
@reached_if [[ "$(f2 World)" == "123" ]]
echo "Should see this"
13 changes: 9 additions & 4 deletions tests/15_lib.tush
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/15_lib.sh -l
| Available goals:
| g1
| g2
| g5
| g3
| g4

$ cd "$MYDIR"; ./$MAKESURE -f tests/15_lib.sh g1
| goal 'g1' ...
Expand All @@ -14,10 +15,14 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/15_lib.sh g2
| goal 'g2' ...
| Hello lib_name World

$ cd "$MYDIR"; ./$MAKESURE -f tests/15_lib.sh g3
| goal 'g3' [already satisfied].

$ cd "$MYDIR"; ./$MAKESURE -f tests/15_lib.sh g4
| goal 'g4' ...
| Should see this

$ cd "$MYDIR"; ./$MAKESURE -f tests/15_lib_unknown.sh g3
@ Goal 'g3' uses unknown lib 'unknown':
@ tests/15_lib_unknown.sh:3: @use_lib unknown
? 1

$ cd "$MYDIR"; ./$MAKESURE -f tests/15_lib.sh g5
| goal 'g5' [already satisfied].

0 comments on commit 6ab7417

Please sign in to comment.