diff options
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/Rakefile | 27 | ||||
-rw-r--r-- | actionview/test/ujs/server.rb | 1 |
2 files changed, 25 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 diff --git a/actionview/test/ujs/server.rb b/actionview/test/ujs/server.rb index 56f436c8b8..d7a6271587 100644 --- a/actionview/test/ujs/server.rb +++ b/actionview/test/ujs/server.rb @@ -23,6 +23,7 @@ module UJS config.public_file_server.enabled = true config.logger = Logger.new(STDOUT) config.log_level = :error + config.hosts << proc { true } config.content_security_policy do |policy| policy.default_src :self, :https |