diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 984dd034a..62b2b54eb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -23,13 +23,10 @@ jobs: go-version: 1.15 - name: Build - run: cd go && go build -v mlr.go + run: make build - name: Test - # In the event of needing to debug failures you can modify `./mlr regtest` verbosity - # using `-v`, `-vv`, or `-vvv`. Commit changes to this file and re-push to GitHub - # and let the GitHub Actions re-run. - run: cd go && go test -v mlr/src/... && ./mlr regtest -s 5 + run: make check - name: PrepareArtifactNonWindows if: matrix.os != 'windows-latest' diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..beaf67828 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +build: + make -C go build + +check: + make -C go check + +install: + make -C go install + make -C man install + +# Go does its own dependency management, outside of make. +.PHONY: build diff --git a/go/Makefile b/go/Makefile new file mode 100644 index 000000000..786ec1621 --- /dev/null +++ b/go/Makefile @@ -0,0 +1,22 @@ +# TODO: take from ../configure +INSTALLDIR=/usr/local/bin + +build: + go build + +check: + # Unit tests (small number) + go test -v mlr/src/... + # Regression tests (large number) + # + # See ./regression_test.go for information on how to get more details + # for debugging. TL;DR is for CI jobs, we have 'go test -v'; for + # interactive use, instead of 'go test -v' simply use 'mlr regtest + # -vvv' or 'mlr regtest -s 20'. See also src/auxents/regtest. + go test -v + +install: build + cp mlr $(INSTALLDIR) + +# Go does its own dependency management, outside of make. +.PHONY: build diff --git a/go/regression_test.go b/go/regression_test.go index 8c41c6479..3f9ab3006 100644 --- a/go/regression_test.go +++ b/go/regression_test.go @@ -1,6 +1,8 @@ package main import ( + "fmt" + "os" "testing" "mlr/src/auxents/regtest" @@ -11,12 +13,52 @@ import ( // is a standard location so people can get at them via 'go test'. Please see // (as of this writing) src/auxents/regtest for the Miller regtest package. func TestRegression(t *testing.T) { + // How much detail to show? There are thousands of cases, organized into a + // few hundred top-level directories under ./regtest/cases. + // + // Default behavior is to show PASS/FAIL for those top-level directories. + // If (for whatever reason) lots of tests are systematically failing then + // verbosityLevel = 3 for all cases is probably too much output to be + // useful. + // + // Also note our regtest framework supports four verbosity levels, 'mlr + // regtest' (0) through 'mlr regtest -vvv' (3), while 'go test' has only + // 'go test' and 'go test -v'. Our regtest framework also has 'mlr regtest + // -s 20' which means *re-run* up to 20 failing tests (after having failed + // once with verbosityLevel = 0) as if those had been invoked with + // verbosityLevel = 3. + // + // What we do is: + // * go test: like 'mlr regtest' + // * go test -v: like 'mlr regtest -s 20' + // + // This is (I hope) sufficient flexibility for use in GitHub Actions + // continuous-integration jobs. If more detail is needed then one may: + // + // * For CI debugging: simply edit the below parameters verbosityLevel + // and firstNFailsToShow and re-push to GitHub. + // * For interactive debug: run 'mlr regtest -v', 'mlr regtest -vv', 'mlr + // regtest -vvv' instead of going through 'go test'. + firstNFailsToShow := 0 + if testing.Verbose() { + firstNFailsToShow = 20 + } + + // Let the tests find ./mlr + cwd, err := os.Getwd() + if err != nil { + fmt.Fprintln(os.Stderr, "mlr: could not find current working directory.") + os.Exit(1) + } + path := os.Getenv("PATH") + os.Setenv("PATH", cwd + ":" + path) + regtester := regtest.NewRegTester( "mlr", // exeName false, // doPopulate 0, // verbosityLevel false, // plainMode - 0, // firstNFailsToShow + firstNFailsToShow, ) paths := []string{} // use default diff --git a/go/todo.txt b/go/todo.txt index ce8c88476..8d0aebfe8 100644 --- a/go/todo.txt +++ b/go/todo.txt @@ -2,6 +2,9 @@ PUNCHDOWN LIST * ./configure equivalent + o make: + - windoc note 'choco install make' + - (works in GH CI due to their toolchain) ? twi-dm re all-contribs: all-contributors.org * nikos materials -> fold in diff --git a/man/Makefile b/man/Makefile index 1552a5ab7..01fd668a0 100644 --- a/man/Makefile +++ b/man/Makefile @@ -5,24 +5,30 @@ INSTALLDIR=/usr/local/share/man/man1 INSTALLHOME=$(HOME)/man/man1 -top: .always +# This is normally done only on a development host. Through CI and +# package-installer, mlr.1 should be treated as an already-built artifact, +# needing only to be copied to its install dir. +build: .always echo mkman start ./mkman.rb > mlr.1 ./mkman.rb | groff -man -Tascii | col -b | expand -8 > manpage.txt cp manpage.txt ../docs/src/ echo mkman end -# These targets are only for local dev work. -install: top +install: mkdir -p $(INSTALLDIR) cp mlr.1 $(INSTALLDIR)/mlr.1 -installhome: top + +# ---------------------------------------------------------------- +# These targets are only for local dev work. +installhome: build mkdir -p $(INSTALLHOME) cp mlr.1 $(INSTALLHOME)/mlr.1 # This is an out-of-tree operation so do it only if the user is using out-of-tree manpage setup # (e.g. their $MANPATH as $HOME/man as a component). -maybeinstallhome: top +maybeinstallhome: build if [ -d $(INSTALLHOME) ]; then cp mlr.1 $(INSTALLHOME)/mlr.1; else echo No $(INSTALLHOME) -- skipping ; fi +# ---------------------------------------------------------------- .always: true