From 1511f332b6c10b8e8a4823be3f9602559cde4e7b Mon Sep 17 00:00:00 2001 From: Phil Ross Date: Tue, 16 Nov 2021 19:51:04 +0000 Subject: [PATCH] Fix random test failures in TestExcerpt #to_liquid. 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"]. --- test/test_filters.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/test_filters.rb b/test/test_filters.rb index 2bb68408880..1ebc360b029 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -37,6 +37,7 @@ def select; end context "filters" do setup do @sample_time = Time.utc(2013, 3, 27, 11, 22, 33) + @timezone_before_test = ENV["TZ"] @filter = make_filter_mock( "timezone" => "UTC", "url" => "http://example.com", @@ -55,6 +56,10 @@ def select; end ] end + teardown do + ENV["TZ"] = @timezone_before_test + end + should "markdownify with simple string" do assert_equal( "

something really simple

\n",