zzet--gortex
a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
37 行
1.3 KiB
Go
37 行
1.3 KiB
Go
package lsp
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestEffectiveInitializationOptions_JdtlsBuildGate(t *testing.T) {
|
|
spec := &ServerSpec{Command: "jdtls", InitializationOptions: json.RawMessage(jdtlsSafeInitOptions)}
|
|
|
|
// Default (gate unset): safe — no autobuild, no import.
|
|
t.Setenv(JdtlsTrustBuildEnv, "")
|
|
got := string(effectiveInitializationOptions(spec))
|
|
assert.Contains(t, got, `"autobuild": {"enabled": false}`)
|
|
assert.NotContains(t, got, `"autobuild": {"enabled": true}`)
|
|
|
|
// Opted-in: build-backed options.
|
|
t.Setenv(JdtlsTrustBuildEnv, "1")
|
|
got = string(effectiveInitializationOptions(spec))
|
|
assert.Contains(t, got, `"autobuild": {"enabled": true}`)
|
|
assert.Contains(t, got, `"gradle": {"enabled": true}`)
|
|
|
|
// Non-jdtls servers are never rewritten, even when the gate is on.
|
|
other := &ServerSpec{Command: "gopls", InitializationOptions: json.RawMessage(`{"x":1}`)}
|
|
assert.Equal(t, `{"x":1}`, string(effectiveInitializationOptions(other)))
|
|
|
|
// The shipped jdtls spec is safe by default.
|
|
for i := range Servers {
|
|
if Servers[i].Command == "jdtls" {
|
|
assert.Contains(t, string(Servers[i].InitializationOptions), `"autobuild": {"enabled": false}`,
|
|
"shipped jdtls spec must be no-build by default")
|
|
}
|
|
}
|
|
}
|