From b7b59fa67db9c8c6a2b5ccc6939be388e40e364a Mon Sep 17 00:00:00 2001 From: Jared White Date: Sat, 16 Mar 2024 21:03:15 -0700 Subject: [PATCH] test: address suite flakiness --- bridgetown-core/script/test | 2 +- bridgetown-core/test/helper.rb | 12 ++++++++++++ bridgetown-core/test/test_locales.rb | 12 ------------ bridgetown-core/test/test_ruby_helpers.rb | 1 + 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/bridgetown-core/script/test b/bridgetown-core/script/test index dd62ebb11..d8a4466c0 100755 --- a/bridgetown-core/script/test +++ b/bridgetown-core/script/test @@ -16,7 +16,7 @@ then set -x ruby -S bundle exec ruby -I test \ "test/test_resource.rb" - time BYPASS_RESOURCE_TEST=true SEED=5678 ruby -S bundle exec \ + time BYPASS_RESOURCE_TEST=true SEED=1 ruby -S bundle exec \ rake TESTOPTS=$testopts test else set -x diff --git a/bridgetown-core/test/helper.rb b/bridgetown-core/test/helper.rb index d6974bb04..68a783ed3 100644 --- a/bridgetown-core/test/helper.rb +++ b/bridgetown-core/test/helper.rb @@ -206,6 +206,18 @@ def symlink_if_allowed(target, sym_file) rescue NotImplementedError => e skip e.to_s.magenta end + + def reset_i18n_config + I18n.enforce_available_locales = false + I18n.locale = nil + I18n.default_locale = nil + I18n.load_path = Gem.find_files_from_load_path("active_support/locale/en.*") # restore basic translations + I18n.available_locales = nil + I18n.backend = nil + I18n.default_separator = nil + I18n.enforce_available_locales = true + I18n.fallbacks = nil if I18n.respond_to?(:fallbacks=) + end end class FakeLogger diff --git a/bridgetown-core/test/test_locales.rb b/bridgetown-core/test/test_locales.rb index c4a52aace..76b7ffa1d 100644 --- a/bridgetown-core/test/test_locales.rb +++ b/bridgetown-core/test/test_locales.rb @@ -3,18 +3,6 @@ require "helper" class TestLocales < BridgetownUnitTest - def reset_i18n_config - I18n.enforce_available_locales = false - I18n.locale = nil - I18n.default_locale = nil - I18n.load_path = nil - I18n.available_locales = nil - I18n.backend = nil - I18n.default_separator = nil - I18n.enforce_available_locales = true - I18n.fallbacks = nil if I18n.respond_to?(:fallbacks=) - end - context "similar pages in different locales as specified in filename" do setup do reset_i18n_config diff --git a/bridgetown-core/test/test_ruby_helpers.rb b/bridgetown-core/test/test_ruby_helpers.rb index 0973d2ff7..4ca4e6c91 100644 --- a/bridgetown-core/test/test_ruby_helpers.rb +++ b/bridgetown-core/test/test_ruby_helpers.rb @@ -4,6 +4,7 @@ class TestRubyHelpers < BridgetownUnitTest def setup + reset_i18n_config @site = fixture_site @site.read @helpers = Bridgetown::RubyTemplateView::Helpers.new(