Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test generation for data updates #1059

Merged
merged 5 commits into from
May 7, 2023
Merged

Conversation

gilmoreorless
Copy link
Member

This fixes a few things that were bugging me about the release process.

  1. The zdump output and test generation code was all written for an old 32-bit version of zdump. But the newer 64-bit versions have different flags and output. This resulted in an overly-verbose output format, and accidentally skipping the first and last transitions when generating unit tests. (Or in the case of fixed-offset zones, generating no tests at all.)
  2. I build releases on macOS, but the provided versions of zic and zdump in macOS are horrendously old and only support 32-bit data. I've been manually compiling the binaries from tzdb instead, then temporarily changing data-zic.js and data-zdump.js to reference the custom versions.
  3. The countries unit tests weren't auto-generated, so we have to keep manually tweaking them when data changes during a release. This is error-prone and inconsistent (e.g. it turns out some new zones were missing from the test file).

So after a fair amount of comparing the output of zdump on various machines, this PR does the following:

  1. Allow using custom paths to the zic and zdump binaries by passing --zic-path=/path/to/zic and --zdump-path=/path/to/zdump arguments to the grunt data tasks.
  2. Add warnings when the used zic or zdump doesn't support 64-bit data, and switch between the -V and -v flags depending on what's supported.
  3. Extra zdump output validation and comments.
  4. Generate unit tests for all transitions, with the assumption the data has been validated in previous steps.
  5. Generate unit tests for zone.countries() and tz.zonesForCountry().

The `-V` flag was introduced 10 years ago but macOS uses a very old version of
`zdump` that doesn't support it. The versions of `zic` and `zdump` shipped with
macOS only support 32-bit data files.

A while ago the `data-zdump` task was changed from `-V` to `-v` to support
building on macOS, but that also switched to a far more verbose output format
on Linux machines. The best solution is to use `-v` for macOS but `-V` for
newer versions of `zdump`.

This also logs some warnings when `zic` and `zdump` are outdated.
The best solution for building the data on macOS currently is to manually
compile `zic` and `zdump` from the tzcode source.
This allows people on macOS (or other systems shipping old tzcode versions) to
compile `zic` and `zdump` manually to a different location, then use them in
the data compilation pipeline.

Usage:

- `grunt data-zic --zic-path=/path/to/custom/zic`
- `grunt data-zdump --zdump-path=/path/to/custom/zdump`
The old data-tests behaviour skipped the first 2 and last 2 lines of the
`zdump` output when generating transition tests. This was done when the build
process only used the 32-bit `zdump` output. The output always included
transitions for the 32-bit boundaries (1901 and 2038), regardless of the
actual zone data.

Now that the build uses 64-bit data by default, this behaviour was skipping out
valid transition tests. This commit removes the skipping step, but adds an
extra check for fixed zones with no transitions. Zones like `Etc/UTC` have no
transitions, so weren't generating any transition tests. Now they generate a
single test for 1970-01-01.
@gilmoreorless gilmoreorless merged commit fe79bc6 into develop May 7, 2023
@gilmoreorless gilmoreorless deleted the fix-test-generation branch May 7, 2023 10:10
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