-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into remove-open-not-used-buffer-algorithm
- Loading branch information
Showing
7 changed files
with
133 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/arduino/go-paths-helper" | ||
"github.com/sirupsen/logrus" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetConfigPath(t *testing.T) { | ||
t.Run("read config.ini from ARDUINO_CREATE_AGENT_CONFIG", func(t *testing.T) { | ||
os.Setenv("ARDUINO_CREATE_AGENT_CONFIG", "./testdata/fromenv/config.ini") | ||
defer os.Unsetenv("ARDUINO_CREATE_AGENT_CONFIG") | ||
configPath := GetConfigPath() | ||
assert.Equal(t, "./testdata/fromenv/config.ini", configPath.String()) | ||
}) | ||
|
||
t.Run("panic if config.ini does not exist", func(t *testing.T) { | ||
os.Setenv("ARDUINO_CREATE_AGENT_CONFIG", "./testdata/nonexistent_config.ini") | ||
defer os.Unsetenv("ARDUINO_CREATE_AGENT_CONFIG") | ||
|
||
defer func() { | ||
if r := recover(); r != nil { | ||
entry, ok := r.(*logrus.Entry) | ||
if !ok { | ||
t.Errorf("Expected panic of type *logrus.Entry but got %T", r) | ||
} else { | ||
assert.Equal(t, "config from env var ./testdata/nonexistent_config.ini does not exists", entry.Message) | ||
} | ||
} else { | ||
t.Errorf("Expected panic but did not get one") | ||
} | ||
}() | ||
|
||
GetConfigPath() | ||
}) | ||
|
||
t.Run("read config.ini from $HOME", func(t *testing.T) { | ||
os.Setenv("HOME", "./testdata/home") | ||
defer os.Unsetenv("HOME") | ||
configPath := GetConfigPath() | ||
assert.Equal(t, "testdata/home/.config/ArduinoCreateAgent/config.ini", configPath.String()) | ||
}) | ||
|
||
t.Run("fallback old : read config.ini where the binary is launched", func(t *testing.T) { | ||
src, _ := os.Executable() | ||
paths.New(src).Parent().Join("config.ini").Create() // create a config.ini in the same directory as the binary | ||
// The fallback path is the directory where the binary is launched | ||
fmt.Println(src) | ||
os.Setenv("HOME", "./testdata/noconfig") // force to not have a config in the home directory | ||
defer os.Unsetenv("HOME") | ||
|
||
// expect it creates a config.ini in the same directory as the binary | ||
configPath := GetConfigPath() | ||
assert.Equal(t, "testdata/home/.config/ArduinoCreateAgent/config.ini", configPath.String()) | ||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
gc = std | ||
hostname = unknown-hostname | ||
regex = usb|acm|com | ||
v = true | ||
appName = CreateAgent/Stable | ||
updateUrl = https://downloads.arduino.cc/ | ||
origins = https://local.arduino.cc:8000, https://local.arduino.cc:8001, https://create-dev.arduino.cc, https://*.sparklyunicorn.cc, https://*.iot-cloud-arduino-cc.pages.dev, https://cloud.oniudra.cc, https://app.oniudra.cc,https://*.iot-cloud-arduino-cc.pages.dev | ||
crashreport = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
gc = std | ||
hostname = unknown-hostname | ||
regex = usb|acm|com | ||
v = true | ||
appName = config-from-home-dir | ||
updateUrl = https://downloads.arduino.cc/ | ||
origins = https://local.arduino.cc:8000, https://local.arduino.cc:8001, https://*.iot-cloud-arduino-cc.pages.dev | ||
crashreport = false |
10 changes: 10 additions & 0 deletions
10
config/testdata/noconfig/.config/ArduinoCreateAgent/config.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
gc = std # Type of garbage collection. std = Normal garbage collection allowing system to decide (this has been known to cause a stop the world in the middle of a CNC job which can cause lost responses from the CNC controller and thus stalled jobs. use max instead to solve.), off = let memory grow unbounded (you have to send in the gc command manually to garbage collect or you will run out of RAM eventually), max = Force garbage collection on each recv or send on a serial port (this minimizes stop the world events and thus lost serial responses, but increases CPU usage) | ||
hostname = unknown-hostname # Override the hostname we get from the OS | ||
regex = usb|acm|com # Regular expression to filter serial port list | ||
v = true # show debug logging | ||
appName = CreateAgent/Stable | ||
updateUrl = https://downloads.arduino.cc/ | ||
origins = https://local.arduino.cc:8000 | ||
#httpProxy = http://your.proxy:port # Proxy server for HTTP requests | ||
crashreport = false # enable crashreport logging | ||
autostartMacOS = true # the Arduino Create Agent is able to start automatically after login on macOS (launchd agent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters