Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feature: Added gRPC close signal to Monitor call (allows graceful close of monitor) #2276

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

Merged
merged 9 commits into from
Jan 2, 2024
Prev Previous commit
Next Next commit
Made CreateEnvForDaeamon available in all integration tests
  • Loading branch information
cmaglie committed Jan 2, 2024
commit 5a39d1cc265090c91a179b76163101368e540453
15 changes: 15 additions & 0 deletions 15 internal/integrationtest/arduino-cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@ func NewArduinoCliWithinEnvironment(env *Environment, config *ArduinoCLIConfig)
return cli
}

// CreateEnvForDaemon performs the minimum required operations to start the arduino-cli daemon.
// It returns a testsuite.Environment and an ArduinoCLI client to perform the integration tests.
// The Environment must be disposed by calling the CleanUp method via defer.
func CreateEnvForDaemon(t *testing.T) (*Environment, *ArduinoCLI) {
env := NewEnvironment(t)

cli := NewArduinoCliWithinEnvironment(env, &ArduinoCLIConfig{
ArduinoCLIPath: FindRepositoryRootPath(t).Join("arduino-cli"),
UseSharedStagingFolder: true,
})

_ = cli.StartDaemon(false)
return env, cli
}

// CleanUp closes the Arduino CLI client.
func (cli *ArduinoCLI) CleanUp() {
if cli.proc != nil {
Expand Down
3 changes: 2 additions & 1 deletion 3 internal/integrationtest/daemon/daemon_concurrency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"testing"
"time"

"github.com/arduino/arduino-cli/internal/integrationtest"
"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
Expand All @@ -31,7 +32,7 @@ import (
func TestArduinoCliDaemonCompileWithLotOfOutput(t *testing.T) {
// See: https://github.com/arduino/arduino-cli/issues/2169

env, cli := createEnvForDaemon(t)
env, cli := integrationtest.CreateEnvForDaemon(t)
defer env.CleanUp()

_, _, err := cli.Run("core", "install", "arduino:avr")
Expand Down
37 changes: 11 additions & 26 deletions 37 internal/integrationtest/daemon/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
func TestArduinoCliDaemon(t *testing.T) {
// See: https://github.com/arduino/arduino-cli/pull/1804

env, cli := createEnvForDaemon(t)
env, cli := integrationtest.CreateEnvForDaemon(t)
defer env.CleanUp()

grpcInst := cli.Create()
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestArduinoCliDaemon(t *testing.T) {
func TestDaemonAutoUpdateIndexOnFirstInit(t *testing.T) {
// https://github.com/arduino/arduino-cli/issues/1529

env, cli := createEnvForDaemon(t)
env, cli := integrationtest.CreateEnvForDaemon(t)
defer env.CleanUp()

grpcInst := cli.Create()
Expand All @@ -110,26 +110,11 @@ func TestDaemonAutoUpdateIndexOnFirstInit(t *testing.T) {
require.FileExists(t, cli.DataDir().Join("package_index.json").String())
}

// createEnvForDaemon performs the minimum required operations to start the arduino-cli daemon.
// It returns a testsuite.Environment and an ArduinoCLI client to perform the integration tests.
// The Environment must be disposed by calling the CleanUp method via defer.
func createEnvForDaemon(t *testing.T) (*integrationtest.Environment, *integrationtest.ArduinoCLI) {
env := integrationtest.NewEnvironment(t)

cli := integrationtest.NewArduinoCliWithinEnvironment(env, &integrationtest.ArduinoCLIConfig{
ArduinoCLIPath: integrationtest.FindRepositoryRootPath(t).Join("arduino-cli"),
UseSharedStagingFolder: true,
})

_ = cli.StartDaemon(false)
return env, cli
}

func TestDaemonCompileOptions(t *testing.T) {
// See: https://github.com/arduino/arduino-cli/issues/1614
// See: https://github.com/arduino/arduino-cli/pull/1820

env, cli := createEnvForDaemon(t)
env, cli := integrationtest.CreateEnvForDaemon(t)
defer env.CleanUp()

grpcInst := cli.Create()
Expand Down Expand Up @@ -203,7 +188,7 @@ func TestDaemonCompileOptions(t *testing.T) {
func TestDaemonCompileAfterFailedLibInstall(t *testing.T) {
// See: https://github.com/arduino/arduino-cli/issues/1812

env, cli := createEnvForDaemon(t)
env, cli := integrationtest.CreateEnvForDaemon(t)
defer env.CleanUp()

grpcInst := cli.Create()
Expand Down Expand Up @@ -233,7 +218,7 @@ func TestDaemonCompileAfterFailedLibInstall(t *testing.T) {
}

func TestDaemonCoreUpdateIndex(t *testing.T) {
env, cli := createEnvForDaemon(t)
env, cli := integrationtest.CreateEnvForDaemon(t)
defer env.CleanUp()

grpcInst := cli.Create()
Expand Down Expand Up @@ -269,7 +254,7 @@ func TestDaemonCoreUpdateIndex(t *testing.T) {
}

func TestDaemonBundleLibInstall(t *testing.T) {
env, cli := createEnvForDaemon(t)
env, cli := integrationtest.CreateEnvForDaemon(t)
defer env.CleanUp()

grpcInst := cli.Create()
Expand Down Expand Up @@ -409,7 +394,7 @@ func TestDaemonLibrariesRescanOnInstall(t *testing.T) {
with the gprc instance
The last attempt is expected to not raise an error
*/
env, cli := createEnvForDaemon(t)
env, cli := integrationtest.CreateEnvForDaemon(t)
defer env.CleanUp()

grpcInst := cli.Create()
Expand Down Expand Up @@ -465,7 +450,7 @@ func TestDaemonCoreUpgradePlatform(t *testing.T) {

t.Run("upgraded successfully with additional urls", func(t *testing.T) {
t.Run("and install.json is present", func(t *testing.T) {
env, cli := createEnvForDaemon(t)
env, cli := integrationtest.CreateEnvForDaemon(t)
defer env.CleanUp()

grpcInst := cli.Create()
Expand All @@ -481,7 +466,7 @@ func TestDaemonCoreUpgradePlatform(t *testing.T) {
require.False(t, platform.GetRelease().GetMissingMetadata()) // install.json is present
})
t.Run("and install.json is missing", func(t *testing.T) {
env, cli := createEnvForDaemon(t)
env, cli := integrationtest.CreateEnvForDaemon(t)
defer env.CleanUp()

grpcInst := cli.Create()
Expand All @@ -504,7 +489,7 @@ func TestDaemonCoreUpgradePlatform(t *testing.T) {

t.Run("upgrade failed", func(t *testing.T) {
t.Run("without additional URLs", func(t *testing.T) {
env, cli := createEnvForDaemon(t)
env, cli := integrationtest.CreateEnvForDaemon(t)
defer env.CleanUp()

grpcInst := cli.Create()
Expand All @@ -524,7 +509,7 @@ func TestDaemonCoreUpgradePlatform(t *testing.T) {
require.False(t, platform.GetRelease().GetMissingMetadata()) // install.json is present
})
t.Run("missing both additional URLs and install.json", func(t *testing.T) {
env, cli := createEnvForDaemon(t)
env, cli := integrationtest.CreateEnvForDaemon(t)
defer env.CleanUp()

grpcInst := cli.Create()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.