A platform for community discussion. Free, open, simple.
DEV: Restore the documentation format in system tests (#21471)
Jarek Radosz19ac90536f2c
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 9695d54d2ca..361466be61c 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -180,7 +180,7 @@ jobs:- name: Plugin RSpecif: matrix.build_type == 'backend' && matrix.target == 'plugins'- run: bin/rake plugin:turbo_spec+ run: bin/rake plugin:turbo_spec['*','--verbose --format documentation']- name: Plugin QUnitif: matrix.build_type == 'frontend' && matrix.target == 'plugins'@@ -197,11 +197,11 @@ jobs:- name: Core System Testsif: matrix.build_type == 'system' && matrix.target == 'core'- run: PARALLEL_TEST_PROCESSORS=4 bin/turbo_rspec --verbose spec/system+ run: PARALLEL_TEST_PROCESSORS=4 bin/turbo_rspec --verbose --format documentation spec/system- name: Plugin System Testsif: matrix.build_type == 'system' && matrix.target == 'plugins'- run: LOAD_PLUGINS=1 PARALLEL_TEST_PROCESSORS=4 bin/turbo_rspec --verbose plugins/*/spec/system+ run: LOAD_PLUGINS=1 PARALLEL_TEST_PROCESSORS=4 bin/turbo_rspec --verbose --format documentation plugins/*/spec/systemtimeout-minutes: 30- name: Upload failed system test screenshotsdiff --git a/lib/tasks/documentation.rake b/lib/tasks/documentation.rakeindex 1d74953eb1f..d1e4c767db1 100644--- a/lib/tasks/documentation.rake+++ b/lib/tasks/documentation.rake@@ -16,7 +16,7 @@ def generate_chat_documentation]`yarn --silent jsdoc --readme plugins/chat/README.md -c #{config} #{files.join(" ")} -d #{destination}`- # unecessary files+ # unnecessary files%w[documentation/chat/frontend/scripts/prism.min.jsdocumentation/chat/frontend/scripts/prism.jsdiff --git a/lib/tasks/plugin.rake b/lib/tasks/plugin.rakeindex 9c8d4e601ee..5292df21bc7 100644--- a/lib/tasks/plugin.rake+++ b/lib/tasks/plugin.rake@@ -168,13 +168,13 @@ task "plugin:install_gems", :plugin do |t, args|puts "Done"end-def spec(plugin, parallel: false)+def spec(plugin, parallel: false, argv: nil)params = []params << "--profile" if !parallelparams << "--fail-fast" if ENV["RSPEC_FAILFAST"]params << "--seed #{ENV["RSPEC_SEED"]}" if Integer(ENV["RSPEC_SEED"], exception: false)+ params << argv if argv- ruby = `which ruby`.strip# reject system specs as they are slow and need dedicated setupfiles =Dir.glob("./plugins/#{plugin}/spec/**/*_spec.rb").reject { |f| f.include?("spec/system/") }.sort@@ -187,15 +187,15 @@ def spec(plugin, parallel: false)enddesc "run plugin specs"-task "plugin:spec", :plugin do |t, args|+task "plugin:spec", %i[plugin argv] do |_, args|args.with_defaults(plugin: "*")- spec(args[:plugin])+ spec(args[:plugin], argv: args[:argv])enddesc "run plugin specs in parallel"-task "plugin:turbo_spec", :plugin do |t, args|+task "plugin:turbo_spec", %i[plugin argv] do |_, args|args.with_defaults(plugin: "*")- spec(args[:plugin], parallel: true)+ spec(args[:plugin], parallel: true, argv: args[:argv])enddesc "run plugin qunit tests"diff --git a/lib/turbo_tests.rb b/lib/turbo_tests.rbindex dd3e9c0b619..c8ecc41c6a0 100644--- a/lib/turbo_tests.rb+++ b/lib/turbo_tests.rb@@ -15,6 +15,7 @@ require "parallel_tests/rspec/runner"require "./lib/turbo_tests/reporter"require "./lib/turbo_tests/runner"require "./lib/turbo_tests/json_rows_formatter"+require "./lib/turbo_tests/documentation_formatter"module TurboTestsFakeException = Struct.new(:backtrace, :message, :cause)@@ -54,9 +55,18 @@ module TurboTestsendFakeExample =- Struct.new(:execution_result, :location, :full_description, :metadata, :location_rerun_argument)+ Struct.new(+ :execution_result,+ :location,+ :description,+ :full_description,+ :metadata,+ :location_rerun_argument,+ :process_id,+ )+class FakeExample- def self.from_obj(obj)+ def self.from_obj(obj, process_id)obj = obj.symbolize_keysmetadata = obj[:metadata].symbolize_keys@@ -71,9 +81,11 @@ module TurboTestsnew(FakeExecutionResult.from_obj(obj[:execution_result]),obj[:location],+ obj[:description],obj[:full_description],metadata,obj[:location_rerun_argument],+ process_id,)enddiff --git a/lib/turbo_tests/documentation_formatter.rb b/lib/turbo_tests/documentation_formatter.rbnew file mode 100644index 00000000000..72b924e3f19--- /dev/null+++ b/lib/turbo_tests/documentation_formatter.rb@@ -0,0 +1,44 @@+# frozen_string_literal: true++RSpec::Support.require_rspec_core "formatters/base_text_formatter"++module TurboTests+ # An RSpec formatter that prepends the process id to all messages+ class DocumentationFormatter < ::RSpec::Core::Formatters::BaseTextFormatter+ RSpec::Core::Formatters.register(self, :example_failed, :example_passed, :example_pending)++ def example_passed(notification)+ output.puts RSpec::Core::Formatters::ConsoleCodes.wrap(+ "[#{notification.example.process_id}] #{notification.example.full_description}",+ :success,+ )+ output.flush+ end++ def example_pending(notification)+ message = notification.example.execution_result.pending_message+ output.puts RSpec::Core::Formatters::ConsoleCodes.wrap(+ "[#{notification.example.process_id}] #{notification.example.full_description}" \+ "(PENDING: #{message})",+ :pending,+ )+ output.flush+ end++ def example_failed(notification)+ output.puts RSpec::Core::Formatters::ConsoleCodes.wrap(+ "[#{notification.example.process_id}] #{notification.example.full_description}" \+ "(FAILED - #{next_failure_index})",+ :failure,+ )+ output.flush+ end++ private++ def next_failure_index+ @next_failure_index ||= 0+ @next_failure_index += 1+ end+ end+enddiff --git a/lib/turbo_tests/json_rows_formatter.rb b/lib/turbo_tests/json_rows_formatter.rbindex 35118c35027..1b35344c64b 100644--- a/lib/turbo_tests/json_rows_formatter.rb+++ b/lib/turbo_tests/json_rows_formatter.rb@@ -49,6 +49,7 @@ module TurboTests{execution_result: execution_result_to_json(example.execution_result),location: example.location,+ description: example.description,full_description: example.full_description,metadata: {shared_group_inclusion_backtrace:diff --git a/lib/turbo_tests/reporter.rb b/lib/turbo_tests/reporter.rbindex 67c2a71bc30..af0646abbba 100644--- a/lib/turbo_tests/reporter.rb+++ b/lib/turbo_tests/reporter.rb@@ -35,6 +35,8 @@ module TurboTestscase namewhen "p", "progress"RSpec::Core::Formatters::ProgressFormatter+ when "d", "documentation"+ TurboTests::DocumentationFormatterelseKernel.const_get(name)enddiff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rbindex 010a4bbb771..470b629d531 100644--- a/lib/turbo_tests/runner.rb+++ b/lib/turbo_tests/runner.rb@@ -215,13 +215,13 @@ module TurboTestsmessage = @messages.popcase message[:type]when "example_passed"- example = FakeExample.from_obj(message[:example])+ example = FakeExample.from_obj(message[:example], message[:process_id])@reporter.example_passed(example)when "example_pending"- example = FakeExample.from_obj(message[:example])+ example = FakeExample.from_obj(message[:example], message[:process_id])@reporter.example_pending(example)when "example_failed"- example = FakeExample.from_obj(message[:example])+ example = FakeExample.from_obj(message[:example], message[:process_id])@reporter.example_failed(example)@failure_count += 1if fail_fast_met@@ -237,6 +237,7 @@ module TurboTests@error = truewhen "exit"exited += 1+ @reporter.message("[#{message[:process_id]}] DONE (#{exited}/#{@num_processes + 1})")break if exited == @num_processes + 1elseSTDERR.puts("Unhandled message in main process: #{message}")