Class: Ace::TestRunner::Models::TestConfiguration
- Inherits:
-
Object
- Object
- Ace::TestRunner::Models::TestConfiguration
- Defined in:
- lib/ace/test_runner/models/test_configuration.rb
Overview
Configuration for test execution
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#config_path ⇒ Object
Returns the value of attribute config_path.
-
#execution ⇒ Object
Returns the value of attribute execution.
-
#fail_fast ⇒ Object
Returns the value of attribute fail_fast.
-
#failure_limits ⇒ Object
Returns the value of attribute failure_limits.
-
#files ⇒ Object
Returns the value of attribute files.
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#fix_deprecations ⇒ Object
Returns the value of attribute fix_deprecations.
-
#format ⇒ Object
Returns the value of attribute format.
-
#parallel ⇒ Object
Returns the value of attribute parallel.
-
#patterns ⇒ Object
Returns the value of attribute patterns.
-
#per_file ⇒ Object
Returns the value of attribute per_file.
-
#profile ⇒ Object
Returns the value of attribute profile.
-
#report_dir ⇒ Object
Returns the value of attribute report_dir.
-
#run_in_single_batch ⇒ Object
Returns the value of attribute run_in_single_batch.
-
#save_reports ⇒ Object
Returns the value of attribute save_reports.
-
#target ⇒ Object
Returns the value of attribute target.
-
#targets ⇒ Object
Returns the value of attribute targets.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Class Method Summary collapse
Instance Method Summary collapse
- #execution_mode ⇒ Object
- #formatter_class ⇒ Object
-
#initialize(attributes = {}) ⇒ TestConfiguration
constructor
A new instance of TestConfiguration.
- #merge(options) ⇒ Object
- #target_isolation ⇒ Object
- #to_h ⇒ Object
- #valid_format? ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ TestConfiguration
Returns a new instance of TestConfiguration.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 14 def initialize(attributes = {}) @format = attributes[:format] || "progress" # Default to per-test progress @report_dir = attributes[:report_dir] || ".ace-local/test/reports" @save_reports = attributes.fetch(:save_reports, true) @fail_fast = attributes[:fail_fast] || false @verbose = attributes[:verbose] || false @filter = attributes[:filter] @fix_deprecations = attributes[:fix_deprecations] || false @patterns = attributes[:patterns] || default_patterns @targets = attributes[:targets] || default_targets @target = attributes[:target] @config_path = attributes[:config_path] @timeout = attributes[:timeout] # In seconds, nil = no timeout @parallel = attributes[:parallel] || false @color = attributes.fetch(:color, true) @per_file = attributes[:per_file] || false # Default to by-target execution for performance @failure_limits = attributes[:failure_limits] || {max_display: 7} @profile = attributes[:profile] # nil means no profiling, number means show N slowest tests @execution = attributes[:execution] || {} @files = attributes[:files] # Specific files to test (overrides target/patterns) @run_in_single_batch = attributes[:run_in_single_batch] || false end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def color @color end |
#config_path ⇒ Object
Returns the value of attribute config_path.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def config_path @config_path end |
#execution ⇒ Object
Returns the value of attribute execution.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def execution @execution end |
#fail_fast ⇒ Object
Returns the value of attribute fail_fast.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def fail_fast @fail_fast end |
#failure_limits ⇒ Object
Returns the value of attribute failure_limits.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def failure_limits @failure_limits end |
#files ⇒ Object
Returns the value of attribute files.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def files @files end |
#filter ⇒ Object
Returns the value of attribute filter.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def filter @filter end |
#fix_deprecations ⇒ Object
Returns the value of attribute fix_deprecations.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def fix_deprecations @fix_deprecations end |
#format ⇒ Object
Returns the value of attribute format.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def format @format end |
#parallel ⇒ Object
Returns the value of attribute parallel.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def parallel @parallel end |
#patterns ⇒ Object
Returns the value of attribute patterns.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def patterns @patterns end |
#per_file ⇒ Object
Returns the value of attribute per_file.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def per_file @per_file end |
#profile ⇒ Object
Returns the value of attribute profile.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def profile @profile end |
#report_dir ⇒ Object
Returns the value of attribute report_dir.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def report_dir @report_dir end |
#run_in_single_batch ⇒ Object
Returns the value of attribute run_in_single_batch.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def run_in_single_batch @run_in_single_batch end |
#save_reports ⇒ Object
Returns the value of attribute save_reports.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def save_reports @save_reports end |
#target ⇒ Object
Returns the value of attribute target.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def target @target end |
#targets ⇒ Object
Returns the value of attribute targets.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def targets @targets end |
#timeout ⇒ Object
Returns the value of attribute timeout.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def timeout @timeout end |
#verbose ⇒ Object
Returns the value of attribute verbose.
8 9 10 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 8 def verbose @verbose end |
Class Method Details
.from_cascade ⇒ Object
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 113 def self.from_cascade # Use ace-core configuration cascade if available if defined?(Ace::Core::Configuration) config = Ace::Core::Configuration.new test_config = config.get("test", {}) new(test_config.transform_keys(&:to_sym)) else new end end |
.from_file(path) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 105 def self.from_file(path) return new unless File.exist?(path) config_data = YAML.load_file(path) test_config = config_data["test"] || {} new(test_config.transform_keys(&:to_sym)) end |
Instance Method Details
#execution_mode ⇒ Object
58 59 60 61 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 58 def execution_mode # Default to "all-at-once" for simple, fast execution @execution&.[](:mode) || @execution&.dig("mode") || "all-at-once" end |
#formatter_class ⇒ Object
71 72 73 74 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 71 def formatter_class # Use lazy loader to load formatter on demand Atoms::LazyLoader.load_formatter(format) end |
#merge(options) ⇒ Object
101 102 103 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 101 def merge() self.class.new(to_h.merge()) end |
#target_isolation ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 63 def target_isolation # Default to true for better isolation in by-target mode # Use fetch to handle false values correctly (|| would treat false as falsy) mode = @execution&.[](:target_isolation) mode = @execution&.dig("target_isolation") if mode.nil? mode.nil? || mode end |
#to_h ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 76 def to_h { format: format, report_dir: report_dir, save_reports: save_reports, fail_fast: fail_fast, verbose: verbose, filter: filter, fix_deprecations: fix_deprecations, patterns: patterns, targets: targets, target: target, config_path: config_path, timeout: timeout, parallel: parallel, color: color, per_file: per_file, failure_limits: failure_limits, profile: profile, execution: execution, files: files, run_in_single_batch: run_in_single_batch } end |
#valid_format? ⇒ Boolean
37 38 39 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 37 def valid_format? %w[json progress progress-file].include?(format) end |
#validate! ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ace/test_runner/models/test_configuration.rb', line 41 def validate! unless valid_format? raise ArgumentError, "Unknown format '#{format}'. Valid formats: progress, progress-file, json" end if save_reports && !writable_directory?(report_dir) raise ArgumentError, "Cannot write to #{report_dir}. Check permissions" end # Validate execution_mode if provided if execution_mode && !%w[by-target all-at-once].include?(execution_mode) raise ArgumentError, "Unknown execution_mode '#{execution_mode}'. Valid modes: by-target, all-at-once" end true end |