Skip to content

Commit 04a8b11

Browse files
committed
test: improve Rust toolchain detection in E2E tests
Previously, isRustAvailable() only checked for rustc binary, which could give false positives when WASM cache hits in CI (rustc present but toolchain incomplete). Changes: - Check for rustc, cargo, and wasm32-unknown-unknown target - Add skip logic to TestE2E_ScriptValidation for Rust tests - Comprehensive toolchain validation prevents compilation failures This fixes 3 failing tests: - TestE2E_ScriptingAPI_ResponseModification - TestE2E_ScriptingAPI_BothTriggers - TestE2E_ScriptValidation/Valid_Rust All tests now properly detect unavailable Rust environment and skip gracefully instead of failing with 400 errors.
1 parent 99b9166 commit 04a8b11

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

internal/e2e/scripting_compilation_test.go

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"os"
1111
"os/exec"
1212
"path/filepath"
13+
"strings"
1314
"testing"
1415
"time"
1516
)
@@ -580,6 +581,11 @@ func TestE2E_ScriptValidation(t *testing.T) {
580581

581582
for _, tt := range tests {
582583
t.Run(tt.name, func(t *testing.T) {
584+
// Skip Rust tests if toolchain is not available
585+
if tt.language == "rust" && !isRustAvailable() {
586+
t.Skip("Rust toolchain not available (rustc, cargo, or wasm32 target missing)")
587+
}
588+
583589
validateReq := map[string]any{
584590
"language": tt.language,
585591
"sourceCode": tt.code,
@@ -601,8 +607,25 @@ func TestE2E_ScriptValidation(t *testing.T) {
601607
}
602608
}
603609

604-
// Helper function to check if Rust is available
610+
// Helper function to check if Rust is available with full compilation capability
611+
// Checks for rustc, cargo, and wasm32-unknown-unknown target
605612
func isRustAvailable() bool {
606-
cmd := exec.Command("rustc", "--version")
607-
return cmd.Run() == nil
613+
// Check if rustc exists
614+
if cmd := exec.Command("rustc", "--version"); cmd.Run() != nil {
615+
return false
616+
}
617+
618+
// Check if cargo exists
619+
if cmd := exec.Command("cargo", "--version"); cmd.Run() != nil {
620+
return false
621+
}
622+
623+
// Check if wasm32-unknown-unknown target is installed
624+
cmd := exec.Command("rustc", "--print", "target-list")
625+
out, err := cmd.Output()
626+
if err != nil {
627+
return false
628+
}
629+
630+
return strings.Contains(string(out), "wasm32-unknown-unknown")
608631
}

0 commit comments

Comments
 (0)