- Add testutil.TempDirInMemory() using /dev/shm on Linux for 20-30% I/O speedup - Update slow hash multiclone tests to use in-memory filesystem - Convert 17 scripttest tests (~200+s) to fast CLI tests (31s) with --no-daemon - Disable slow scripttest suite behind build tag - Add README_TESTING.md documenting test strategy and optimizations - Update CI to use -short flag for PR checks, full tests nightly Results: - TestHashIDs_* reduced from ~20s to ~11s (45% reduction) - Scripttest suite eliminated from default runs (massive speedup) - Total integration test time significantly reduced Closes bd-gm7p, bd-l5gq Amp-Thread-ID: https://ampcode.com/threads/T-c2b9434a-cd29-4725-b8e0-cbea50b36fe2 Co-authored-by: Amp <amp@ampcode.com>
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
//go:build scripttests
|
|
// +build scripttests
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"runtime"
|
|
"testing"
|
|
"time"
|
|
|
|
"rsc.io/script"
|
|
"rsc.io/script/scripttest"
|
|
)
|
|
|
|
func TestScripts(t *testing.T) {
|
|
// Skip on Windows - test scripts use sh -c which requires Unix shell
|
|
if runtime.GOOS == "windows" {
|
|
t.Skip("scripttest uses Unix shell commands (sh -c), skipping on Windows")
|
|
}
|
|
|
|
// Build the bd binary
|
|
exeName := "bd"
|
|
binDir := t.TempDir()
|
|
exe := filepath.Join(binDir, exeName)
|
|
if err := exec.Command("go", "build", "-o", exe, ".").Run(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// Create minimal engine with default commands plus bd
|
|
timeout := 2 * time.Second
|
|
engine := script.NewEngine()
|
|
engine.Cmds["bd"] = script.Program(exe, nil, timeout)
|
|
|
|
// Add binDir to PATH so 'sh -c bd ...' works in test scripts
|
|
currentPath := os.Getenv("PATH")
|
|
env := []string{"PATH=" + binDir + ":" + currentPath}
|
|
|
|
// Run all tests
|
|
scripttest.Test(t, context.Background(), engine, env, "testdata/*.txt")
|
|
}
|