Files
gollum/test/helper.rb
T
benjamin wil 9c574fd760 Improve test suite and CI run performance (#1796)
* Simplify test

I came across this test because it was failing JRuby CI runs. I should
emphasize, though, that this test was only failing due do an upstream
bug in Nokogiri v1.12.5.

When I was reviewing the test, to understand why it was failing at all,
I noticed that the assertion was rather obfuscated.  Specifically, we
were post-processing the entire `response.body` and using that as an
expectation.

* Use an older version of Nokogiri in our test env

This is a temporary fix. See the commit diff for more information.

* Split JRuby CI runs from MRI CI runs

We can improve the performance of our MRI test runs by not installing
Java as part of their run. (Java is only required for JRuby.)

* Use latest Ruby patch versions during CI runs

* Simplify GitHub Action workflow steps

Judging by the output in the GitHub Actions workflow UI, the `echo`
steps were not providing much value to us.

We can get rid of them to slightly increase run performance.

I've also named the other steps to make it easier to skim the Actions
workflow output.

* Remove `twitter_cldr` development dependency

This is no longer being used.

* Change GitHub Actions workflow Ruby matrix

We can drop Ruby 2.4 from our test run matrix. It is beyond EOL.
Let's add 2.7 instead.
2021-12-30 14:21:23 -08:00

97 lines
2.1 KiB
Ruby

require 'rubygems'
require 'rack/test'
require 'test/unit'
require 'shoulda'
require 'mocha/setup'
require 'fileutils'
require 'minitest/reporters'
require 'minitest/spec'
require 'tmpdir'
# Silence locale validation warning
require 'i18n'
I18n.enforce_available_locales = false
MiniTest::Reporters.use!
dir = File.dirname(File.expand_path(__FILE__))
$LOAD_PATH.unshift(File.join(dir, '..', 'lib'))
$LOAD_PATH.unshift(dir)
module Gollum
end
if ENV['GIT_ADAPTER']
Gollum::GIT_ADAPTER = ENV['GIT_ADAPTER']
else
Gollum::GIT_ADAPTER = RUBY_PLATFORM == 'java' ? 'rjgit' : 'rugged'
end
ENV['RACK_ENV'] = 'test'
require 'gollum'
require 'gollum/app'
# Disable the metadata feature
$METADATA = false
# Make sure we're in the test dir, the tests expect that to be the current
# directory.
TEST_DIR = File.join(File.dirname(__FILE__), *%w[.])
def testpath(path)
File.join(TEST_DIR, path)
end
def cloned_testpath(path, bare = false)
repo = File.expand_path(testpath(path))
tmpdir = Dir.mktmpdir(self.class.name)
bare = bare ? "--bare" : ""
redirect = Gem.win_platform? ? '' : '2>/dev/null'
%x{git clone #{bare} '#{repo}' #{tmpdir} #{redirect}}
tmpdir
end
def commit_details
{ :message => "Did something at #{Time.now}",
:name => "Tom Preston-Werner",
:email => "tom@github.com" }
end
def normal(text)
text.gsub!(' ', '')
text.gsub!("\n", '')
text
end
# test/spec/mini 3
# http://gist.github.com/25455
# chris@ozmm.org
# file:lib/test/spec/mini.rb
def context(*args, &block)
return super unless (name = args.first) && block
require 'test/unit'
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
def self.test(name, &block)
define_method("test_#{name.gsub(/\W/, '_')}", &block) if block
end
def self.xtest(*args)
end
def self.setup(&block)
define_method(:setup, &block)
end
def self.teardown(&block)
define_method(:teardown, &block)
end
end
(
class << klass;
self
end).send(:define_method, :name) { name.gsub(/\W/, '_') }
$contexts << klass
klass.class_eval &block
end
$contexts = []