From dfc6bb402905320451cf1414d933e08a9a454180 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 6 Mar 2024 15:41:14 +0000 Subject: [PATCH] DEV: Remove direct minitest dependency to appease ruby-lsp (#26056) Having minitest as a direct dependency causes ruby-lsp to use it as our test runner (per https://github.com/Shopify/ruby-lsp/blob/d1da8858a1/lib/ruby_lsp/requests/support/dependency_detector.rb#L40-L55). This makes VSCode's test explorer incorrectly display Minitest 'run' buttons above all our tests. We were only using it in `emoji.rake`... and that wasn't even working with the latest version of Minitest. This commit refactors `emoji.rake` to work without minitest, and removes the dependency. --- Gemfile | 1 - Gemfile.lock | 1 - lib/tasks/emoji.rake | 25 ++++++++++++++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index f73aeecb6ba..a1d96e5bd27 100644 --- a/Gemfile +++ b/Gemfile @@ -125,7 +125,6 @@ group :test do gem "capybara", require: false gem "webmock", require: false gem "fakeweb", require: false - gem "minitest", require: false gem "simplecov", require: false gem "selenium-webdriver", "~> 4.14", require: false gem "selenium-devtools", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 8932f8bc6dc..c73e1f0cbb1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -602,7 +602,6 @@ DEPENDENCIES mini_sql mini_suffix minio_runner - minitest mocha multi_json mustache diff --git a/lib/tasks/emoji.rake b/lib/tasks/emoji.rake index b1a2868f61c..111c4070b28 100644 --- a/lib/tasks/emoji.rake +++ b/lib/tasks/emoji.rake @@ -475,12 +475,27 @@ def confirm_overwrite(path) STDIN.gets.chomp end -class TestEmojiUpdate < Minitest::Test +class TestEmojiUpdate def self.run_and_summarize - puts "Runnings tests..." - reporter = Minitest::SummaryReporter.new - TestEmojiUpdate.run(reporter) - puts reporter + puts "Running tests..." + instance = TestEmojiUpdate.new + instance.public_methods.each do |method| + next unless method.to_s.start_with? "test_" + print "Running #{method}..." + instance.public_send(method) + puts " ✅" + rescue StandardError => e + puts " ❌" + puts e.message.indent(2) + end + end + + def assert_equal(a, b) + raise "Expected #{a.inspect} to equal #{b.inspect}" if a != b + end + + def assert(a) + raise "Expected #{a.inspect} to be truthy" if !a end def image_path(style, name)