Skip to content

Add WinRT regression test harness (portable golden net) - #66

Open
Gordon Lam (yeelam-gordon) wants to merge 8 commits into
microsoft:mainfrom
yeelam-gordon:test/winrt-regression-harness
Open

Add WinRT regression test harness (portable golden net)#66
Gordon Lam (yeelam-gordon) wants to merge 8 commits into
microsoft:mainfrom
yeelam-gordon:test/winrt-regression-harness

Conversation

@yeelam-gordon

@yeelam-gordon Gordon Lam (yeelam-gordon) commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a portable WinRT regression test — one self‑contained integration test (crates/dynwinrt/tests/winrt_regression.rs) that uses only dynwinrt's public API and asserts ~43 golden facts about real WinRT behavior. It locks current behavior so future engine/codegen changes can't silently regress it. Independent of the Win32/COM work.

Motivation

dynwinrt is a dynamic FFI + codegen engine: it marshals arbitrary WinRT calls through libffi driven by .winmd metadata. Regressions there are easy to introduce and hard to notice by eye. This net runs in CI (cargo test -p dynwinrt) and is deliberately public‑API‑only, so it stays stable across internal refactors while still exercising the full activate → dynamic‑invoke → marshal‑back path against real Windows APIs.

What it covers

  • Windows.Foundation.Uri — dynamically activate and read Host / Domain / Path / SchemeName / AbsoluteUri for fixed inputs (incl. query/fragment, empty‑path).
  • PropertyValue — scalar create/read round‑trips and type‑mismatch behavior.
  • BasicGeoposition / Geopoint — value‑type struct layout + a dynamic round‑trip through a factory that takes a struct.

Sample (shape of an assertion)

// crates/dynwinrt/tests/winrt_regression.rs — public API only
let uri = /* dynamically activated Windows.Foundation.Uri via MetadataTable */;
assert_eq!(host, "example.com");
assert_eq!(path, "/a/b");
assert_eq!(scheme, "https");

Status

Green today: 1 integration test, ~43 assertions, alongside the existing unit suite. Base: main; independent of the classic‑COM and flat‑Win32 PRs (it is used to prove those don't regress WinRT behavior).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot review (PR #3): projected_values_equal returned after the FIRST shared
attribute (name/value/path) matched, so an object exposing more than one of them
(e.g. both .name and .value) could be treated as equal when only the first matches,
weakening the regression protocol checks. Compare every shared attribute and return
False if any differ; keep the scalar-equality fallback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nown kinds

Copilot review: the E2E spec schema includes instantiate.kind 'constructor' (py_runner
already handles it), but ts_runner only handled 'activate'/'static_factory', leaving obj
null and proceeding for 'constructor' or any unexpected kind — which could report a pass
with no object. Add the 'constructor' branch (new cls(...args), mirroring py_runner) and
throw on unknown kinds. (The current constructor spec is py-only, so no ts behavior
changes today; this is defensive.)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…D_MODE in init

Copilot review (PR #3):
- winrt_regression.rs uses WinRT/Win32 APIs (RoInitialize etc.) and won't compile on
  non-Windows; add #![cfg(windows)] so cargo test stays usable off-Windows.
- init_winrt ignored ALL RoInitialize failures despite the comment saying only the
  already-initialized case is benign. Now it accepts only RPC_E_CHANGED_MODE (already
  initialized in a different apartment; S_FALSE is already Ok) and panics on any other
  HRESULT so a genuine init failure is diagnosable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…aw literal

Copilot review (PR #3): the golden-behavior harness asserted against a raw
0x80028CA0 HRESULT literal. Name it TYPE_E_TYPEMISMATCH locally (GetString on a
non-string IPropertyValue) for readability/maintainability.
The earlier ts_runner 'constructor' handling compared instKind against a literal not
in the Instantiate.kind union ('activate' | 'static_factory' | 'none'), which a
type-checked (tsc) run rejects as TS2367 (no overlap). Extend the union to include
'constructor'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant