DEV: Allow Ember CLI for `rake qunit:test` and `rake plugin:qunit`
To use Ember CLI, set QUNIT_EMBER_CLI=1
This commit is contained in:
parent
3e3043dbaa
commit
89994cff40
|
@ -42,7 +42,7 @@ end
|
||||||
# in development do some fussing around, to automate config
|
# in development do some fussing around, to automate config
|
||||||
if !ARGV.include?("-E") &&
|
if !ARGV.include?("-E") &&
|
||||||
!ARGV.include?("--env") &&
|
!ARGV.include?("--env") &&
|
||||||
(ENV["RAILS_ENV"] == "development" || !ENV["RAILS_ENV"])
|
(["development", "test"].include?(ENV["RAILS_ENV"]) || !ENV["RAILS_ENV"])
|
||||||
|
|
||||||
dev_mode = true
|
dev_mode = true
|
||||||
|
|
||||||
|
|
|
@ -29,32 +29,52 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
port = ENV['TEST_SERVER_PORT'] || 60099
|
ember_cli = ENV['QUNIT_EMBER_CLI'] == "1"
|
||||||
|
|
||||||
|
port = ENV['TEST_SERVER_PORT'] || 60099
|
||||||
while !port_available? port
|
while !port_available? port
|
||||||
port += 1
|
port += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if ember_cli
|
||||||
|
unicorn_port = 60098
|
||||||
|
while unicorn_port == port || !port_available?(unicorn_port)
|
||||||
|
unicorn_port += 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
unicorn_port = port
|
||||||
|
end
|
||||||
|
|
||||||
|
env = {
|
||||||
|
"RAILS_ENV" => ENV["QUNIT_RAILS_ENV"] || "test",
|
||||||
|
"SKIP_ENFORCE_HOSTNAME" => "1",
|
||||||
|
"UNICORN_PID_PATH" => "#{Rails.root}/tmp/pids/unicorn_test_#{unicorn_port}.pid", # So this can run alongside development
|
||||||
|
"UNICORN_PORT" => unicorn_port.to_s,
|
||||||
|
"UNICORN_SIDEKIQS" => "0",
|
||||||
|
"DISCOURSE_SKIP_CSS_WATCHER" => "1",
|
||||||
|
"UNICORN_LISTENER" => "127.0.0.1:#{unicorn_port}",
|
||||||
|
"LOGSTASH_UNICORN_URI" => nil,
|
||||||
|
"UNICORN_WORKERS" => "3"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = if ember_cli
|
||||||
|
"#{Rails.root}/bin/ember-cli -u --port #{port} --proxy http://localhost:#{unicorn_port} -lr false"
|
||||||
|
else
|
||||||
|
"#{Rails.root}/bin/unicorn"
|
||||||
|
end
|
||||||
|
|
||||||
pid = Process.spawn(
|
pid = Process.spawn(
|
||||||
{
|
env,
|
||||||
"RAILS_ENV" => ENV["QUNIT_RAILS_ENV"] || "test",
|
cmd,
|
||||||
"SKIP_ENFORCE_HOSTNAME" => "1",
|
|
||||||
"UNICORN_PID_PATH" => "#{Rails.root}/tmp/pids/unicorn_test_#{port}.pid", # So this can run alongside development
|
|
||||||
"UNICORN_PORT" => port.to_s,
|
|
||||||
"UNICORN_SIDEKIQS" => "0",
|
|
||||||
"DISCOURSE_SKIP_CSS_WATCHER" => "1",
|
|
||||||
"UNICORN_LISTENER" => "127.0.0.1:#{port}",
|
|
||||||
"LOGSTASH_UNICORN_URI" => nil,
|
|
||||||
"UNICORN_WORKERS" => "3"
|
|
||||||
},
|
|
||||||
"#{Rails.root}/bin/unicorn -c config/unicorn.conf.rb",
|
|
||||||
pgroup: true
|
pgroup: true
|
||||||
)
|
)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
success = true
|
success = true
|
||||||
test_path = "#{Rails.root}/test"
|
test_path = "#{Rails.root}/test"
|
||||||
qunit_path = args[:qunit_path] || "/qunit"
|
qunit_path = args[:qunit_path]
|
||||||
|
qunit_path ||= "/tests" if ember_cli
|
||||||
|
qunit_path ||= "/qunit"
|
||||||
cmd = "node #{test_path}/run-qunit.js http://localhost:#{port}#{qunit_path}"
|
cmd = "node #{test_path}/run-qunit.js http://localhost:#{port}#{qunit_path}"
|
||||||
options = { seed: (ENV["QUNIT_SEED"] || Random.new.seed), hidepassed: 1 }
|
options = { seed: (ENV["QUNIT_SEED"] || Random.new.seed), hidepassed: 1 }
|
||||||
|
|
||||||
|
@ -79,7 +99,7 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
||||||
|
|
||||||
# wait for server to accept connections
|
# wait for server to accept connections
|
||||||
require 'net/http'
|
require 'net/http'
|
||||||
uri = URI("http://localhost:#{port}/assets/test_helper.js")
|
uri = URI("http://localhost:#{port}/#{qunit_path}")
|
||||||
puts "Warming up Rails server"
|
puts "Warming up Rails server"
|
||||||
begin
|
begin
|
||||||
Net::HTTP.get(uri)
|
Net::HTTP.get(uri)
|
||||||
|
@ -96,7 +116,7 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
||||||
ensure
|
ensure
|
||||||
# was having issues with HUP
|
# was having issues with HUP
|
||||||
Process.kill "-KILL", pid
|
Process.kill "-KILL", pid
|
||||||
FileUtils.rm("#{Rails.root}/tmp/pids/unicorn_test_#{port}.pid")
|
FileUtils.rm("#{Rails.root}/tmp/pids/unicorn_test_#{unicorn_port}.pid")
|
||||||
end
|
end
|
||||||
|
|
||||||
if success
|
if success
|
||||||
|
|
Loading…
Reference in New Issue