diff options
author | Matthew Draper <matthew@trebex.net> | 2019-02-06 01:20:06 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2019-02-06 01:20:06 +1030 |
commit | 287920ca7d06c8f51198ec750d65ba703835b257 (patch) | |
tree | fa38811f965fa873d02bc7df3317583ada076ff1 /actionview/Rakefile | |
parent | 44232b485485634d681c60868c619323f882e59f (diff) | |
download | rails-287920ca7d06c8f51198ec750d65ba703835b257.tar.gz rails-287920ca7d06c8f51198ec750d65ba703835b257.tar.bz2 rails-287920ca7d06c8f51198ec750d65ba703835b257.zip |
Respect ENV variables when finding DBs etc for the test suite
If they're not set we'll still fall back to localhost, but this makes it
possible to run the tests against a remote Postgres / Redis / whatever.
Diffstat (limited to 'actionview/Rakefile')
-rw-r--r-- | actionview/Rakefile | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/actionview/Rakefile b/actionview/Rakefile index 7851a2b6bf..237e458b6f 100644 --- a/actionview/Rakefile +++ b/actionview/Rakefile @@ -31,9 +31,26 @@ namespace :test do desc "Run tests for rails-ujs" task :ujs do + system("npm run lint") + exit $?.exitstatus unless $?.success? + begin + listen_host = "localhost" + listen_port = "4567" + + runner_command = %w(ruby ../ci/qunit-selenium-runner.rb) + if ENV["SELENIUM_DRIVER_URL"] + require "socket" + runner_command += %W(http://#{Socket.gethostname}:#{listen_port}/ #{ENV["SELENIUM_DRIVER_URL"]}) + listen_host = "0.0.0.0" + else + runner_command += %W(http://localhost:#{listen_port}/) + end + Dir.mkdir("log") - pid = spawn("bundle exec rackup test/ujs/config.ru -p 4567 -s puma > log/test.log 2>&1", pgroup: true) + pid = File.open("log/test.log", "w") do |f| + spawn(*%W(rackup test/ujs/config.ru -o #{listen_host} -p #{listen_port} -s puma), out: f, err: f, pgroup: true) + end start_time = Time.now @@ -41,12 +58,16 @@ namespace :test do break if system("lsof -i :4567", 1 => File::NULL) if Time.now - start_time > 5 - puts "Timed out after 5 seconds" + puts "Failed to start puma after 5 seconds" + puts + puts File.read("log/test.log") exit 1 end + + sleep 0.2 end - system("npm run lint && bundle exec ruby ../ci/qunit-selenium-runner.rb http://localhost:4567/") + system(*runner_command) status = $?.exitstatus ensure Process.kill("KILL", -pid) if pid |