Skip to content

Fix random test failures in TestExcerpt #to_liquid#8884

Merged
jekyllbot merged 1 commit intojekyll:masterfrom
philr:fix_timezone_test_failure
Nov 17, 2021
Merged

Fix random test failures in TestExcerpt #to_liquid#8884
jekyllbot merged 1 commit intojekyll:masterfrom
philr:fix_timezone_test_failure

Conversation

@philr
Copy link
Copy Markdown
Contributor

@philr philr commented Nov 16, 2021

This is a 🐛 bug fix.

Summary

Failures can occur in the TestExcerpt #to_liquid test when the random seed orders TestFilters tests before TestExcerpt and the tests are run with a system time zone that's has a non-zero offset on 2013-07-22.

The TestFilters setup changes ENV["TZ"] to "UTC" but doesn't reset it.

The TestExcerpt #to_liquid test fails because @excerpt.to_liquid["date"] returns a UTC time and Time.parse("2013-07-22") returns a time in the system time zone:

Failure: TestExcerpt#test_: An extracted excerpt #to_liquid should contain the proper page data to mimic the post liquid.
[jekyll/test/test_excerpt.rb:103] Minitest::Assertion:
Expected: 2013-07-22 00:00:00 +0000
Actual: 2013-07-22 00:00:00 +0100

This pull request adds a teardown to TestFilters to reset ENV["TZ"].

Failures can occur when the random seed orders TestFilters tests before
TestExcerpt and the tests are run with a system time zone that's has a
non-zero offset on 2013-07-22.

The TestFilters setup changes ENV["TZ"] to "UTC" but doesn't reset it.

The TestExcerpt#to_liquid test fails because @excerpt.to_liquid["date"]
returns a UTC time and Time.parse("2013-07-22") returns a time in the
system time zone:

  Failure: TestExcerpt#test_: An extracted excerpt #to_liquid should
  contain the proper page data to mimic the post liquid.
  [jekyll/test/test_excerpt.rb:103] Minitest::Assertion:
  Expected: 2013-07-22 00:00:00 +0000
    Actual: 2013-07-22 00:00:00 +0100

Add a teardown to TestFilters to reset ENV["TZ"].
Copy link
Copy Markdown
Member

@mattr- mattr- left a comment

Choose a reason for hiding this comment

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

Great find! Thanks! ❤️

@ashmaroli
Copy link
Copy Markdown
Member

Thank you @philr
@jekyllbot: merge +dev

@jekyllbot jekyllbot merged commit 3a688fe into jekyll:master Nov 17, 2021
jekyllbot added a commit that referenced this pull request Nov 17, 2021
github-actions bot pushed a commit that referenced this pull request Nov 17, 2021
Phil Ross: Fix random test failures in TestExcerpt #to_liquid. (#8884)

Merge pull request 8884
@jekyll jekyll locked and limited conversation to collaborators Nov 17, 2022
@philr philr deleted the fix_timezone_test_failure branch December 31, 2025 16:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants