Skip to content

Run the tests with package:test and parameterized_test (#17) - #65

Closed
jeremy-morren wants to merge 4 commits into
evoleen:masterfrom
jeremy-morren:migrate-to-package-test
Closed

jeremy-morren wants to merge 4 commits into
evoleen:masterfrom
jeremy-morren:migrate-to-package-test

Conversation

@jeremy-morren

@jeremy-morren jeremy-morren commented Nov 6, 2026 •

Copy link
Copy Markdown

Depends on #63. Closes #17.

Replaces the dart:mirrors harness (@Test, @TestCase, @TestCaseSource, @SkipMe, runTests()) with plain test(), group() and parameterizedTest(). Test bodies are unchanged; a one-off tool (package:analyzer) rewrote the registrations.

  • Names: the same, except groups are separated by a space instead of a dot (Name.[100] → Name [100]).
  • Web: no mirrors, so the suite now compiles with -p chrome, -p node and -c dart2wasm (files needing dart:ffi or files are @TestOn('vm')). Not yet in CI: dart2js fails 6 tests on values above 2^53, and dart2wasm fails timezoneCanBeOverridden.
  • Tests the old harness silently dropped:
    • 22 @SkipMe tests are now reported as skipped.
    • 79 cases had @TestCase without @Test and never ran. 64 pass; 15 fail because of casts ported from C#, and are skipped with a reason.
  • Timeouts: the two OS comparisons (zdump, Windows API; ~20–25s alone) get 5 minutes instead of the default 30s.
  • Requires Dart ≥ 3.8 to pub get (parameterized_test is a dev dependency). Consumers are unaffected.
Passed Skipped
Windows 10,450 52
Linux 10,455 47

Not fixed here: TestHelper.TestOperatorEquality and the other operator helpers return their check instead of calling it, so they have never checked anything.

🤖 Generated with Claude Code

…luding non-English)

On Windows, DateTimeZone.local was UTC on most systems: detection matched
DateTime.timeZoneName (a Windows display name, localized on non-English
Windows) against a hard-coded table of English names, and fell back to UTC.
Six tests failed on Windows machines outside UTC as a result.

Local zone detection now follows Noda Time, which maps .NET's
TimeZoneInfo.Local.Id:

- Windows: the Windows zone ID from GetDynamicTimeZoneInformation (via
  dart:ffi), mapped with CLDR data embedded in tzdb.bin. The ID is the
  same in every display language. With automatic DST adjustment turned
  off, the guess below is used instead.
- Linux/macOS: the IANA ID found as .NET finds it: TZ (empty means UTC,
  ':' prefix ignored, absolute paths are zoneinfo files), else the
  /etc/localtime symlink target, else the zoneinfo file with the same
  contents. Android: persist.sys.timezone.
- TZ on Windows follows Python's tzlocal and Node.js (.NET and Noda Time
  ignore it): an IANA ID, a Windows zone ID (mapped with CLDR) or a path to
  a zone file is used; empty or unrecognised values (e.g. POSIX rules)
  leave Windows' own zone.
- Otherwise: a port of Noda Time's guess by transitions, then a fixed
  zone at the current offset (no longer UTC). On Windows with automatic
  DST adjustment off, the guess uses the zone's standard offset as Windows
  reports it, not Dart's DateTime (whose C runtime applies TZ).
The abbreviation heuristic and its hard-coded name table are removed.

Embedded CLDR Windows mapping (enabling the existing compiler port):
- Check in CLDR windowsZones.xml for every version Noda Time has (21 to
  49), from unicode-org/cldr release tags; the compiler picks the newest
  suitable file and validates it against the TZDB data.
- Fix the ported CLDR parser (root element, otherVersion, splitting IDs,
  version from the file name) and MergeWindowsZones (identity-keyed map).
- NameIdMappingSupport: Russia TZ 3/10/11 and Türkiye.

Public API matching Noda Time's TzdbDateTimeZoneSource: defaultSource,
tzdbVersion, canonicalIdMap, aliases, windowsMapping, windowsToTzdbIds,
tzdbToWindowsIds and validate(); MapZone and WindowsZones are exported.

Tests: ports of Noda Time's TzdbDateTimeZoneSourceTest, MapZoneTest,
WindowsZonesTest, CldrWindowsZonesParserTest, NameIdMappingSupportTest and
ProgramTest; Windows registry and local zone tests; Unix and TZ
behaviour tests (including child processes with TZ set).

Also: version 0.15.0 (0.14.0 is already published), with a CHANGELOG
entry; require archive ^4.6.0 (XZDecoder); NOTICE references Noda Time
3.3.0, copyright to 2026.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

if [ -n "${{ matrix.tz }}" ]; then export TZ="${{ matrix.tz }}"; fi
dart test \
--coverage=coverage/raw \
--file-reporter=json:test-results/tests.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test reporter parent directory never created

High Severity

--file-reporter writes under test-results/, but the workflow never creates that directory. Dart's File.openWrite() does not create parent directories, so dart test and flutter test fail immediately on a clean checkout. The same path is used in the Sanity, Web, Android, and iOS jobs.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d49ed03. Configure here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bug. dart test --file-reporter creates the directory itself. Every Sanity leg on this branch passed, and the results-ubuntu artifact contains test-results/tests.json and test-results/compiler-tests.json.

run: |
dart run coverage:format_coverage --lcov --check-ignore \
--report-on=lib --base-directory=. \
--in=coverage/raw --out=coverage/lcov.info

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage tool is not a direct dependency

High Severity

The Sanity job runs dart run coverage:format_coverage, but coverage is not listed in pubspec.yaml. dart run only resolves immediate dependencies, so LCOV conversion fails after tests succeed and turns the job red even when the suite passed.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d49ed03. Configure here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bug. coverage comes in through test, and dart run coverage:format_coverage resolves it. "Convert coverage to LCOV" succeeded on all four Sanity legs, and the Ubuntu artifact's coverage/lcov.info has 9,851 lines.

@jeremy-morren
jeremy-morren force-pushed the migrate-to-package-test branch from d49ed03 to 1bb9f12 Compare November 6, 2026 20:17
@jeremy-morren

Copy link
Copy Markdown
Author

@cursor review

@jeremy-morren
jeremy-morren force-pushed the migrate-to-package-test branch from 1bb9f12 to f491165 Compare November 6, 2026 20:19
@jeremy-morren

Copy link
Copy Markdown
Author

@cursor review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@jeremy-morren
jeremy-morren force-pushed the migrate-to-package-test branch 2 times, most recently from 62131b9 to f491165 Compare November 6, 2026 20:53
…ndows; publish test results and coverage

CI only ran on Ubuntu in UTC, so it never saw platform-specific local time
zone problems (such as Windows detecting UTC). Matrix legs:

- Ubuntu: the /etc/localtime symlink.
- Ubuntu with TZ=Australia/Sydney: the TZ environment variable, with DST.
- Windows (English): the Windows zone ID mapped with CLDR, in
  AUS Eastern Standard Time (with DST).
- Windows (non-English): W. Europe Standard Time with German display
  names, as on German Windows. GitHub has no non-English runners and
  language packs can't be installed on them in reasonable time, so the
  zone's display names are set with SetDynamicTimeZoneInformation; the
  zone ID stays English, exactly as on localized Windows. A guard test
  (TIME_MACHINE_EXPECT_LOCALIZED_WINDOWS=1) fails the leg if Dart doesn't
  report the localized names.
- macOS is paused: GitHub's macOS arm64 runners are at capacity.

Also runs the TZDB compiler's tests and validates the package on every
leg, and publishes results with existing actions:

- Each leg collects LCOV coverage (lib/ only) and JSON test results,
  writes a coverage summary to its job summary (ReportGenerator) and
  uploads them as an artifact.
- A final job combines all legs: EnricoMi/publish-unit-test-result-action
  publishes a job summary, a "Test Results" check run and one PR comment
  for all platforms; ReportGenerator merges coverage into a job summary
  and an HTML artifact, posted as one PR comment
  (marocchino/sticky-pull-request-comment). Both comments are updated in
  place. Fork PRs get the job summaries only (read-only token).
- Runs on pull requests as well as pushes.

A pana job checks pub.dev platform support: it fails if pana stops
reporting any of the tags for everywhere Dart runs (the six platforms,
native AOT/JIT and web runtimes, WebAssembly, Dart and Flutter SDKs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremy-morren
jeremy-morren force-pushed the migrate-to-package-test branch from f491165 to e214907 Compare November 7, 2026 23:20
@jeremy-morren

Copy link
Copy Markdown
Author

@cursor review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

jeremy-morren and others added 2 commits November 8, 2026 07:24
…base

The equivalent of Noda Time's BclDateTimeZoneSource (.NET's TimeZoneInfo),
exposed as DateTimeZoneProviders.system. It never falls back to the
embedded TZDB data: on a platform without time zone data it throws
UnsupportedError, and unknown IDs throw DateTimeZoneNotFoundError. Use
DateTimeZoneProviders.tzdb for data on every platform.

Backends, chosen by conditional import:
- Windows (dart:ffi): zone IDs from EnumDynamicTimeZoneInformation, rules
  for each year from GetTimeZoneInformationForYear, converted the way Noda
  Time converts adjustment rules (with fixes for rule boundaries at New
  Year and Windows' start-of-year marker transitions). Matches
  SystemTimeToTzSpecificLocalTimeEx for all 144 zones at ~1M instants.
  forId and the provider also accept IANA IDs, as .NET 6+ does: mapped to
  a Windows zone with Windows' own ICU (icu.dll), with the requested ID.
  getIds lists only Windows IDs.
- Linux, macOS, iOS: TZif v1-v4 files in $TZDIR or /usr/share/zoneinfo,
  including the POSIX TZ footer. Matches zdump for every zone.
- Android: the system tzdata bundle (APEX or /system), reusing the TZif
  parser.
The system default follows TZ as DateTimeZone.local does, so both pick the
same zone: on Linux and macOS by .NET's rules; on Windows (as Python's
tzlocal and Node.js) a Windows zone ID, or an IANA ID mapped to a Windows
zone with Windows' own ICU (icu.dll, as .NET does), with empty or
unrecognised values leaving Windows' own zone.

- Web (JS and WASM, dart:js_interop): the browser's Intl data; offsets
  from Intl.DateTimeFormat, transitions from Temporal when available or
  else by search; the standard/daylight split is inferred.

Tests: unit tests for the Windows rule conversion, TZif, the POSIX footer
and the Android bundle, comparisons against the OS (Windows) and zdump
(Linux), and shared checks (test/system_source) that run on the VM, in
Chrome (dart2js and dart2wasm), in Node, and on Android and iOS through
a Flutter integration test app (test_apps/system_source_flutter).

CI: web legs (Chrome JS, Chrome WASM, Node), Android emulators (API 35
with the APEX tzdata, API 28 with /system tzdata) and an iOS Simulator
job; web and Android results are included in the combined report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the dart:mirrors test harness (test/testing/test_fx.dart with its
@test, @testcase, @TestCaseSource and @skipme annotations and runTests())
with plain package:test registrations, and parameterized_test for the
parameterized tests. Each test file's main() now registers its tests with
test(), group() and parameterizedTest(), so dart test and IDEs see ordinary
tests: no custom runner to maintain, and no dart:mirrors anywhere in test/.

The test bodies are unchanged; only their annotations went, and main() now
lists them in source order. A one-off migration tool (package:analyzer, kept
outside the repository) did the rewrite:

- test functions: test('Name', Name); test classes: group('Class', ...) with
  one instance shared by its tests, as before, including the PatternTestBase
  and TextCursorTestBase methods each subclass inherits.
- @testcase and @TestCaseSource: parameterizedTest('Name', values, Name),
  with each case named after its arguments as before ([2011, 1, 1]), or after
  its description through .options(customDescriptionBuilder: ...).
  Sources that were only [null] are not registered, as before.
- @skipme: skip:, so these tests are now reported as skipped instead of being
  left out.
- A main() that only awaited TimeMachineTest.initialize() and setup() is now
  void main() with setUpAll(); the few files whose registrations need that
  state (test case sources, cultures loaded in main) still await it before
  registering, as the harness did.
- Imports left unused (dart:async, time_machine_testing.dart) were removed.

Test names are the same except that package:test separates groups with a
space where the harness used a dot: "Name.[100]" is now "Name [100]", and
"Class.Method.[...]" is "Class Method [...]".

By hand: era_test lists the Era constants instead of reflecting them;
TestCaseData became .options(customDescriptionBuilder: ...); the
operator-test helpers always use the mirrors-free implementation (TestHelper
never calls either). Functions with @testcase but no @test, which the harness
never ran, are now registered; the cases that fail because they were ported
from C# casts or null arguments are skipped with a reason. Tests that need
dart:ffi or files are marked @teston('vm'), so the rest of the suite also
runs with dart test -p chrome, -p node and -c dart2wasm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremy-morren
jeremy-morren force-pushed the migrate-to-package-test branch from e214907 to 68cb34c Compare November 8, 2026 11:26
@jeremy-morren

Copy link
Copy Markdown
Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 3 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 68cb34c. Configure here.

Comment thread test_apps/.pubignore
@@ -0,0 +1,2 @@
# Apps that only CI uses (see their READMEs); not part of the published package.
*

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nested pubignore does not exclude test apps

Medium Severity

Pub only honors .pubignore files when a .pubignore exists at the package root; otherwise it uses .gitignore patterns. This subdirectory .pubignore is therefore ignored, so the Flutter CI app under test_apps/ is still included in the published package despite the comment that it is not.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 68cb34c. Configure here.

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.

Replace test harness with Dart native tests

1 participant