mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-04 15:13:41 +08:00
Pitchfork has been the default web server for some time now. This removes Unicorn entirely to simplify the codebase and unblock future improvements (like Rack 3). Notable changes beyond the straightforward removal: - `Discourse.after_unicorn_worker_fork` → `Discourse.apply_worker_db_variables_overrides`: renamed and wired into pitchfork.conf.rb's `after_worker_fork`. This actually *fixes* per-worker DB variable overrides (`unicorn_worker_db_variables_*`) which were never called under Pitchfork. - `bin/ember-cli`: `--unicorn` flag renamed to `--server` (`-u` kept). - `lib/demon/sidekiq.rb`: removed Unicorn-specific USR1/USR2 signal handlers and `reopen_logs` (called `Unicorn::Util.reopen_logs`), which were already dead code under Pitchfork. Intentionally kept unchanged: - `config/unicorn_launcher` (used by Docker images, separate effort) - `docker_manager` plugin (separate repo) - `UNICORN_*` env vars (renaming deferred) - Rack < 3 constraint (separate PR)
171 lines
4.3 KiB
Ruby
171 lines
4.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe "bin/qunit" do
|
|
def run(*args)
|
|
out, err, status = Open3.capture3("bin/qunit", "--dry-run", *args, chdir: Rails.root.to_s)
|
|
|
|
parsed_args, parsed_env =
|
|
if parsed_result = out.match(/Executing: (?<args>\[.+?\])\nwith env: (?<env>\{.+?\})/m)
|
|
[JSON.parse(parsed_result[:args]), JSON.parse(parsed_result[:env])]
|
|
end
|
|
|
|
OpenStruct.new(
|
|
out: out,
|
|
err: err,
|
|
status: status.exitstatus,
|
|
args: parsed_args,
|
|
env: parsed_env,
|
|
launched_server: out.include?("[dry-run] skipping server startup"),
|
|
)
|
|
end
|
|
|
|
let(:core_test_file) do
|
|
Dir.glob("#{Rails.root}/frontend/discourse/tests/integration/**/*-test.js").first
|
|
end
|
|
|
|
let(:chat_test_file) { Dir.glob("#{Rails.root}/plugins/chat/test/**/*-test.js").first }
|
|
|
|
it "runs all core tests by default" do
|
|
result = run
|
|
expect(result.status).to eq(0)
|
|
expect(result.launched_server).to eq(false)
|
|
|
|
expect(result.args).to match(
|
|
[
|
|
"pnpm",
|
|
"ember",
|
|
"exam",
|
|
"--query",
|
|
"target=core",
|
|
"--random",
|
|
a_string_matching(/\A[a-zA-Z0-9]{8}\z/),
|
|
"--path",
|
|
"dist",
|
|
],
|
|
)
|
|
expect(result.env).to match(
|
|
"UNICORN_PORT" => a_truthy_value,
|
|
"TESTEM_DEFAULT_BROWSER" => a_truthy_value,
|
|
"LOAD_PLUGINS" => "0",
|
|
)
|
|
end
|
|
|
|
it "allows running specific file" do
|
|
result = run(core_test_file)
|
|
expect(result.status).to eq(0)
|
|
expect(result.launched_server).to eq(false)
|
|
|
|
expect(result.args).to match(
|
|
[
|
|
"pnpm",
|
|
"ember",
|
|
"exam",
|
|
"--query",
|
|
"target=core",
|
|
"--file-path",
|
|
core_test_file.sub("#{Rails.root}/frontend/discourse/", ""),
|
|
"--random",
|
|
a_string_matching(/\A[a-zA-Z0-9]{8}\z/),
|
|
"--path",
|
|
"dist",
|
|
],
|
|
)
|
|
expect(result.env).to match(
|
|
"UNICORN_PORT" => a_truthy_value,
|
|
"TESTEM_DEFAULT_BROWSER" => a_truthy_value,
|
|
"LOAD_PLUGINS" => "0",
|
|
)
|
|
end
|
|
|
|
it "allows running all plugin tests" do
|
|
result = run("--target", "plugins")
|
|
expect(result.status).to eq(0)
|
|
expect(result.launched_server).to eq(false)
|
|
|
|
expect(result.args).to match(
|
|
[
|
|
"pnpm",
|
|
"ember",
|
|
"exam",
|
|
"--random",
|
|
a_string_matching(/\A[a-zA-Z0-9]{8}\z/),
|
|
"--path",
|
|
"dist",
|
|
],
|
|
)
|
|
expect(result.env).to match(
|
|
"UNICORN_PORT" => a_truthy_value,
|
|
"TESTEM_DEFAULT_BROWSER" => a_truthy_value,
|
|
"LOAD_PLUGINS" => "1",
|
|
"PLUGIN_TARGETS" => a_string_matching(/,/),
|
|
)
|
|
end
|
|
|
|
it "allows running tests for multiple plugins" do
|
|
result = run("--target", "chat,discourse-local-dates")
|
|
expect(result.status).to eq(0)
|
|
expect(result.launched_server).to eq(false)
|
|
|
|
expect(result.args).to match(
|
|
[
|
|
"pnpm",
|
|
"ember",
|
|
"exam",
|
|
"--random",
|
|
a_string_matching(/\A[a-zA-Z0-9]{8}\z/),
|
|
"--path",
|
|
"dist",
|
|
],
|
|
)
|
|
expect(result.env).to match(
|
|
"UNICORN_PORT" => a_truthy_value,
|
|
"TESTEM_DEFAULT_BROWSER" => a_truthy_value,
|
|
"LOAD_PLUGINS" => "1",
|
|
"PLUGIN_TARGETS" => "chat,discourse-local-dates",
|
|
)
|
|
end
|
|
|
|
it "allows running specific plugin test file" do
|
|
result = run(chat_test_file)
|
|
expect(result.status).to eq(0)
|
|
expect(result.launched_server).to eq(false)
|
|
|
|
expect(result.args).to match(
|
|
[
|
|
"pnpm",
|
|
"ember",
|
|
"exam",
|
|
"--query",
|
|
"target=chat",
|
|
"--file-path",
|
|
chat_test_file.sub(
|
|
"#{Rails.root}/plugins/chat/test/javascripts/",
|
|
"discourse/plugins/chat/",
|
|
),
|
|
"--random",
|
|
a_string_matching(/\A[a-zA-Z0-9]{8}\z/),
|
|
"--path",
|
|
"dist",
|
|
],
|
|
)
|
|
expect(result.env).to match(
|
|
"UNICORN_PORT" => a_truthy_value,
|
|
"TESTEM_DEFAULT_BROWSER" => a_truthy_value,
|
|
"LOAD_PLUGINS" => "1",
|
|
)
|
|
end
|
|
|
|
it "prevents running files from multiple targets" do
|
|
result = run(core_test_file, chat_test_file)
|
|
expect(result.status).to eq(1)
|
|
expect(result.out).to include(
|
|
"Error: Cannot mix multiple plugin/core targets when running specific files",
|
|
)
|
|
end
|
|
|
|
it "launches server when using --standalone" do
|
|
result = run("--standalone")
|
|
expect(result.status).to eq(0)
|
|
expect(result.launched_server).to eq(true)
|
|
end
|
|
end
|