Skip to content

Commit

Permalink
Run Windows unit tests for all modules
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryax committed May 20, 2022
1 parent c56d20e commit 874fa8c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ jobs:
~\go\pkg\mod
~\AppData\Local\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Run Unit tests
run: go test ./...
- name: Run Unit Tests
run: make gotest
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,23 @@ install-tools:
run: otelcorecol
./bin/otelcorecol_$(GOOS)_$(GOARCH) --config ${RUN_CONFIG} ${RUN_ARGS}

# Append root module to all modules
GOMODULES = $(ALL_MODULES) $(PWD)

# Define a delegation target for each module
.PHONY: $(GOMODULES)
MODULEDIRS = $(GOMODULES:%=for-all-target-%)
$(GOMODULES):
@echo "Running target '$(TARGET)' in module '$@'"
$(MAKE) -C $@ $(TARGET)

# Triggers each module's delegation target
.PHONY: for-all-target
for-all-target: $(MODULEDIRS)
$(MODULEDIRS):
$(MAKE) -C $(@:for-all-target-%=%) $(TARGET)
for-all-target: $(GOMODULES)

# Debugging target, which helps to quickly determine whether for-all-target is working or not.
.PHONY: all-pwd
all-pwd:
$(MAKE) for-all-target TARGET="pwd"

.PHONY: check-component
check-component:
Expand Down
5 changes: 4 additions & 1 deletion Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ ALL_PKGS := $(sort $(shell go list ./...))

# Use a single process (-p 1) on go test to avoid tests clashing on machine
# wide resources, e.g. ports.
GOTEST_OPT?= -v -p 1 -race -timeout 60s
GOTEST_OPT?= -v -p 1 -race -timeout 120s
GOCMD?= go
GOTEST=$(GOCMD) test
GO_ACC=go-acc
LINT=golangci-lint
IMPI=impi

pwd:
@pwd

.PHONY: test
test:
$(GOTEST) $(GOTEST_OPT) ./...
Expand Down
1 change: 0 additions & 1 deletion cmd/builder/internal/builder/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func TestRelativePath(t *testing.T) {
// verify
cwd, err := os.Getwd()
require.NoError(t, err)
assert.True(t, strings.HasPrefix(cfg.Extensions[0].Path, "/"))
assert.True(t, strings.HasPrefix(cfg.Extensions[0].Path, cwd))
}

Expand Down
10 changes: 1 addition & 9 deletions cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,8 @@ func TestGenerateInvalidCollectorVersion(t *testing.T) {
require.NoError(t, err)
}

func TestGenerateInvalidOutputPath(t *testing.T) {
cfg := NewDefaultConfig()
cfg.Distribution.OutputPath = "/invalid"
err := Generate(cfg)
require.Error(t, err)
require.Contains(t, err.Error(), "failed to create output path")
}

func TestGenerateAndCompileDefault(t *testing.T) {
dir, err := ioutil.TempDir("/tmp", "default")
dir, err := ioutil.TempDir("", "default")
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 874fa8c

Please sign in to comment.