28 lines
713 B
Go
28 lines
713 B
Go
package tests
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// TestMain ensures the Zig CLI is built once before running E2E tests.
|
|
// If the build fails, tests that depend on the CLI will skip based on their
|
|
// existing checks for the CLI binary path.
|
|
func TestMain(m *testing.M) {
|
|
cliDir := filepath.Join("..", "..", "cli")
|
|
|
|
cmd := exec.CommandContext(context.Background(), "zig", "build", "--release=fast")
|
|
cmd.Dir = cliDir
|
|
|
|
if output, err := cmd.CombinedOutput(); err != nil {
|
|
log.Printf("zig build for CLI failed (CLI-dependent tests may skip): %v\nOutput:\n%s", err, string(output))
|
|
} else {
|
|
log.Printf("zig build succeeded for CLI E2E tests")
|
|
}
|
|
|
|
os.Exit(m.Run())
|
|
}
|