Skip to content

test: capture negative utimes mtime at call time#62490

Open
inoway46 wants to merge 1 commit intonodejs:mainfrom
inoway46:fix-flaky-fs-utimes
Open

test: capture negative utimes mtime at call time#62490
inoway46 wants to merge 1 commit intonodejs:mainfrom
inoway46:fix-flaky-fs-utimes

Conversation

@inoway46
Copy link
Copy Markdown
Contributor

@inoway46 inoway46 commented Mar 29, 2026

test-fs-utimes recalculates the expected mtime during assertion.

For negative numeric timestamps such as -1, Node normalizes the value to the current time at call time. Recomputing the expectation later can let it drift past the test's 2-second tolerance and cause a false failure.

This change captures the expected mtime immediately before each utimes/lutimes/futimes call and reuses it for the assertion.

Background: #62490 (comment)

Refs: #37692

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Mar 29, 2026
@inoway46
Copy link
Copy Markdown
Contributor Author

// Negative numeric timestamps are normalized to "now" at call time.
return fs._toUnixTimestamp(mtime);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This helper is optional and I can inline it if preferred.

I kept it as a helper because the key point is to capture the expected mtime at call time before each invocation, and I thought naming that step made the intent clearer.

@inoway46 inoway46 marked this pull request as ready for review March 29, 2026 07:25
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.71%. Comparing base (cc96741) to head (5246b06).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62490      +/-   ##
==========================================
- Coverage   91.55%   89.71%   -1.84%     
==========================================
  Files         351      692     +341     
  Lines      147653   213986   +66333     
  Branches    23224    41052   +17828     
==========================================
+ Hits       135179   191982   +56803     
- Misses      12217    14086    +1869     
- Partials      257     7918    +7661     

see 462 files with indirect coverage changes

🚀 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants