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

Function compile

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

Source from the content-addressed store, hash-verified

507}
508
509func compile(t testing.TB, name string, policy *Policy, envOpts []cel.EnvOption, compilerOpts []CompilerOption) (*cel.Env, *cel.Ast, *cel.Issues) {
510 config := readPolicyConfig(t, fmt.Sprintf("testdata/%s/config.yaml", name))
511 env, err := cel.NewCustomEnv(
512 cel.OptionalTypes(),
513 cel.EnableMacroCallTracking(),
514 cel.ExtendedValidations(),
515 ext.Bindings())
516 if err != nil {
517 t.Fatalf("cel.NewEnv() failed: %v", err)
518 }
519 // Configure any custom environment options.
520 env, err = env.Extend(envOpts...)
521 if err != nil {
522 t.Fatalf("env.Extend() with env options %v, failed: %v", config, err)
523 }
524 // Configure declarations
525 env, err = env.Extend(FromConfig(config))
526 if err != nil {
527 t.Fatalf("env.Extend() with config options %v, failed: %v", config, err)
528 }
529 ast, iss := Compile(env, policy, compilerOpts...)
530 if iss.Err() == nil {
531 verifySourceInfoCoverage(t, policy, ast)
532 }
533 return env, ast, iss
534}
535
536func normalize(s string) string {
537 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
CompileFunction · 0.85
verifySourceInfoCoverageFunction · 0.85
ErrMethod · 0.80
FromConfigFunction · 0.70
ExtendMethod · 0.45

Tested by

no test coverage detected