A platform for community discussion. Free, open, simple.
DEV: Change test formatters (#39427)
Jarek Radosz22068cbf2e6c
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 14166e9e46f..ea2c4e49b3f 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -24,7 +24,7 @@ permissions:jobs:build:if: github.event_name == 'pull_request' || github.repository != 'discourse/discourse-private-mirror'- name: ${{ matrix.target }} ${{ matrix.build_type }}${{ (matrix.target == 'core' && matrix.build_type == 'frontend' && format(' ({0})', matrix.browser)) || '' }}+ name: ${{ (matrix.target == 'core-plugins' && 'plugins (core)') || (matrix.target == 'official-plugins' && 'plugins (official)') || (matrix.target == 'chat' && 'plugins (chat)') || matrix.target }} ${{ matrix.build_type }}runs-on: >-${{github.repository_owner == 'discourse' && (@@ -57,8 +57,6 @@ jobs:CHEAP_SOURCE_MAPS: "1"DBUS_SESSION_BUS_ADDRESS: "unix:path=/dev/null"MINIO_RUNNER_INSTALL_DIR: /home/discourse/.minio_runner- TESTEM_BROWSER: ${{ (startsWith(matrix.browser, 'Firefox') && 'Firefox') || matrix.browser }}- TESTEM_FIREFOX_PATH: ${{ (matrix.browser == 'Firefox Evergreen') && '/opt/firefox-evergreen/firefox' }}EMBER_ENV: developmentLOAD_PLUGINS: ${{ (matrix.target == 'core-plugins' || matrix.target == 'official-plugins' || matrix.target == 'plugins' || matrix.target == 'chat') && '1' || '0' }}QUNIT_REUSE_BUILD: 1@@ -67,32 +65,27 @@ jobs:fail-fast: falsematrix:- build_type: [backend, frontend, system]- target: [core, plugins, themes]- browser: [Chrome]- exclude:- - build_type: backend- target: themes- # Exclude combined plugins from system tests - use split targets instead- - build_type: system- target: pluginsinclude:- # Split plugin targets for system tests only- - build_type: system- target: core-plugins- browser: Chrome- - build_type: system- target: official-plugins- browser: Chrome- - build_type: system- target: chat- browser: Chrome- # - build_type: frontend- # target: core- # browser: Firefox Evergreen- # - build_type: frontend- # target: core- # browser: Firefox ESR+ - target: core+ build_type: backend+ - target: core+ build_type: frontend+ - target: core+ build_type: system+ - target: plugins+ build_type: backend+ - target: plugins+ build_type: frontend+ - target: core-plugins+ build_type: system+ - target: chat+ build_type: system+ - target: official-plugins+ build_type: system+ - target: themes+ build_type: frontend+ - target: themes+ build_type: systemsteps:- name: Set working directory owner@@ -289,7 +282,7 @@ jobs:- name: Core RSpecif: matrix.build_type == 'backend' && matrix.target == 'core'- run: bin/turbo_rspec --use-runtime-info --verbose --format=progress --profile=50+ run: bin/turbo_rspec --use-runtime-info --verbose --format=progress- name: Ember Buildif: matrix.build_type == 'system' || matrix.build_type == 'frontend'@@ -307,7 +300,7 @@ jobs:- name: Plugins RSpecif: matrix.build_type == 'backend' && matrix.target == 'plugins'run: |- bin/rake plugin:turbo_spec['*','--verbose --format=progress --use-runtime-info --profile=50']+ bin/rake plugin:turbo_spec['*','--verbose --format=progress --use-runtime-info']- name: Plugins QUnitif: matrix.build_type == 'frontend' && matrix.target == 'plugins'@@ -331,33 +324,33 @@ jobs:if: matrix.build_type == 'system' && matrix.target == 'core'env:CHECKOUT_TIMEOUT: 10- run: RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error bin/turbo_rspec --use-runtime-info --profile=50 --verbose --format documentation spec/system+ run: RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error bin/turbo_rspec --use-runtime-info --verbose --format documentation spec/system- name: Core Plugins System Testsif: matrix.build_type == 'system' && matrix.target == 'core-plugins'env:CHECKOUT_TIMEOUT: 10run: |- RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error bin/turbo_rspec --exclude-pattern="plugins/chat/*" --use-runtime-info --profile=50 --verbose --format documentation plugins/*/spec/system+ RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error bin/turbo_rspec --exclude-pattern="plugins/chat/*" --use-runtime-info --verbose --format documentation plugins/*/spec/system- name: Official Plugins System Testsif: matrix.build_type == 'system' && matrix.target == 'official-plugins'env:CHECKOUT_TIMEOUT: 10run: |- RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error bin/turbo_rspec --exclude-pattern="$(script/list_bundled_plugins '/*' | paste -sd, -)" --use-runtime-info --profile=50 --verbose --format documentation plugins/*/spec/system+ RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error bin/turbo_rspec --exclude-pattern="$(script/list_bundled_plugins '/*' | paste -sd, -)" --use-runtime-info --verbose --format documentation plugins/*/spec/system- name: Chat System Testsif: matrix.build_type == 'system' && matrix.target == 'chat'env:CHECKOUT_TIMEOUT: 10- run: RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error bin/turbo_rspec --use-runtime-info --profile=50 --verbose --format documentation plugins/chat/spec/system+ run: RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error bin/turbo_rspec --use-runtime-info --verbose --format documentation plugins/chat/spec/system- name: Theme System Testsif: matrix.build_type == 'system' && matrix.target == 'themes'env:CHECKOUT_TIMEOUT: 10- run: RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error bin/turbo_rspec --profile=50 --verbose --format documentation tmp/themes/*/spec/system themes/*/spec/system+ run: RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error bin/turbo_rspec --verbose --format documentation tmp/themes/*/spec/system themes/*/spec/system- name: Upload failed system test artifactsuses: actions/upload-artifact@v7diff --git a/bin/turbo_rspec b/bin/turbo_rspecindex f97bc2548a9..2f4e6ad9a4d 100755--- a/bin/turbo_rspec+++ b/bin/turbo_rspec@@ -76,14 +76,8 @@ OptionParser# OptionParser modifies ARGV, leaving the leftover arguments in ARGVif ARGV.empty?- if !enable_system_tests- STDERR.puts "Not running system tests since it wasn't explicitly specified"- end-- run_system_tests = !!enable_system_tests-files = Dir.glob("spec/**/*_spec.rb")- files.reject! { |file| File.fnmatch("*spec/system*", file) } if !run_system_tests+ files.reject! { |file| File.fnmatch("*spec/system*", file) } if !enable_system_testsuse_runtime_info = true if use_runtime_info.nil?elsediff --git a/config/boot.rb b/config/boot.rbindex 155cad7f6cd..d14ab6341c4 100644--- a/config/boot.rb+++ b/config/boot.rb@@ -33,8 +33,6 @@ if ENV["RAILS_ENV"] == "test" && ENV["TEST_ENV_NUMBER"]port = 10_000 + n- STDERR.puts "Setting up parallel test mode - starting Redis #{n} on port #{port}"-`rm -rf tmp/test_data_#{n} && mkdir -p tmp/test_data_#{n}/redis`pid =Process.spawn("redis-server --dir tmp/test_data_#{n}/redis --port #{port}", out: "/dev/null")diff --git a/frontend/discourse/testem.js b/frontend/discourse/testem.jsindex d567c4db23e..0e6ebee74a2 100644--- a/frontend/discourse/testem.js+++ b/frontend/discourse/testem.js@@ -59,7 +59,9 @@ class Reporter extends TapReporter {display(prefix, result) {if (this.willDisplay(result)) {- const string = displayUtils.resultString(+ this.showBrowserVersion(prefix);++ const rawString = displayUtils.resultString(this.id++,prefix,result,@@ -67,6 +69,8 @@ class Reporter extends TapReporter {this.strictSpecCompliance);+ const string = this.reformatTapLine(rawString, prefix);+const color = this.colorForResult(result);const matches = string.match(/([\S\s]+?)(\n\s+browser\slog:[\S\s]+)/);@@ -79,6 +83,43 @@ class Reporter extends TapReporter {}}+ showBrowserVersion(prefix) {+ if (!prefix) {+ return;+ }++ this.shownBrowserVersions ??= new Set();+ if (!this.shownBrowserVersions.has(prefix)) {+ this.shownBrowserVersions.add(prefix);+ this.out.write(colors.gray(`# Launcher: ${prefix}\n`));+ }+ }++ reformatTapLine(rawString, prefix) {+ const newlineIndex = rawString.indexOf("\n");+ const firstLine =+ newlineIndex >= 0 ? rawString.slice(0, newlineIndex) : rawString;+ const rest = newlineIndex >= 0 ? rawString.slice(newlineIndex) : "";+ let line = firstLine;++ if (prefix) {+ const escaped = prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");+ line = line.replace(+ new RegExp(+ `^(ok|not ok|skip|todo) (\\d+) ${escaped} - (\\[\\d+ ms\\])`+ ),+ "$1 $2 $3"+ );+ }++ line = line.replace(+ /^(ok|not ok|skip|todo) (\d+) (\[\d+ ms\]) - Browser Id (\d+) - /,+ "$1 $2 #$4 $3 - "+ );++ return line + rest;+ }+colorForResult(result) {if (result.todo || result.skipped) {return colors.yellow;diff --git a/lib/turbo_tests/documentation_formatter.rb b/lib/turbo_tests/documentation_formatter.rbindex 91b25c12c80..e9a4bafba72 100644--- a/lib/turbo_tests/documentation_formatter.rb+++ b/lib/turbo_tests/documentation_formatter.rb@@ -66,8 +66,7 @@ module TurboTestsenddef output_example(example)- output =- +"[#{example.process_id}] (##{example.metadata[:process_pid]}) #{example.full_description}"+ output = +"[#{example.process_id}] #{example.full_description}"if run_duration_ms = example.metadata[:run_duration_ms]output << " (#{run_duration_ms}ms)"diff --git a/lib/turbo_tests/json_example.rb b/lib/turbo_tests/json_example.rbindex a0ac86ce4ff..13b9b7b45e5 100644--- a/lib/turbo_tests/json_example.rb+++ b/lib/turbo_tests/json_example.rb@@ -18,7 +18,6 @@ module TurboTests),extra_failure_lines: @rspec_example.metadata[:extra_failure_lines],run_duration_ms: @rspec_example.metadata[:run_duration_ms],- process_pid: Process.pid,js_deprecations: @rspec_example.metadata[:js_deprecations],rerun_file_path: @rspec_example.metadata[:rerun_file_path],active_record_debug_logs: @rspec_example.metadata[:active_record_debug_logs],diff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rbindex cffe727b2ca..9f40978845a 100644--- a/lib/turbo_tests/runner.rb+++ b/lib/turbo_tests/runner.rb@@ -12,8 +12,6 @@ module TurboTestsuse_runtime_info = opts.fetch(:use_runtime_info, false)retry_and_log_flaky_tests = opts.fetch(:retry_and_log_flaky_tests, false)- STDOUT.puts "VERBOSE" if verbose-reporter =Reporter.from_config(formatters,