Skip to content

Commit

Permalink
Run integration tests on the CI (arduino#296)
Browse files Browse the repository at this point in the history
* removed redundant test

* add python tests

* un-mark as integration

* additional step to run integration tests

* change step name

* install dependencies first

* split unit and intg tests execution

* bump image for all steps
  • Loading branch information
masci authored Jul 22, 2019
1 parent 15fcf19 commit 5a4f31d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 39 deletions.
17 changes: 12 additions & 5 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,36 @@ name: default

steps:
- name: lint
image: arduino/arduino-cli:drone-0.2.0
image: arduino/arduino-cli:drone-1.0
commands:
# Check if the Go code is properly formatted and run the linter
- task check
# Ensure protobufs compile
- task protoc

- name: build
image: arduino/arduino-cli:drone-0.2.0
image: arduino/arduino-cli:drone-1.0
commands:
- task build

- name: test
image: arduino/arduino-cli:drone-0.2.0
image: arduino/arduino-cli:drone-1.0
commands:
- task test
- task test-unit
- task test-legacy

- name: integration
image: arduino/arduino-cli:drone-1.0
failure: ignore # work in progress, we know some tests will fail at the moment
commands:
- pip install -r test/requirements.txt
- task test-integration

# Contrary to other CI platforms, uploading reports to Codecov requires Drone to provide a token.
# To avoid exposing the Codecov token to external PRs, we only upload coverage when we merge on
# `master`.
- name: coverage
image: arduino/arduino-cli:drone-0.2.0
image: arduino/arduino-cli:drone-1.0
environment:
CODECOV_TOKEN:
from_secret: codecov_token
Expand Down
3 changes: 2 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ tasks:
test-unit:
desc: Run unit tests only
cmds:
- go test -short {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }}
- go test -short {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}}

test-integration:
desc: Run integration tests only
cmds:
- go test -run Integration {{ default "-v" .GOFLAGS }} -coverprofile=coverage_integ.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}}
- pytest test/

test-legacy:
desc: Run tests for the `legacy` package
Expand Down
27 changes: 0 additions & 27 deletions cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,33 +288,6 @@ func TestUploadIntegration(t *testing.T) {
require.NotZero(t, exitCode)
}

func TestLibSearchIntegration(t *testing.T) {
exitCode, output := executeWithArgs("lib", "search", "audiozer", "--format", "json")
require.Zero(t, exitCode)
var res struct {
Libraries []struct {
Name string
}
}
err := json.Unmarshal(output, &res)
require.NoError(t, err, "decoding json output")
require.NotNil(t, res.Libraries)
require.Len(t, res.Libraries, 1)
require.Equal(t, res.Libraries[0].Name, "AudioZero")

exitCode, output = executeWithArgs("lib", "search", "audiozero", "--names")
require.Zero(t, exitCode, "process exit code")
require.Equal(t, "AudioZero\n", string(output))

exitCode, output = executeWithArgs("lib", "search", "audiozer", "--names")
require.Zero(t, exitCode, "process exit code")
require.Equal(t, "AudioZero\n", string(output))

exitCode, output = executeWithArgs("lib", "search", "audiozerooooo", "--names")
require.Zero(t, exitCode, "process exit code")
require.Equal(t, "", string(output))
}

func TestLibUserIntegration(t *testing.T) {
// source of test custom libs
libDir := filepath.Join("testdata", "libs")
Expand Down
9 changes: 3 additions & 6 deletions version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@ import (
"github.com/stretchr/testify/require"
)

// TestIntegrationBuildInjectedInfo is an integration test that aims to test the Info strings passed to the binary at build time
// TestBuildInjectedInfo tests the Info strings passed to the binary at build time
// in order to have this test green launch your testing using the provided task (see /Taskfile.yml) or use:
// go test -run Integration -v ./... -ldflags '
// go test -run TestBuildInjectedInfo -v ./... -ldflags '
// -X github.com/arduino/arduino-cli/version.versionString=0.0.0-test.preview
// -X github.com/arduino/arduino-cli/version.commit=deadbeef'
func TestIntegrationBuildInjectedInfo(t *testing.T) {
if testing.Short() {
t.Skip("skip integration test")
}
func TestBuildInjectedInfo(t *testing.T) {
goldenAppName := "arduino-cli"
goldenInfo := Info{
Application: goldenAppName,
Expand Down

0 comments on commit 5a4f31d

Please sign in to comment.