diff options
Diffstat (limited to 'ci')
-rw-r--r-- | ci/qunit-selenium-runner.rb | 15 | ||||
-rwxr-xr-x | ci/travis.rb | 104 |
2 files changed, 75 insertions, 44 deletions
diff --git a/ci/qunit-selenium-runner.rb b/ci/qunit-selenium-runner.rb new file mode 100644 index 0000000000..3a58377d77 --- /dev/null +++ b/ci/qunit-selenium-runner.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "qunit/selenium/test_runner" +require "chromedriver/helper" + +driver_options = Selenium::WebDriver::Chrome::Options.new +driver_options.add_argument("--headless") +driver_options.add_argument("--disable-gpu") + +driver = ::Selenium::WebDriver.for(:chrome, options: driver_options) +result = QUnit::Selenium::TestRunner.new(driver).open(ARGV[0], timeout: 60) +driver.quit + +puts "Time: #{result.duration} seconds, Total: #{result.assertions[:total]}, Passed: #{result.assertions[:passed]}, Failed: #{result.assertions[:failed]}" +exit(result.tests[:failed] > 0 ? 1 : 0) diff --git a/ci/travis.rb b/ci/travis.rb index 063c6acb07..b124358789 100755 --- a/ci/travis.rb +++ b/ci/travis.rb @@ -1,8 +1,14 @@ #!/usr/bin/env ruby -require 'fileutils' +# frozen_string_literal: true + +require "fileutils" include FileUtils commands = [ + 'mysql -e "create user rails@localhost;"', + 'mysql -e "grant all privileges on activerecord_unittest.* to rails@localhost;"', + 'mysql -e "grant all privileges on activerecord_unittest2.* to rails@localhost;"', + 'mysql -e "grant all privileges on inexistent_activerecord_unittest.* to rails@localhost;"', 'mysql -e "create database activerecord_unittest;"', 'mysql -e "create database activerecord_unittest2;"', 'psql -c "create database activerecord_unittest;" -U postgres', @@ -10,21 +16,22 @@ commands = [ ] commands.each do |command| - system("#{command} > /dev/null 2>&1") + system(command, [1, 2] => File::NULL) end class Build MAP = { - 'railties' => 'railties', - 'ap' => 'actionpack', - 'am' => 'actionmailer', - 'amo' => 'activemodel', - 'as' => 'activesupport', - 'ar' => 'activerecord', - 'av' => 'actionview', - 'aj' => 'activejob', - 'ac' => 'actioncable', - 'guides' => 'guides' + "railties" => "railties", + "ap" => "actionpack", + "am" => "actionmailer", + "amo" => "activemodel", + "as" => "activesupport", + "ar" => "activerecord", + "av" => "actionview", + "aj" => "activejob", + "ac" => "actioncable", + "ast" => "activestorage", + "guides" => "guides" } attr_reader :component, :options @@ -36,8 +43,10 @@ class Build def run!(options = {}) self.options.update(options) + Dir.chdir(dir) do announce(heading) + if guides? run_bug_report_templates else @@ -55,41 +64,45 @@ class Build heading << "with #{adapter}" if activerecord? heading << "in isolation" if isolated? heading << "integration" if integration? - heading.join(' ') + heading.join(" ") end def tasks if activerecord? tasks = ["#{adapter}:#{'isolated_' if isolated?}test"] case adapter - when 'mysql2' - tasks.unshift 'db:mysql:rebuild' - when 'postgresql' - tasks.unshift 'db:postgresql:rebuild' + when "mysql2" + tasks.unshift "db:mysql:rebuild" + when "postgresql" + tasks.unshift "db:postgresql:rebuild" end tasks else - ["test", ('isolated' if isolated?), ('integration' if integration?)].compact.join(":") + ["test", ("isolated" if isolated?), ("integration" if integration?), ("ujs" if ujs?)].compact.join(":") end end def key key = [gem] key << adapter if activerecord? - key << 'isolated' if isolated? - key.join(':') + key << "isolated" if isolated? + key.join(":") end def activesupport? - gem == 'activesupport' + gem == "activesupport" end def activerecord? - gem == 'activerecord' + gem == "activerecord" end def guides? - gem == 'guides' + gem == "guides" + end + + def ujs? + component.split(":").last == "ujs" end def isolated? @@ -97,16 +110,16 @@ class Build end def integration? - component.split(':').last == 'integration' + component.split(":").last == "integration" end def gem - MAP[component.split(':').first] + MAP[component.split(":").first] end alias :dir :gem def adapter - component.split(':').last + component.split(":").last end def rake(*tasks) @@ -120,40 +133,43 @@ class Build def env if activesupport? && !isolated? - # There is a known issue with the listen tests that casuses files to be - # incorrectly GC'ed even when they are still in-use. The current is to - # only run them in isolation to avoid randomly failing our test suite. - { 'LISTEN' => '0' } + # There is a known issue with the listen tests that causes files to be + # incorrectly GC'ed even when they are still in-use. The current solution + # is to only run them in isolation to avoid randomly failing our test suite. + { "LISTEN" => "0" } else {} end end def run_bug_report_templates - Dir.glob('bug_report_templates/*.rb').all? do |file| - system(Gem.ruby, '-w', file) + Dir.glob("bug_report_templates/*.rb").all? do |file| + system(Gem.ruby, "-w", file) end end end -if ENV['GEM']=='aj:integration' - ENV['QC_DATABASE_URL'] = 'postgres://postgres@localhost/active_jobs_qc_int_test' - ENV['QUE_DATABASE_URL'] = 'postgres://postgres@localhost/active_jobs_que_int_test' +if ENV["GEM"] == "aj:integration" + ENV["QC_DATABASE_URL"] = "postgres://postgres@localhost/active_jobs_qc_int_test" + ENV["QUE_DATABASE_URL"] = "postgres://postgres@localhost/active_jobs_que_int_test" end results = {} -ENV['GEM'].split(',').each do |gem| +ENV["GEM"].split(",").each do |gem| [false, true].each do |isolated| - next if ENV['TRAVIS_PULL_REQUEST'] && ENV['TRAVIS_PULL_REQUEST'] != 'false' && isolated - next if gem == 'railties' && isolated - next if gem == 'ac' && isolated - next if gem == 'aj:integration' && isolated - next if gem == 'guides' && isolated - - build = Build.new(gem, :isolated => isolated) + next if ENV["TRAVIS_PULL_REQUEST"] && ENV["TRAVIS_PULL_REQUEST"] != "false" && isolated + next if RUBY_VERSION < "2.4" && isolated + next if gem == "railties" && isolated + next if gem == "ac" && isolated + next if gem == "ac:integration" && isolated + next if gem == "aj:integration" && isolated + next if gem == "guides" && isolated + next if gem == "av:ujs" && isolated + next if gem == "ast" && isolated + + build = Build.new(gem, isolated: isolated) results[build.key] = build.run! - end end |