A platform for community discussion. Free, open, simple.
DEV: Correct `bin/qunit` random seed handling (#37087)
David Taylor8671593a9983
diff --git a/bin/qunit b/bin/qunitindex dcded9de67e..eedc118684e 100755--- a/bin/qunit+++ b/bin/qunit@@ -7,6 +7,7 @@ require "fileutils"require "socket"require "uri"require "net/http"+require "securerandom"require_relative "../lib/chrome_installed_checker"class QunitRunner@@ -260,6 +261,7 @@ class QunitRunnerargs += ["--filter", filter] if filterargs += ["--file-path", file_path_filter] if file_path_filterargs += ["--load-balance", "--parallel", parallel.to_s] if parallel+ args += ["--random", resolved_seed]args += %w[--path dist] if reuse_buildargs << "--write-execution-file" if ENV["QUNIT_WRITE_EXECUTION_FILE"]end@@ -496,7 +498,10 @@ class QunitRunnerdef build_queryparams = {}- params["seed"] = resolved_seed+ if @qunit_path+ # Only include seed manually if we're running without ember exam+ params["seed"] = resolved_seed+ endparams["module"] = @module if @moduleparams["theme_name"] = @theme_name if @theme_nameparams["theme_url"] = @theme_url if @theme_url@@ -541,7 +546,7 @@ class QunitRunnerenddef resolved_seed- @resolved_seed ||= present_string(@seed) || Random.new.seed+ @resolved_seed ||= present_string(@seed) || SecureRandom.alphanumeric(8)enddef should_load_plugins?diff --git a/spec/tasks/qunit_cli_spec.rb b/spec/tasks/qunit_cli_spec.rbindex 84ba6f41eda..6095683ff5b 100644--- a/spec/tasks/qunit_cli_spec.rb+++ b/spec/tasks/qunit_cli_spec.rb@@ -36,7 +36,9 @@ describe "bin/qunit" do"ember","exam","--query",- a_string_matching(/\Aseed=\d+&target=core\z/),+ "target=core",+ "--random",+ a_string_matching(/\A[a-zA-Z0-9]{8}\z/),"--path","dist",],@@ -59,9 +61,11 @@ describe "bin/qunit" do"ember","exam","--query",- a_string_matching(/\Aseed=\d+&target=core\z/),+ "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",],@@ -79,7 +83,15 @@ describe "bin/qunit" doexpect(result.launched_unicorn).to eq(false)expect(result.args).to match(- ["pnpm", "ember", "exam", "--query", a_string_matching(/\Aseed=\d+\z/), "--path", "dist"],+ [+ "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,@@ -95,7 +107,15 @@ describe "bin/qunit" doexpect(result.launched_unicorn).to eq(false)expect(result.args).to match(- ["pnpm", "ember", "exam", "--query", a_string_matching(/\Aseed=\d+\z/), "--path", "dist"],+ [+ "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,@@ -116,12 +136,14 @@ describe "bin/qunit" do"ember","exam","--query",- a_string_matching(/\Aseed=\d+&target=chat\z/),+ "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",],