45 lines
978 B
Go
45 lines
978 B
Go
//go:build llm_script
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestScriptsPackageCompileContract(t *testing.T) {
|
|
projectRoot, err := os.Getwd()
|
|
if err != nil {
|
|
t.Fatalf("getwd: %v", err)
|
|
}
|
|
scriptDir := projectRoot
|
|
if filepath.Base(projectRoot) != "scripts" {
|
|
scriptDir = filepath.Join(projectRoot, "scripts")
|
|
}
|
|
|
|
entries, err := os.ReadDir(scriptDir)
|
|
if err != nil {
|
|
t.Fatalf("readdir %s: %v", scriptDir, err)
|
|
}
|
|
|
|
var mainCount int
|
|
for _, entry := range entries {
|
|
if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".go") || strings.HasSuffix(entry.Name(), "_test.go") {
|
|
continue
|
|
}
|
|
content, err := os.ReadFile(filepath.Join(scriptDir, entry.Name()))
|
|
if err != nil {
|
|
t.Fatalf("read %s: %v", entry.Name(), err)
|
|
}
|
|
if strings.Contains(string(content), "func main()") {
|
|
mainCount++
|
|
}
|
|
}
|
|
|
|
if mainCount < 2 {
|
|
t.Fatalf("expected scripts package to contain multiple CLI entrypoints, got %d", mainCount)
|
|
}
|
|
}
|