fix: skip bash tests on Windows (#19277)

Adds Windows compatibility to toolsdk tests

This PR adds Windows compatibility to the toolsdk tests by:

1. Adding build constraints to exclude bash_test.go from running on
Windows
2. Skipping the WorkspaceSSHExec test on Windows platforms with a clear
message

These changes ensure tests run properly across all supported platforms.

Related to https://github.com/coder/internal/issues/798

Signed-off-by: Thomas Kosiewski <tk@coder.com>
This commit is contained in:
Thomas Kosiewski
2025-08-11 11:43:25 +02:00
committed by GitHub
parent dadeab881b
commit b7e026682a
2 changed files with 23 additions and 0 deletions
+19
View File
@@ -2,6 +2,7 @@ package toolsdk_test
import (
"context"
"runtime"
"testing"
"github.com/stretchr/testify/require"
@@ -14,6 +15,9 @@ import (
func TestWorkspaceBash(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("Skipping on Windows: Workspace MCP bash tools rely on a Unix-like shell (bash) and POSIX/SSH semantics. Use Linux/macOS or WSL for these tests.")
}
t.Run("ValidateArgs", func(t *testing.T) {
t.Parallel()
@@ -97,6 +101,9 @@ func TestWorkspaceBash(t *testing.T) {
func TestNormalizeWorkspaceInput(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("Skipping on Windows: Workspace MCP bash tools rely on a Unix-like shell (bash) and POSIX/SSH semantics. Use Linux/macOS or WSL for these tests.")
}
testCases := []struct {
name string
@@ -151,6 +158,9 @@ func TestNormalizeWorkspaceInput(t *testing.T) {
func TestAllToolsIncludesBash(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("Skipping on Windows: Workspace MCP bash tools rely on a Unix-like shell (bash) and POSIX/SSH semantics. Use Linux/macOS or WSL for these tests.")
}
// Verify that WorkspaceBash is included in the All slice
found := false
@@ -169,6 +179,9 @@ func TestAllToolsIncludesBash(t *testing.T) {
func TestWorkspaceBashTimeout(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("Skipping on Windows: Workspace MCP bash tools rely on a Unix-like shell (bash) and POSIX/SSH semantics. Use Linux/macOS or WSL for these tests.")
}
t.Run("TimeoutDefaultValue", func(t *testing.T) {
t.Parallel()
@@ -251,6 +264,9 @@ func TestWorkspaceBashTimeout(t *testing.T) {
func TestWorkspaceBashTimeoutIntegration(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("Skipping on Windows: Workspace MCP bash tools rely on a Unix-like shell (bash) and POSIX/SSH semantics. Use Linux/macOS or WSL for these tests.")
}
t.Run("ActualTimeoutBehavior", func(t *testing.T) {
t.Parallel()
@@ -338,6 +354,9 @@ func TestWorkspaceBashTimeoutIntegration(t *testing.T) {
func TestWorkspaceBashBackgroundIntegration(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("Skipping on Windows: Workspace MCP bash tools rely on a Unix-like shell (bash) and POSIX/SSH semantics. Use Linux/macOS or WSL for these tests.")
}
t.Run("BackgroundCommandCapturesOutput", func(t *testing.T) {
t.Parallel()
+4
View File
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"os"
"runtime"
"sort"
"sync"
"testing"
@@ -397,6 +398,9 @@ func TestTools(t *testing.T) {
})
t.Run("WorkspaceSSHExec", func(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("WorkspaceSSHExec is not supported on Windows")
}
// Setup workspace exactly like main SSH tests
client, workspace, agentToken := setupWorkspaceForAgent(t)