mirror of
https://github.com/discourse/discourse.git
synced 2025-02-05 19:11:13 +00:00
DEV: Extensively use exception: true
in system()
(#25911)
Specifically fixes a bug in smoke-test where it would just move on after failing to install latest js dependencies with yarn.
This commit is contained in:
parent
b337ae5ae9
commit
3736d66f17
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
desc "ensure the asynchronously-created post_search_data index is present"
|
desc "ensure the asynchronously-created post_search_data index is present"
|
||||||
task "annotate" => :environment do |task, args|
|
task "annotate" => :environment do |task, args|
|
||||||
raise if !system "bin/annotate --models"
|
system("bin/annotate --models", exception: true)
|
||||||
STDERR.puts "Annotate executed successfully"
|
STDERR.puts "Annotate executed successfully"
|
||||||
|
|
||||||
non_core_plugins =
|
non_core_plugins =
|
||||||
@ -27,9 +27,12 @@ task "annotate:clean" => :environment do |task, args|
|
|||||||
db = TemporaryDb.new
|
db = TemporaryDb.new
|
||||||
db.start
|
db.start
|
||||||
db.with_env do
|
db.with_env do
|
||||||
raise if !system "RAILS_ENV=test LOAD_PLUGINS=0 bin/rake db:migrate"
|
system("RAILS_ENV=test LOAD_PLUGINS=0 bin/rake db:migrate", exception: true)
|
||||||
raise if !system "RAILS_ENV=test LOAD_PLUGINS=0 bin/rake annotate:ensure_all_indexes"
|
system("RAILS_ENV=test LOAD_PLUGINS=0 bin/rake annotate:ensure_all_indexes", exception: true)
|
||||||
raise if !system "RAILS_ENV=test LOAD_PLUGINS=0 bin/annotate --models --model-dir app/models"
|
system(
|
||||||
|
"RAILS_ENV=test LOAD_PLUGINS=0 bin/annotate --models --model-dir app/models",
|
||||||
|
exception: true,
|
||||||
|
)
|
||||||
end
|
end
|
||||||
STDERR.puts "Annotate executed successfully"
|
STDERR.puts "Annotate executed successfully"
|
||||||
ensure
|
ensure
|
||||||
|
@ -27,7 +27,10 @@ end
|
|||||||
|
|
||||||
task "db:environment:set" => [:load_config] do |_, args|
|
task "db:environment:set" => [:load_config] do |_, args|
|
||||||
if MultisiteTestHelpers.load_multisite?
|
if MultisiteTestHelpers.load_multisite?
|
||||||
system("RAILS_ENV=test RAILS_DB=discourse_test_multisite rake db:environment:set")
|
system(
|
||||||
|
"RAILS_ENV=test RAILS_DB=discourse_test_multisite rake db:environment:set",
|
||||||
|
exception: true,
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -56,7 +59,7 @@ end
|
|||||||
|
|
||||||
task "db:drop" => [:load_config] do |_, args|
|
task "db:drop" => [:load_config] do |_, args|
|
||||||
if MultisiteTestHelpers.create_multisite?
|
if MultisiteTestHelpers.create_multisite?
|
||||||
system("RAILS_DB=discourse_test_multisite RAILS_ENV=test rake db:drop")
|
system("RAILS_DB=discourse_test_multisite RAILS_ENV=test rake db:drop", exception: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -266,7 +269,7 @@ task "db:migrate" => %w[
|
|||||||
end
|
end
|
||||||
|
|
||||||
if !Discourse.is_parallel_test? && MultisiteTestHelpers.load_multisite?
|
if !Discourse.is_parallel_test? && MultisiteTestHelpers.load_multisite?
|
||||||
system("RAILS_DB=discourse_test_multisite rake db:migrate")
|
system("RAILS_DB=discourse_test_multisite rake db:migrate", exception: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ def write_template(path, task_name, template)
|
|||||||
|
|
||||||
File.write(output_path, "#{header}\n\n#{template}")
|
File.write(output_path, "#{header}\n\n#{template}")
|
||||||
puts "#{basename} created"
|
puts "#{basename} created"
|
||||||
`yarn run prettier --write #{output_path}`
|
system("yarn run prettier --write #{output_path}", exception: true)
|
||||||
puts "#{basename} prettified"
|
puts "#{basename} prettified"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ def write_hbs_template(path, task_name, template)
|
|||||||
basename = File.basename(path)
|
basename = File.basename(path)
|
||||||
output_path = "#{Rails.root}/app/assets/javascripts/#{path}"
|
output_path = "#{Rails.root}/app/assets/javascripts/#{path}"
|
||||||
File.write(output_path, "#{header}\n#{template}")
|
File.write(output_path, "#{header}\n#{template}")
|
||||||
`yarn run prettier --write #{output_path}`
|
system("yarn run prettier --write #{output_path}", exception: true)
|
||||||
puts "#{basename} created"
|
puts "#{basename} created"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -203,8 +203,7 @@ end
|
|||||||
task "javascript:update" => "clean_up" do
|
task "javascript:update" => "clean_up" do
|
||||||
require "uglifier"
|
require "uglifier"
|
||||||
|
|
||||||
yarn = system("yarn install")
|
system("yarn install", exception: true)
|
||||||
abort('Unable to run "yarn install"') unless yarn
|
|
||||||
|
|
||||||
versions = {}
|
versions = {}
|
||||||
start = Time.now
|
start = Time.now
|
||||||
|
@ -17,7 +17,7 @@ task "qunit:test", %i[timeout qunit_path filter] do |_, args|
|
|||||||
|
|
||||||
report_requests = ENV["REPORT_REQUESTS"] == "1"
|
report_requests = ENV["REPORT_REQUESTS"] == "1"
|
||||||
|
|
||||||
system("yarn install")
|
system("yarn install", exception: true)
|
||||||
|
|
||||||
# ensure we have this port available
|
# ensure we have this port available
|
||||||
def port_available?(port)
|
def port_available?(port)
|
||||||
@ -108,7 +108,13 @@ task "qunit:test", %i[timeout qunit_path filter] do |_, args|
|
|||||||
if qunit_path
|
if qunit_path
|
||||||
# Bypass `ember test` - it only works properly for the `/tests` path.
|
# Bypass `ember test` - it only works properly for the `/tests` path.
|
||||||
# We have to trigger a `build` manually so that JS is available for rails to serve.
|
# We have to trigger a `build` manually so that JS is available for rails to serve.
|
||||||
system("yarn", "ember", "build", chdir: "#{Rails.root}/app/assets/javascripts/discourse")
|
system(
|
||||||
|
"yarn",
|
||||||
|
"ember",
|
||||||
|
"build",
|
||||||
|
chdir: "#{Rails.root}/app/assets/javascripts/discourse",
|
||||||
|
exception: true,
|
||||||
|
)
|
||||||
|
|
||||||
env["THEME_TEST_PAGES"] = if ENV["THEME_IDS"]
|
env["THEME_TEST_PAGES"] = if ENV["THEME_IDS"]
|
||||||
ENV["THEME_IDS"]
|
ENV["THEME_IDS"]
|
||||||
|
@ -10,7 +10,7 @@ task "smoke:test" do
|
|||||||
abort err.message
|
abort err.message
|
||||||
end
|
end
|
||||||
|
|
||||||
system("yarn install")
|
system("yarn install", exception: true)
|
||||||
|
|
||||||
url = ENV["URL"]
|
url = ENV["URL"]
|
||||||
if !url
|
if !url
|
||||||
|
@ -9,8 +9,7 @@ def library_src
|
|||||||
end
|
end
|
||||||
|
|
||||||
task "svgicons:update" do
|
task "svgicons:update" do
|
||||||
yarn = system("yarn install")
|
system("yarn install", exception: true)
|
||||||
abort('Unable to run "yarn install"') unless yarn
|
|
||||||
|
|
||||||
dependencies = [{ source: "@fortawesome/fontawesome-free/sprites", destination: "fontawesome" }]
|
dependencies = [{ source: "@fortawesome/fontawesome-free/sprites", destination: "fontawesome" }]
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
RSpec.describe "Migrations::Import" do
|
RSpec.describe "Migrations::Import" do
|
||||||
subject(:cli) { system "migrations/import" }
|
subject(:cli) { system("migrations/import", exception: true) }
|
||||||
|
|
||||||
it "works" do
|
it "works" do
|
||||||
expect { cli }.to output(
|
expect { cli }.to output(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user