Adds check 29: ported plugin repos must not carry a `-buildmode=plugin` build target (the legacy .so compile the wasm migration retires). Lands DISABLED behind a per-check const toggle (enableBuildmodePluginCheck=false) so it emits no output and never fails while the fleet is still porting; WO-WZ-017 flips it on. Scans plugin Makefiles/*.sh only. Unit-tested; golden snapshots unaffected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestCheckBuildmodePlugin_FlagsMakefileAndScript(t *testing.T) {
|
|
root := t.TempDir()
|
|
if err := os.WriteFile(filepath.Join(root, "Makefile"),
|
|
[]byte("build-so:\n\tgo build -buildmode=plugin -o plugin.so .\n"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(root, "build.sh"),
|
|
[]byte("#!/bin/sh\ngo build -buildmode=plugin -o x.so .\n"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// A non-build file mentioning the string must NOT be flagged.
|
|
if err := os.WriteFile(filepath.Join(root, "README.md"),
|
|
[]byte("we used to run go build -buildmode=plugin here\n"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
v := checkBuildmodePlugin([]pluginScanTarget{{root: root, display: "demo"}})
|
|
if len(v) != 2 {
|
|
t.Fatalf("got %d violations, want 2: %+v", len(v), v)
|
|
}
|
|
}
|
|
|
|
func TestCheckBuildmodePlugin_CleanRepo(t *testing.T) {
|
|
root := t.TempDir()
|
|
if err := os.WriteFile(filepath.Join(root, "Makefile"),
|
|
[]byte("build-wasm:\n\tninja plugin build\n"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if v := checkBuildmodePlugin([]pluginScanTarget{{root: root, display: "demo"}}); len(v) != 0 {
|
|
t.Fatalf("clean repo flagged: %+v", v)
|
|
}
|
|
}
|