Skip to content

test(compiler-cli): add compliance coverage for under-tested emit behaviors#69913

Draft
mattrbeck wants to merge 2 commits into
angular:mainfrom
mattrbeck:test/compliance-additional-coverage
Draft

test(compiler-cli): add compliance coverage for under-tested emit behaviors#69913
mattrbeck wants to merge 2 commits into
angular:mainfrom
mattrbeck:test/compliance-additional-coverage

Conversation

@mattrbeck

@mattrbeck mattrbeck commented Jul 23, 2026

Copy link
Copy Markdown
Member

A number of compiler emit behaviors are exercised only in ngtsc unit tests, or are not covered anywhere, rather than in the file-based compliance suite. For example the ɵɵsetNgModuleScope JIT-scope call is always elided behind in existing goldens, and ɵɵsanitizeUrlOrResourceUrl (the runtime URL/resource-URL sanitizer used for ambiguous host bindings) has no compliance coverage. This change adds compliance test cases for these behaviors.

Coverage added, by destination directory:

  • r3_compiler_compliance/ng_modulesɵɵsetNgModuleScope (declarations/imports/exports; previously only ever elided), injector providers (useClass/useExisting/useValue/multi/useFactory+deps), same-file forRoot() ModuleWithProviders (raw call in the injector, unwrapped module in the scope), standalone declarables excluded from the injector but kept in scope, exports-only re-exported modules, nested-array/constant injector imports (with full-mode scope flattening), and forwardRef imports lowered to a closure in the scope.
  • r3_view_compiler_di/di and service_decorator — constructor injection flags (@Optional/@Self/@SkipSelf/@Host/@Attribute), and @Injectable({ providedIn }) variants ('platform', 'any', a module type).
  • r3_compiler_compliance/components_and_directives, r3_view_compiler_bindings, r3_view_compiler_styling, r3_view_compiler_input_outputs@Input transforms encoded inline in the inputs map, @HostBinding/@HostListener merged with the host object, host [class]/[style] map bindings plus a [style.width.px] unit binding, exportAs read via a template-reference viewQuery, cross-file inheritance (ɵɵInheritDefinitionFeature), and OnPush change-detection / encapsulation metadata.
  • signal_inputsinput() / input.required() / model() / output() metadata (signal input flag, model two-way output).
  • r3_view_compiler_bindings / r3_view_compiler_deferred / r3_compiler_compliance / r3_view_compiler_control_flow — two-way binding to a signal model(), a @defer block (interaction trigger + prefetch-on-idle + placeholder/loading timing), multi-slot content projection with ngProjectAs, and an @for block with a track function and @empty.
  • r3_view_compiler_i18n — a $localize message with meaning|description@@id metadata and interpolation/tag placeholders, ɵɵi18nAttributes, plural and nested (select-in-plural) ICUs via ɵɵi18nPostprocess, and an i18n block wrapping @if/@else.
  • r3_view_compiler_bindings/host_bindings and r3_compiler_compliance/elementsɵɵsanitizeUrlOrResourceUrl for ambiguous src/href host bindings on an attribute-only directive (element unknown at compile time), ɵɵtrustConstantResourceUrl for static security-sensitive resource URLs, and an SVG-namespaced xlink:href binding.

Note: the prettier reformatting of the existing TEST_CASES.json files this change appends to is split into #69916 to keep this diff to pure additions. Until that lands, the ng-dev format check here will fail on those files; rebasing on top of it clears the check.

@angular-robot angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Jul 23, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jul 23, 2026
@mattrbeck
mattrbeck force-pushed the test/compliance-additional-coverage branch 3 times, most recently from f718c90 to e79acac Compare July 23, 2026 17:43
…aviors

Adds file-based compliance test cases for a number of compiler emit
behaviors that are currently exercised only in ngtsc unit tests (or not
covered at all) rather than in the compliance suite. Each case is added
to the existing compliance directory that matches its area, alongside the
related cases, rather than in a separate tree. New cases span:

- NgModule (r3_compiler_compliance/ng_modules): the setNgModuleScope JIT
  scope call, injector providers (useClass/useExisting/useValue/multi/
  useFactory), same-file ModuleWithProviders, standalone declarables in
  imports, exports-only re-exports, and nested-array / forwardRef injector
  imports.
- DI: constructor injection flags (@Optional/@Self/@SkipSelf/@Host/
  @Attribute) in r3_view_compiler_di, and @Injectable providedIn variants
  ('platform'/'any'/a module type) in service_decorator.
- Directives/components (r3_compiler_compliance, r3_view_compiler_bindings,
  r3_view_compiler_styling, r3_view_compiler_input_outputs): @input
  transforms, @HostBinding/@HostListener merged with the host object, host
  [class]/[style] bindings, exportAs read via a template-reference query,
  cross-file inheritance (InheritDefinitionFeature), and OnPush change
  detection / encapsulation metadata.
- Signals (signal_inputs): input()/input.required()/model()/output().
- Templates: two-way binding to a model (r3_view_compiler_bindings), @defer
  with triggers (r3_view_compiler_deferred), multi-slot content projection
  with ngProjectAs (r3_compiler_compliance), and @for with track and @empty
  (r3_view_compiler_control_flow).
- i18n (r3_view_compiler_i18n): $localize meaning/description/id metadata
  and placeholders, i18n attributes, plural and nested (select-in-plural)
  ICUs, and an i18n block wrapping @if/@else.
- Sanitization: sanitizeUrlOrResourceUrl for ambiguous host src/href on an
  attribute-only directive (r3_view_compiler_bindings), trustConstantResourceUrl
  for static resource URLs and an SVG xlink:href binding (r3_compiler_compliance
  elements).

Each case runs in full and/or local compilation mode, with expected files
verified against the compiler output and golden partials generated.
@mattrbeck
mattrbeck force-pushed the test/compliance-additional-coverage branch from e79acac to 6430218 Compare July 23, 2026 18:08
…, declaration ordering, and forwardRef exports

Adds compliance test coverage for:
- Pipe resolution precedence across imported modules (last imported pipe is selected)
- Directive/component ordering in component dependencies (imported module declarables before local declarations)
- ForwardRef module unwrapping in NgModule exports to injector imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: compiler Issues related to `ngc`, Angular's template compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant