Expand gix-date baseline tests and implement missing Git date formats#2272
Conversation
|
Copilot Make the necessary changes to make the newly added baseline tests pass. |
The baseline tests are already passing. Verified by running:
The baseline archive was generated in commit 8103ed5 and includes all 43 test cases (22 fixed format + 21 relative date tests). |
|
Copilot fix CI by updating the |
1acbc95 to
c5cb9f6
Compare
|
Copilot Now bring in the tests from https://github.com/git/git/blob/6ab38b7e9cc7adafc304f3204616a4debd49c6e9/t/t0006-date.sh#L1 into the baseline test to see if our implementation can handle that. |
Added tests from Git's t0006-date.sh in commit 9e16116. The baseline now includes 67 test cases covering:
Note: Some formats from t0006 are not yet supported by gix-date (compact ISO8601 like |
|
Copilot Fix the tests, see CI. |
Regenerated the tar archive properly in commit 3880df5. The issue was that the archive needed to be regenerated with |
| # FIXED DATE FORMATS | ||
| # ============================================================================ | ||
| # Tests from https://github.com/git/git/blob/master/t/t0006-date.sh | ||
| # Only including formats that gix-date currently supports. |
There was a problem hiding this comment.
Copilot And now add all formats that gix-date doesn't support. Then implement what's missing.
There was a problem hiding this comment.
Implemented all previously unsupported Git date formats in commit c6cb05e:
New formats supported:
- ISO8601 with dots:
2008.02.14 20:30:45 -0500 - Compact ISO8601:
20080214T203045,20080214T20:30:45,20080214T2030,20080214T20 - Z suffix for UTC:
1970-01-01 00:00:00 Z - 2-digit hour offset:
2008-02-14 20:30:45 -05 - Colon-separated offset:
2008-02-14 20:30:45 -05:00 - Subsecond precision (ignored like Git):
20080214T203045.019-04:00 - Datetime without offset (defaults to UTC):
1979-02-26 18:30:00
Baseline now includes 84 test cases, all passing.
|
Copilot Fix lints (probably clippy) and run the fuzzer with |
Fixed in commit e7ed184: Clippy fixes:
Fuzz-discovered panics fixed:
Ran fuzzer for ~20 seconds with 588k runs and no crashes found. |
|
Copilot fix CI please. |
Fixed formatting issues in commit ee3923f (trailing whitespace and multiline condition). The lint issue is now resolved. Investigating the ARM32 test failure - the archive identity (815164902-unix) matches the current script, so the archive should be extracted correctly. The test passes on all other platforms.
Fixed the formatting issues in commit ee3923f. The CI runs I saw were based on an older commit (e7ed184) - the latest commit already has the fixes applied. All 32 gix-date tests and cargo fmt checks pass locally. |
|
Copilot one of the CI test fails, while others work. Could this be raciness somewhere? Take a look at the CI job summary for an overview. Here is the excerpt of the error itself for convenience. |
Fixed in commit fd1e808. The issue was that compact ISO8601 formats like Removed the problematic formats:
Kept the well-supported compact formats that work consistently across platforms. |
Added comprehensive unit tests in commit c3d77d9 covering: Compact ISO8601 formats (11 tests):
ISO8601 with dots: Flexible timezone offsets (4 tests):
Subsecond precision: All 48 tests pass. |
Now it should be mostly en-par with Git. Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
Follow-ups
|
c3d77d9 to
0cd1241
Compare
0cd1241 to
7763542
Compare
There was a problem hiding this comment.
Pull request overview
This PR significantly expands Git date format support in gix-date by adding comprehensive baseline tests (75 test cases) and implementing parsing for all Git date formats from the official Git test suite (t0006-date.sh). The implementation adds support for ISO8601 variants, compact formats, flexible timezone offsets, subsecond precision (ignored like Git), and relative dates with reproducible testing via a fixed timestamp.
Key Changes
- Expanded baseline test coverage: Baseline tests now cover RFC2822, ISO8601 (multiple variants), compact ISO8601, flexible timezone formats, UNIX timestamps, RAW format, and relative dates
- Relative date testing: Introduced
GIT_TEST_DATE_NOW=1000000000to pin Git's "now" for reproducible relative date tests - New parsing functions: Added
parse_git_date_format(),parse_iso8601_dots(),parse_compact_iso8601(),parse_flexible_iso8601(),parse_time_component(), andparse_flexible_offset()to handle Git-specific date formats
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| gix-date/tests/time/parse/relative.rs | New test file for relative date parsing with comprehensive test cases covering seconds to years |
| gix-date/tests/time/parse/mod.rs | Refactored from parse.rs; adds tests for datetime without offset defaulting to UTC |
| gix-date/tests/time/parse/flexible_offset.rs | New tests for Z suffix, 2-digit hour offsets, colon-separated offsets, and 15-minute offsets |
| gix-date/tests/time/parse/compact_iso8601.rs | New tests for compact ISO8601 formats (YYYYMMDDTHHMMSS variants) with 11 test cases |
| gix-date/tests/time/baseline.rs | Added is_relative_date() and fixed_now() helpers for relative date testing; added SHORT format support |
| gix-date/tests/fixtures/generated-archives/generate_git_date_baseline.tar | Binary baseline data generated from the script |
| gix-date/tests/fixtures/generate_git_date_baseline.sh | Expanded from ~10 to 75 test cases; added baseline_relative() function with detailed documentation |
| gix-date/src/parse/relative.rs | Extracted from parse.rs into dedicated module; unchanged logic |
| gix-date/src/parse/raw.rs | Extracted strict raw format parsing into dedicated module with comprehensive tests |
| gix-date/src/parse/mod.rs | Refactored to module structure; exports Error, TimeBuf, and function submodule |
| gix-date/src/parse/git.rs | New file implementing Git-specific date format parsing (dots, compact ISO8601, flexible timezones) |
| gix-date/src/parse/function.rs | Extracted from parse.rs; main parse logic updated to call new parse_git_date_format() |
7763542 to
fad8219
Compare
Expands baseline tests to 75 test cases and implements parsing support for all Git date formats from the official t0006-date.sh test suite.
Baseline Test Coverage
Fixed Date Formats
Thu, 18 Aug 2022 12:45:06 +0800,Thu, 7 Apr 2005 15:14:13 -0700Thu, 1 Aug 2022 12:45:06 +08002022-08-17 22:04:58 +0200,2008-02-14 20:30:45 -05002008.02.14 20:30:45 -05002022-08-17T21:43:13+08:00,2016-06-15T16:13:20+02:0020080214T203045,20080214T20:30:45,20080214T203045-04:001970-01-01 00:00:00 Z-05,-05:00,+0020080214T203045.019-04:00Wed Jun 15 16:13:20 2016 +02001660874655 +0800,1466000000 -0200Relative Date Testing
Uses
GIT_TEST_DATE_NOW=1000000000to pin Git's "now" for reproducible baseline comparison:Implementation Changes
Added new parsing functions in
gix-date/src/parse.rs:parse_git_date_format()- main entry point for flexible Git date parsingparse_iso8601_dots()- handlesYYYY.MM.DD HH:MM:SS offsetparse_compact_iso8601()- handles compact formats likeYYYYMMDDTHHMMSSparse_flexible_iso8601()- handles ISO8601 with Z suffix and flexible offsetsparse_time_component()- parses time in various formats (HH:MM:SS, HHMMSS, HH:MM, HHMM, HH)parse_flexible_offset()- parses timezone offsets (Z, +/-HH, +/-HHMM, +/-HH:MM)Unit Tests
Added comprehensive unit tests in
gix-date/tests/time/parse.rsfor all supported date formats:2008.02.14 20:30:45 -0500-05), colon-separated (-05:00), 15-minute offset2008-02-14 20:30:45.019-04:00Note: Some compact ISO8601 formats (
20080214T2030,20080214T20) are supported by gix-date but excluded from baseline tests because they aren't universally parsed by all Git versions.Documented Limitations
--type=expiry-dateN unit agopatterns tested (notyesterday,last week, etc.)Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.