Skip to content

discard defaulted, old timestamps when validating#1027

Merged
trunk-io[bot] merged 3 commits intomainfrom
dylan/improve-old-timestamp-checking
Feb 5, 2026
Merged

discard defaulted, old timestamps when validating#1027
trunk-io[bot] merged 3 commits intomainfrom
dylan/improve-old-timestamp-checking

Conversation

@dfrankland
Copy link
Member

@trunk-io
Copy link

trunk-io bot commented Feb 4, 2026

😎 Merged successfully - details.

@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.72%. Comparing base (72aad86) to head (c275be6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1027      +/-   ##
==========================================
+ Coverage   81.40%   81.72%   +0.32%     
==========================================
  Files          69       69              
  Lines       14527    14537      +10     
==========================================
+ Hits        11825    11880      +55     
+ Misses       2702     2657      -45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dfrankland dfrankland marked this pull request as ready for review February 4, 2026 22:53
Comment on lines +348 to 358
let two_days_ago = Utc::now()
.checked_sub_days(Days::new(2))
.unwrap()
.timestamp();
let test_started_at = Timestamp {
seconds: 1000,
seconds: two_days_ago,
nanos: 0,
};
let test_finished_at = Timestamp {
seconds: 2000,
seconds: two_days_ago + 1000,
nanos: 0,
Copy link
Member Author

Choose a reason for hiding this comment

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

These were basically set to 1970-01-01, so I've updated them to be old, but not invalid and discarded

Comment on lines +25 to +29
/// Don't even consider timestamps older than this reference date time delta when validating
/// timestamps. These timestamps are considered to be defaulted by the test runner, test reporter,
/// or test suite, so they are unactionable and should be ignored.
pub const DISCARD_DEFAULTED_TIMESTAMP_OLDER_THAN_REFERENCE_TIMESTAMP: TimeDelta =
TimeDelta::days(30);
Copy link
Member Author

Choose a reason for hiding this comment

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

Anything older than 30 days is probably a mistake, not just something that's being uploaded a bit late

Comment on lines -744 to +752
let mut issues: Vec<JunitTestCaseValidationIssueSubOptimal> = Vec::new();
let timestamp_with_fallbacks = [test_case_timestamp, test_suite_timestamp, report_timestamp]
.iter()
.find_map(|ts| ts.discard_defaulted_timestamp(reference_timestamp));
Copy link
Member Author

Choose a reason for hiding this comment

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

I updated this function to be a little simpler utilizing some language features in Rust edition 2024.

calling discard_defaulted_timestamp is the only material change

Comment on lines +827 to +842
trait DiscardDefaultedTimestamp<T: Into<DateTime<FixedOffset>>> {
fn discard_defaulted_timestamp(self, reference_timestamp: T) -> Self
where
Self: marker::Sized;
}

impl DiscardDefaultedTimestamp<DateTime<FixedOffset>> for Option<DateTime<FixedOffset>> {
fn discard_defaulted_timestamp(self, reference_timestamp: DateTime<FixedOffset>) -> Self {
self.filter(|timestamp| {
*timestamp
> reference_timestamp
.checked_sub_signed(DISCARD_DEFAULTED_TIMESTAMP_OLDER_THAN_REFERENCE_TIMESTAMP)
.unwrap_or_default()
})
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Here's what helps do the check for whether the timestamp should be discarded

Comment on lines 355 to 381
@@ -344,10 +362,24 @@ fn validate_timestamps() {
JunitValidationIssueType::Report(JunitReportValidationIssue::SubOptimal(
JunitReportValidationIssueSubOptimal::FutureTimestamps,
)),
],
"failed to validate with seed `{}`",
seed,
);
];
// discarded timestamps have fallbacks, so timestamps are only reported missing if there's
// other non-discarded timestamps present
if generated_report_index > 1 {
expected_issues.push(JunitValidationIssueType::Report(
JunitReportValidationIssue::SubOptimal(
JunitReportValidationIssueSubOptimal::MissingTimestamps,
),
));
}

pretty_assertions::assert_eq!(
report_validation.all_issues(),
expected_issues,
"failed to validate with seed `{}`",
seed,
);
Copy link
Member Author

Choose a reason for hiding this comment

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

This checks that the old behavior is preserved and that invalid test case timestamps are only reported when all timestamps are either missing or invalid.

@trunk-staging-io
Copy link

trunk-staging-io bot commented Feb 4, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@trunk-io
Copy link

trunk-io bot commented Feb 5, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@trunk-io trunk-io bot merged commit bfa1f7a into main Feb 5, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants