Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Preserve screenshots in `bulk_run_rspec`

Christophe Bliardb762b6e7234e
diff --git a/script/bulk_run_rspec b/script/bulk_run_rspec
index fa4ce930a92..5690240d1d9 100755
--- a/script/bulk_run_rspec
+++ b/script/bulk_run_rspec
@@ -170,10 +170,24 @@ class BulkRunner
@tests ||= found_tests.map { |test_path| Test.new(test_path) }
end
+ def copy_screenshots_from_capybara_dir_to_bulk_run_dir
+ capybara_screenshots_dir.glob("screenshot_*").each do |screenshot|
+ FileUtils.cp(screenshot, bulk_run_dir("screenshots/"))
+ end
+ end
+
+ def copy_screenshots_from_bulk_run_dir_to_capybara_dir
+ bulk_run_dir.glob("screenshots/screenshot_*").each do |screenshot|
+ FileUtils.cp(screenshot, capybara_screenshots_dir)
+ end
+ end
+
# rubocop:disable Metrics/AbcSize
def run
FileUtils.rm_rf(bulk_run_dir("logs")) if bulk_run_dir("logs").exist?
- `mkdir -p #{bulk_run_dir("logs")}`
+ FileUtils.mkdir_p([bulk_run_dir("logs"),
+ bulk_run_dir("screenshots"),
+ capybara_screenshots_dir])
puts "#{tests.count} tests to run"
puts "logs: #{bulk_run_dir('logs')}"
tests.each do |test|
@@ -189,6 +203,7 @@ class BulkRunner
run.passed!
else
puts "ko".red
+ copy_screenshots_from_capybara_dir_to_bulk_run_dir
run.failed!
end
File.write(bulk_run_dir("logs/#{test.normalized_name}.#{run.result}.#{i}.log"), run.output)
@@ -199,15 +214,20 @@ class BulkRunner
puts "PASSED".green
else
puts "FAILED".red
+ copy_screenshots_from_bulk_run_dir_to_capybara_dir
end
end
end
# rubocop:enable Metrics/AbcSize
- def bulk_run_dir(path)
+ def bulk_run_dir(path = "")
RAILS_ROOT.join("tmp/bulk_run").join(path)
end
+ def capybara_screenshots_dir
+ RAILS_ROOT.join("tmp/capybara")
+ end
+
def save
puts "Saving"
File.open(bulk_run_dir("results.txt"), "w") do |results|