Skip to content

Commit 583d684

Browse files
authored
Merge pull request #146 from xonixx/v0.9.21
V0.9.21
2 parents 0084d9c + 013c2a7 commit 583d684

11 files changed

+753
-586
lines changed

Makesurefile

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# vim: syntax=bash
22
@options timing
33

4-
@define NEXT_VERSION='0.9.20'
5-
@define GOAWK_VERSION='1.23.1'
6-
@define JUST_VERSION='1.3.0'
7-
@define GOAWK="goawk$GOAWK_VERSION"
8-
@define JUST="just$JUST_VERSION"
9-
@define FHTAGN_VERSION='v0.1.0'
10-
@define FHTAGN_URL="https://github.com/xonixx/fhtagn/raw/$FHTAGN_VERSION/fhtagn.awk"
11-
@define REPO='xonixx/makesure'
12-
@define AWK="${AWK:-awk}"
4+
@define NEXT_VERSION '0.9.21'
5+
@define GOAWK_VERSION '1.23.1'
6+
@define JUST_VERSION '1.3.0'
7+
@define FHTAGN_VERSION 'v0.1.0'
8+
@define GOAWK "goawk$GOAWK_VERSION"
9+
@define JUST "just$JUST_VERSION"
10+
@define FHTAGN_URL "https://github.com/xonixx/fhtagn/raw/$FHTAGN_VERSION/fhtagn.awk"
11+
@define REPO 'xonixx/makesure'
12+
@define AWK "${AWK:-awk}"
1313

1414
@goal soft_folder_created @private
1515
@reached_if [[ -d "soft" ]]
1616
mkdir soft
1717

18-
@define FHTAGN="soft/fhtagn.awk"
18+
@define FHTAGN "soft/fhtagn.awk"
1919

2020
@goal fhtagn_installed @private
2121
@depends_on soft_folder_created
@@ -81,27 +81,27 @@
8181

8282
@goal tested
8383
@doc 'runs all *.tush tests'
84-
@depends_on tests/*.tush
84+
@depends_on 'tests/*.tush'
8585

8686
@goal fhtagn
8787
@doc 'runs all *.tush tests (fail at end)'
8888
@depends_on prepared4tests
8989
MAKESURE=makesure_dev ALL=1 ./soft/fhtagn.awk tests/*.tush
9090

91-
@goal @glob tests/*.tush @private
91+
@goal @glob 'tests/*.tush' @private
9292
@depends_on prepared4tests
9393
@use_lib testing
9494
MAKESURE=makesure_dev \
9595
run_tush_file "$ITEM"
9696

97-
@goal tested_candidate @glob tests/*.tush @private
97+
@goal tested_candidate @glob 'tests/*.tush' @private
9898
@depends_on tested
9999
@depends_on candidate_version_prepared
100100
@use_lib testing
101101
MAKESURE=makesure_candidate \
102102
run_tush_file "$ITEM"
103103

104-
@define COVERPROFILE="/tmp/cov.txt"
104+
@define COVERPROFILE "/tmp/cov.txt"
105105

106106
@goal _cover_profile_prepared @private
107107
rm -f "$COVERPROFILE"
@@ -372,8 +372,8 @@
372372
mv goawk $GOAWK
373373
"./$GOAWK" --version
374374

375-
@define GOAWK_BRANCH='bytecode'
376-
@define GOAWK_BRANCH_EXE="goawk_$GOAWK_BRANCH"
375+
@define GOAWK_BRANCH 'bytecode'
376+
@define GOAWK_BRANCH_EXE "goawk_$GOAWK_BRANCH"
377377

378378
@goal installed_goawk_branch @private
379379
@reached_if [[ -f soft/$GOAWK_BRANCH_EXE ]]

README.md

+51-10
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ By default, all scripts inside goals are executed with `bash`. If you want to us
5454

5555
```
5656
$ ./makesure -h
57-
makesure ver. 0.9.20
57+
makesure ver. 0.9.21
5858
Usage: makesure [options...] [-f buildfile] [goals...]
5959
-f,--file buildfile
6060
set buildfile to use (default Makesurefile)
@@ -103,13 +103,6 @@ Updates `makesure` executable to latest available version in-place:
103103
- MacOS
104104
- Windows (via Git Bash)
105105

106-
#### AWK
107-
108-
The core of this tool is implemented in [AWK](https://en.wikipedia.org/wiki/AWK).
109-
Almost all major implementations of AWK will work. Tested and officially supported are [Gawk](https://www.gnu.org/software/gawk/), [BWK](https://github.com/onetrueawk/awk), [mawk](https://invisible-island.net/mawk/). This means that the default AWK implementation in your OS will work.
110-
111-
Developed in [xonixx/intellij-awk](https://github.com/xonixx/intellij-awk).
112-
113106
## Concepts
114107

115108
- Build file is a text file named `Makesurefile`.
@@ -180,6 +173,7 @@ Example:
180173
```sh
181174
@define A hello
182175
@define B "${A} world"
176+
@define C 'hello world'
183177
```
184178

185179
This directive is valid [in any place](tests/24_define_everywhere.sh) in `Makesurefile`. However, we recommend:
@@ -194,6 +188,16 @@ Overall the precedence for variables resolution is (higher priority top):
194188
- `@define VAR 2` in `Makesurefile`
195189
- `VAR=3 ./makesure`
196190

191+
The precedence priorities are designed like this on purpose, to prevent accidental override of `@define VAR='value'` definition in file by the environment variable with the same name. However, sometimes this is the desired behavior. In this case you can use:
192+
193+
```sh
194+
@define VAR "${VAR}" # using the same name, or
195+
@define VAR1 "${ENV_VAR}" # using different name, or
196+
@define VAR2 "${VAR_NAME:-default_value}" # if need the default value when not set
197+
```
198+
199+
This allows to use environment variables `VAR`, `ENV_VAR`, and `VAR_NAME` to set the value of `VAR`, `VAR1` and `VAR2`.
200+
197201
Please note, the parser of `makesure` is somewhat stricter here than shell's one:
198202
```sh
199203
@define HW ${HELLO}world # makesure won't accept
@@ -300,7 +304,7 @@ as equivalent for
300304

301305
So essentially one glob goal declaration expands to multiple goal declarations based on files present in project that match the glob pattern. Shell glob expansion mechanism applies.
302306

303-
The useful use case here would be to represent a set of test files as a set of goals. The example could be found in the project's own [build file](https://github.com/xonixx/makesure/blob/main/Makesurefile#L108).
307+
The useful use case here would be to represent a set of test files as a set of goals. The example could be found in the project's own [build file](https://github.com/xonixx/makesure/blob/3be738d771bf855b5a6d3cd08cbc38dc977bed76/Makesurefile#L91).
304308

305309
Why this may be useful? Imagine in your nodejs application you have `test1.js`, `test2.js`, `test3.js`.
306310
Now you can use this `Makesurefile`
@@ -347,7 +351,7 @@ Example:
347351
@depends_on file_processed @args 'file3'
348352
```
349353

350-
Having the above in `Makesurefile` will produce next output when ran with `./makesure all_files_processed`
354+
Having the above in `Makesurefile` will produce next output when ran with `./makesure all_files_processed`:
351355
```
352356
goal 'file_downloaded@file1' ...
353357
Downloading file1...
@@ -388,6 +392,30 @@ Processing file2...
388392

389393
You can also take a look at an [example from a real project](https://github.com/xonixx/intellij-awk/blob/68bd7c5eaa5fefbd7eaa9f5f5a4b77b69dcd8779/Makesurefile#L126).
390394

395+
Note, you can reference the `@define`-ed variables in the arguments of the parameterized goals:
396+
397+
```shell
398+
@define HELLO 'hello'
399+
400+
@goal parameterized_goal @params ARG
401+
echo "ARG=$ARG"
402+
403+
@goal goal1
404+
@depends_on parameterized_goal @args HELLO # reference by name
405+
@depends_on parameterized_goal @args "$HELLO world" # interpolated inside string
406+
```
407+
408+
Having the above in `Makesurefile` will produce next output when ran with `./makesure goal1`:
409+
```
410+
goal 'parameterized_goal@hello' ...
411+
ARG=hello
412+
goal 'parameterized_goal@hello world' ...
413+
ARG=hello world
414+
goal 'goal1' [empty].
415+
```
416+
417+
Please find a more real-world example [here](https://github.com/xonixx/fhtagn/blob/e7161f92731c13b5afbc09c7d738c1ff4882906f/Makesurefile#L70).
418+
391419
For more technical consideration regarding this feature see [parameterized_goals.md](docs/parameterized_goals.md).
392420

393421
### @doc
@@ -659,6 +687,19 @@ echo 'Please reopen the shell to activate completion.'
659687

660688
Find some contributor instructions in [DEVELOPER.md](docs/DEVELOPER.md).
661689

690+
#### AWK
691+
692+
The core of this tool is implemented in [AWK](https://en.wikipedia.org/wiki/AWK).
693+
Almost all major implementations of AWK will work. Tested and officially supported are [Gawk](https://www.gnu.org/software/gawk/), [BWK](https://github.com/onetrueawk/awk), [mawk](https://invisible-island.net/mawk/). This means that the default AWK implementation in your OS will work.
694+
695+
Developed in [xonixx/intellij-awk](https://github.com/xonixx/intellij-awk).
696+
697+
## Articles
698+
699+
- [Adding parameterized goals to makesure](https://maximullaris.com/parameterized_goals.html) (March 2023)
700+
- [makesure vs make](https://maximullaris.com/makesure-vs-make.html) (March 2023)
701+
- [makesure – make with a human face](https://maximullaris.com/makesure.html) (February 2023)
702+
662703
## Similar tools
663704

664705
- **just** https://github.com/casey/just `Rust`

coverage.svg

+4-4
Loading

0 commit comments

Comments
 (0)