MCPcopy Create free account
hub / github.com/cel-expr/cel-go / compile

Function compile

policy/compiler_test.go:506–531  ·  view source on GitHub ↗
(t testing.TB, name string, policy *Policy, envOpts []cel.EnvOption, compilerOpts []CompilerOption)

Source from the content-addressed store, hash-verified

504}
505
506func compile(t testing.TB, name string, policy *Policy, envOpts []cel.EnvOption, compilerOpts []CompilerOption) (*cel.Env, *cel.Ast, *cel.Issues) {
507 config := readPolicyConfig(t, fmt.Sprintf("testdata/%s/config.yaml", name))
508 env, err := cel.NewCustomEnv(
509 cel.OptionalTypes(),
510 cel.EnableMacroCallTracking(),
511 cel.ExtendedValidations(),
512 ext.Bindings())
513 if err != nil {
514 t.Fatalf("cel.NewEnv() failed: %v", err)
515 }
516 // Configure any custom environment options.
517 env, err = env.Extend(envOpts...)
518 if err != nil {
519 t.Fatalf("env.Extend() with env options %v, failed: %v", config, err)
520 }
521 // Configure declarations
522 env, err = env.Extend(FromConfig(config))
523 if err != nil {
524 t.Fatalf("env.Extend() with config options %v, failed: %v", config, err)
525 }
526 ast, iss := Compile(env, policy, compilerOpts...)
527 if iss.Err() == nil {
528 verifySourceInfoCoverage(t, policy, ast)
529 }
530 return env, ast, iss
531}
532
533func normalize(s string) string {
534 return strings.ReplaceAll(

Callers 5

TestCompileErrorFunction · 0.70
TestWhitespaceHanldingFunction · 0.70
compileMethod · 0.70

Calls 11

NewCustomEnvFunction · 0.92
OptionalTypesFunction · 0.92
EnableMacroCallTrackingFunction · 0.92
ExtendedValidationsFunction · 0.92
BindingsFunction · 0.92
readPolicyConfigFunction · 0.85
verifySourceInfoCoverageFunction · 0.85
ErrMethod · 0.80
FromConfigFunction · 0.70
CompileFunction · 0.70
ExtendMethod · 0.45

Tested by

no test coverage detected