mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-18 22:05:43 +08:00
Adds `RspecPerformanceFormatter`, an RSpec formatter that captures the SQL queries, Redis commands, and outbound network calls each example performs and emits them as NDJSON with one object per test. It gives an AI model (or a developer) concrete per-test context for spotting N+1s, redundant queries, or unexpected outbound calls. Off unless the formatter is selected, so normal runs and production are unaffected. Works with both `bin/rspec` and `bin/turbo_rspec`.
36 lines
1 KiB
Ruby
Executable file
Vendored
36 lines
1 KiB
Ruby
Executable file
Vendored
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
#
|
|
# This file was generated by Bundler.
|
|
#
|
|
# The application 'rspec' is installed as part of a gem, and
|
|
# this file is here to facilitate running it.
|
|
#
|
|
|
|
require "pathname"
|
|
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath)
|
|
|
|
require "rubygems"
|
|
require "bundler/setup"
|
|
|
|
if ENV["LOAD_PLUGINS"].nil? &&
|
|
ARGV.any? { |pattern|
|
|
pattern.include?("plugins/") ||
|
|
(
|
|
ENV.key?("DISCOURSE_REPO_BASE_DIRECTORY") &&
|
|
!pattern.include?(ENV["DISCOURSE_REPO_BASE_DIRECTORY"] + "/spec")
|
|
)
|
|
}
|
|
STDERR.puts "Detected plugin spec path, setting LOAD_PLUGINS to 1"
|
|
ENV["LOAD_PLUGINS"] = "1"
|
|
end
|
|
|
|
ENV["PLAYWRIGHT_HEADLESS"] = "0" if ARGV.delete("--headful")
|
|
ENV["CAPYBARA_PLAYWRIGHT_DEBUG_CLIENT_SETTLED"] = "1" if ARGV.delete("--debug-client-settled")
|
|
|
|
if ARGV.any? { |arg| arg.include?("RspecPerformanceFormatter") }
|
|
ENV["DISCOURSE_RSPEC_PERFORMANCE_FORMATTER"] = "1"
|
|
end
|
|
|
|
load Gem.bin_path("rspec-core", "rspec")
|