DEV: Don't use `Dir.chdir()` (#16535)

`system()` provides `chdir:` option for that.
This commit is contained in:
Jarek Radosz 2022-04-22 11:17:10 +02:00 committed by GitHub
parent dba7a1d8ed
commit 1209d51a7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 7 deletions

View File

@ -1,7 +1,6 @@
# frozen_string_literal: true
desc "Runs the qunit test suite"
task "qunit:test", [:timeout, :qunit_path] do |_, args|
require "socket"
require "chrome_installed_checker"
@ -107,11 +106,9 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
puts "Rails server is warmed up"
if ember_cli
Dir.chdir("#{Rails.root}/app/assets/javascripts/discourse") do # rubocop:disable Discourse/NoChdir because this is not part of the app
cmd = ["env", "UNICORN_PORT=#{unicorn_port}", "yarn", "ember", "test", "--query", query]
cmd += ["--test-page", qunit_path.delete_prefix("/")] if qunit_path
system(*cmd)
end
cmd = ["env", "UNICORN_PORT=#{unicorn_port}", "yarn", "ember", "test", "--query", query]
cmd += ["--test-page", qunit_path.delete_prefix("/")] if qunit_path
system(*cmd, chdir: "#{Rails.root}/app/assets/javascripts/discourse")
else
cmd = "node #{test_path}/run-qunit.js http://localhost:#{port}#{qunit_path}"
cmd += "?#{query.gsub('+', '%20').gsub("&", '\\\&')}"
@ -131,5 +128,4 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
puts "\nTests Failed"
exit(1)
end
end