mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 10:45:59 -10:00
A Build handed Options.Home still put three storage roots under the process's home: isolated and best-of-n worktrees, browser profiles, and the missing-reasoning recovery state. Each now resolves through the build's config.Roots, which is the process binding whenever no home is stated, as in every production frontend. The new process-input repolint rule ratchets direct reads of the process environment, working directory and user directories below internal/frontend, so later slices can only move that count down. 40 boot tests now state their home and workspace instead of mutating the process, and run in parallel. The isolation effect test runs two sessions with different homes side by side and fails without the binding fix. The provider registry now holds a read-write lock: parallel Builds register and resolve kinds concurrently, which -race reported as a race and could crash with a concurrent map write. Refs #12531 Refs #12521
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
// processInputFindings parses through parseBytes, the mode the real run uses.
|
|
func processInputFindings(t *testing.T, rel, src string) []Finding {
|
|
t.Helper()
|
|
file := parseBytes(rel, []byte(src))
|
|
if file == nil || file.file == nil {
|
|
t.Fatalf("%s did not parse", rel)
|
|
}
|
|
return checkProcessInput(file)
|
|
}
|
|
|
|
func TestProcessInputReadBelowTheFrontendsIsReported(t *testing.T) {
|
|
src := `package boot
|
|
import "os"
|
|
func f() string { h, _ := os.UserHomeDir(); return h + os.Getenv("X") }
|
|
func g(lookup func(string) string) {}
|
|
func h() { g(os.Getenv) }`
|
|
got := processInputFindings(t, "internal/assembly/boot/x.go", src)
|
|
if len(got) != 3 || got[0].Rule != ruleProcessInput {
|
|
t.Fatalf("findings = %+v, want each call and the value reference", got)
|
|
}
|
|
}
|
|
|
|
func TestProcessInputFollowsTheImportName(t *testing.T) {
|
|
src := `package boot
|
|
import sys "os"
|
|
func f() string { return sys.Getenv("X") }`
|
|
if got := processInputFindings(t, "internal/assembly/boot/x.go", src); len(got) != 1 {
|
|
t.Fatalf("findings = %+v, want the renamed import's read", got)
|
|
}
|
|
}
|
|
|
|
func TestProcessInputLeavesFrontendsHostsAndTestsAlone(t *testing.T) {
|
|
src := `package x
|
|
import "os"
|
|
func f() string { return os.Getenv("X") }`
|
|
for _, rel := range []string{
|
|
"internal/frontend/cli/x.go",
|
|
"cmd/reasonix/x.go",
|
|
"internal/assembly/boot/x_test.go",
|
|
} {
|
|
if got := processInputFindings(t, rel, src); len(got) != 0 {
|
|
t.Fatalf("%s: findings = %+v, want none", rel, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestProcessInputCountsALocalShadowingOs(t *testing.T) {
|
|
src := `package boot
|
|
import "os"
|
|
type env struct{}
|
|
func (env) Getenv(string) string { return "" }
|
|
func f() string { os := env{}; return os.Getenv("X") }
|
|
var _ = os.Args`
|
|
if got := processInputFindings(t, "internal/assembly/boot/x.go", src); len(got) != 1 {
|
|
t.Fatalf("findings = %+v, want the shadowed read counted: names are not resolved", got)
|
|
}
|
|
}
|