Skip to content

Commit

Permalink
Pick the GoReleaser build for integration tests by default
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Oct 25, 2024
1 parent b69f226 commit 792089c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ php-*
!internal/legacy/archives/windows_php.ini.tpl
completion

# Executable built with `go build ./cmd/platform` (or `make platform`)
/platform

# Binaries for programs and plugins
*.exe
*.exe~
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,9 @@ test: ## Run unit tests
go clean -testcache
go test -v -race -short -cover ./...

platform: internal/legacy/archives/platform.phar php
go build ./cmd/platform

.PHONY: integration-test
integration-test: platform
TEST_CLI_PATH="$(PWD)/platform" go test -v ./tests/...
integration-test: single
go test -v ./tests/...

golangci-lint:
command -v golangci-lint >/dev/null || go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
Expand Down
27 changes: 13 additions & 14 deletions tests/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,25 @@ var _validatedCommand string
const mockProjectID = "abcdefg123456"

func getCommandName(t *testing.T) string {
if testing.Short() {
t.Skip("skipping integration test due to -short flag")
}
if _validatedCommand != "" {
return _validatedCommand
}
candidate := os.Getenv("TEST_CLI_PATH")
if candidate == "" {
candidate = "platform"
}
if !filepath.IsAbs(candidate) {
c, err := filepath.Abs("../" + candidate)
if candidate != "" {
_, err := os.Stat(candidate)
require.NoError(t, err)
candidate = c
}
_, err := os.Stat(candidate)
switch {
case os.IsNotExist(err) && os.Getenv("TEST_CLI_PATH") == "":
t.Skipf("skipping integration tests: CLI not found at path: %s", candidate)
case err != nil:
} else {
matches, _ := filepath.Glob("../dist/platform_*/platform")
if len(matches) == 0 {
t.Skipf("skipping integration tests: CLI not found matching path: %s", "../dist/platform_*/platform")
return ""
}
c, err := filepath.Abs(matches[0])
require.NoError(t, err)
case testing.Short():
t.Skip("skipping integration test due to -short flag")
candidate = c
}
versionCmd := exec.Command(candidate, "--version")
versionCmd.Env = testEnv()
Expand Down

0 comments on commit 792089c

Please sign in to comment.