Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Windows unit tests for all modules and fix them #5401

Merged
merged 1 commit into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,18 @@ 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)

.PHONY: check-component
check-component:
Expand Down
2 changes: 1 addition & 1 deletion Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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
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
8 changes: 6 additions & 2 deletions cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"io/ioutil"
"log"
"os"
"runtime"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -37,14 +38,17 @@ func TestGenerateInvalidCollectorVersion(t *testing.T) {

func TestGenerateInvalidOutputPath(t *testing.T) {
cfg := NewDefaultConfig()
cfg.Distribution.OutputPath = "/invalid"
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")
if runtime.GOOS == "windows" {
t.Skip("skipping the test on Windows, see https://github.com/open-telemetry/opentelemetry-collector/issues/5403")
}
dir, err := ioutil.TempDir("", "default")
if err != nil {
log.Fatal(err)
}
Expand Down