(t testing.TB, name string, policy *Policy, envOpts []cel.EnvOption, compilerOpts []CompilerOption)
| 504 | } |
| 505 | |
| 506 | func 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 | |
| 533 | func normalize(s string) string { |
| 534 | return strings.ReplaceAll( |
no test coverage detected