(t testing.TB, name string, policy *Policy, envOpts []cel.EnvOption, compilerOpts []CompilerOption)
| 507 | } |
| 508 | |
| 509 | func 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 | |
| 536 | func normalize(s string) string { |
| 537 | return strings.ReplaceAll( |
no test coverage detected