Installing GOLD

In a new directory, download gold, the GOLD file manager:

Make it executable, then run it:

chmod +x gold
./gold install

This generates the following files:

WHAT WHERE
the GOLD file manager ./gold
base functions for GOLD ./lib/gold.gold
GOLD’s configuration options $HOME/.config/gold
Directory for writing .awk files $HOME/opt/gold/awk

gold has the following command line options:

COMMAND NOTES
gold help print help text
gold install ensure base files exist
gold make update all .awk files for all the .golds
gold zap delete all .awk files
gold oks run all unit tests, return 0 if no “FAIL”s
gold run gold make, then run gawk -f for command line args

Note that a XXX.gold file can be executed without using gold. After running gold make, then the command

gawk -f XXX.awk

will run XXX.gold. For convenience, the command gold go XXX runs make (to update all the .awk files) before running gawk -f XXX.

Test

To test if your install worked, then in the same as directory as gold:

  • create a file ./lib/goldok.gold
  • add in some GOLD unit tests, as follows1.
# vim: nospell filetype=awk ts=2 sw=2 sts=2  et :
#--------- --------- --------- --------- --------- ---------

@include "gold"

function _gold1(f) {
  is(f, length("word"), 4) # passing test
  is(f, 10 > 1, 1)         # a pass test
}
function _gold2(f) {
  is(f, length("word"), 1) # failing test
}
BEGIN {
  tests("gold","_gold1,_gold2")
}

Now run

../gold goldok

If this work wells, then we should see that two unit tests pass, and one fails:

#--- gold -----------------------
#TEST:  PASSED  _gold1  4       4
#TEST:  PASSED  _gold1  1       1
#TEST:  FAILED  _gold2  1       4

Notes

  1. A GOLD unit test function has a first argument f (the describes the test group) and calls the function is(f,want,got) to check that want equals got. This is called via BEGIN{tests(group,listOfTests)}