8000 feat: add agent exec pkg by sreya · Pull Request #15577 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: add agent exec pkg #15577

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 17 commits into from
Nov 25, 2024
Prev Previous commit
Next Next commit
lint
  • Loading branch information
sreya committed Nov 20, 2024
commit 5f633e16712b4dd21f7fa9fd9ade8ffdc350e3dd
14 changes: 10 additions & 4 deletions agent/agentexec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
"github.com/coder/coder/v2/agent/agentexec"
)

//nolint:paralleltest // we need to test environment variables
func TestExec(t *testing.T) {
//nolint:paralleltest // we need to test environment variables
t.Run("NonLinux", func(t *testing.T) {

t.Setenv(agentexec.EnvProcPrioMgmt, "true")

if runtime.GOOS == "linux" {
Expand All @@ -23,12 +24,16 @@ func TestExec(t *testing.T) {

cmd, err := agentexec.CommandContext(context.Background(), "sh", "-c", "sleep")
require.NoError(t, err)
require.Equal(t, "sh", cmd.Path)
require.Equal(t, []string{"-c", "sleep"}, cmd.Args[1:])

path, err := exec.LookPath("sh")
require.NoError(t, err)
require.Equal(t, path, cmd.Path)
require.Equal(t, []string{"sh", "-c", "sleep"}, cmd.Args)
})

//nolint:paralleltest // we need to test environment variables
t.Run("Linux", func(t *testing.T) {

//nolint:paralleltest // we need to test environment variables
t.Run("Disabled", func(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("skipping on linux")
Expand All @@ -42,6 +47,7 @@ func TestExec(t *testing.T) {
require.Equal(t, []string{"sh", "-c", "sleep"}, cmd.Args)
})

//nolint:paralleltest // we need to test environment variables
t.Run("Enabled", func(t *testing.T) {
t.Setenv(agentexec.EnvProcPrioMgmt, "hello")

Expand Down
Loading
0