Skip to content

Commit

Permalink
build: simplify go commands
Browse files Browse the repository at this point in the history
Use ./... instead of loop over packages.

Originally loop over packages was added by #359 that introduced glide package manager.
This manager fetches dependencies into vendor/ subdirectory (see https://glide.readthedocs.io/en/latest/getting-started/) and
apparently loop over packages was necessary back then.
glide usage was removed by #764

The change now also runs testable examples.

Also:
* fixes cmd/eskip etcd shutdown similar to #2359
* fixes cmd/eskip test introduced by #2202
* fixes lua example
* removed bench target as it makes little sense
* .coverprofile-all can not be simplified yet due to golang/go#45361

Signed-off-by: Alexander Yastrebov <[email protected]>
  • Loading branch information
AlexanderYastrebov committed Jul 11, 2023
1 parent 972e84c commit f2c7133
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 45 deletions.
43 changes: 7 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SOURCES = $(shell find . -name '*.go' -not -path "./vendor/*" -and -not -path "./_test_plugins" -and -not -path "./_test_plugins_fail" )
SOURCES = $(shell find . -name '*.go' -and -not -path "./_test_plugins" -and -not -path "./_test_plugins_fail" )
PACKAGES = $(shell go list ./...)
CURRENT_VERSION = $(shell git describe --tags --always --dirty)
VERSION ?= $(CURRENT_VERSION)
Expand All @@ -20,7 +20,7 @@ help: ## Display this help

.PHONY: lib
lib: $(SOURCES) ## build skipper library
go build $(PACKAGES)
go build ./...

.PHONY: bindir
bindir:
Expand Down Expand Up @@ -79,39 +79,19 @@ install: $(SOURCES) ## install skipper and eskip binaries into your system

.PHONY: check
check: build check-plugins ## run all tests
# go test $(PACKAGES)
#
# due to vendoring and how go test ./... is not the same as go test ./a/... ./b/...
# probably can be reverted once etcd is fully mocked away for tests
#
for p in $(PACKAGES); do go test $$p || break; done
go test ./...

.PHONY: shortcheck
shortcheck: build check-plugins fixlimits ## run all short tests
# go test -test.short -run ^Test $(PACKAGES)
#
# due to vendoring and how go test ./... is not the same as go test ./a/... ./b/...
# probably can be reverted once etcd is fully mocked away for tests
#
for p in $(PACKAGES); do go test -test.short -run ^Test $$p || break -1; done
go test -test.short ./...

.PHONY: cicheck
cicheck: build check-plugins ## run all short and redis tests
# go test -test.short -run ^Test $(PACKAGES)
#
# due to vendoring and how go test ./... is not the same as go test ./a/... ./b/...
# probably can be reverted once etcd is fully mocked away for tests
#
for p in $(PACKAGES); do go test -tags=redis -test.short -run ^Test $$p || break -1; done
go test -tags=redis -test.short ./...

.PHONY: check-race
check-race: build ## run all tests with race checker
# go test -race -test.short -run ^Test $(PACKAGES)
#
# due to vendoring and how go test ./... is not the same as go test ./a/... ./b/...
# probably can be reverted once etcd is fully mocked away for tests
#
for p in $(PACKAGES); do go test -race -test.short -run ^Test $$p || break -1; done
check-race: build ## run all short tests with race checker
go test -race -test.short ./...

.PHONY: check-plugins
check-plugins: $(TEST_PLUGINS)
Expand All @@ -123,15 +103,6 @@ _test_plugins/%.so: _test_plugins/%.go
_test_plugins_fail/%.so: _test_plugins_fail/%.go
go build -buildmode=plugin -o $@ $<

.PHONY: bench
bench: build $(TEST_PLUGINS) ## run all benchmark tests
# go test -bench . $(PACKAGES)
#
# due to vendoring and how go test ./... is not the same as go test ./a/... ./b/...
# probably can be reverted once etcd is fully mocked away for tests
#
for p in $(PACKAGES); do go test -bench . $$p; done

.PHONY: fuzz
fuzz: ## run all fuzz tests
for p in $(PACKAGES); do go test -run=NONE -fuzz=Fuzz -fuzztime 30s $$p; done
Expand Down
2 changes: 1 addition & 1 deletion cmd/eskip/args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestProcessArgs(t *testing.T) {
[]string{"-sort-predicates"},
false,
nil,
[]*medium{{typ: inline, eskip: `PathRegexp("^/") && Host("^(www[.]example[.]org[.]?(:[0-9]+)?)$") -> "https://www.example.org"`}},
nil,
}, {

// etcd-urls
Expand Down
16 changes: 8 additions & 8 deletions cmd/eskip/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ func TestMain(m *testing.M) {
log.Fatal(err)
}

defer func() {
err := etcdtest.Stop()
if err != nil {
log.Fatal(err)
}
}()

urls, err := stringsToUrls(etcdtest.Urls...)
if err != nil {
log.Fatal(err)
}

testEtcdUrls = urls

os.Exit(m.Run())
exitCode := m.Run()

err = etcdtest.Stop()
if err != nil {
log.Fatal(err)
}

os.Exit(exitCode)
}

func TestUpsertLoadFail(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions script/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func ExampleLuaOptions_enableModules() {
// table
// table.insert
// table.sort
// package.config
// package.cpath
// package.loaded
// package.loaders
Expand Down

0 comments on commit f2c7133

Please sign in to comment.