Class: Verity::Configuration
- Inherits:
-
Object
- Object
- Verity::Configuration
- Defined in:
- lib/verity/configuration.rb
Overview
Instance Attribute Summary collapse
-
#location_filters ⇒ Object
Public: String path for the SQLite manifest database.
-
#manifest_path ⇒ Object
Public: String path for the SQLite manifest database.
-
#reporter ⇒ Object
Public: String path for the SQLite manifest database.
-
#shuffle_seed ⇒ Object
Public: String path for the SQLite manifest database.
-
#test_globs ⇒ Object
Public: String path for the SQLite manifest database.
-
#test_order ⇒ Object
Public: String path for the SQLite manifest database.
-
#worker_count ⇒ Object
Public: String path for the SQLite manifest database.
Class Method Summary collapse
-
.cpus_worker_token?(value) ⇒ Boolean
Internal: Determine whether a value represents the :cpus worker token.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#memory_manifest? ⇒ Boolean
Public: Check whether the manifest is configured as in-memory.
-
#resolved_worker_count ⇒ Object
Public: Resolve worker_count to an Integer, expanding :cpus to the number of available processors.
- #set_defaults! ⇒ Object
-
#test_files ⇒ Object
Public: Expand test_globs into a sorted, deduplicated list of file paths.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
45 46 47 |
# File 'lib/verity/configuration.rb', line 45 def initialize set_defaults! end |
Instance Attribute Details
#location_filters ⇒ Object
Public: String path for the SQLite manifest database. Use “:memory:” for an in-process database (single-worker only; cannot be used with parallel workers). Default: “verity/manifest.db” (relative to the process working directory, typically the project root).
Public: Array of glob Strings matched against the working directory to discover test files. Default: [“verity/*/_test.rb”].
Public: Integer worker count, or :cpus / “cpus” to auto-detect from Etc.nprocessors. Default: 1.
Public: Object implementing the Verity::Reporter interface that receives lifecycle callbacks. Default: ColoredDotsReporter writing to $stdout.
Public: Test dispatch order for manifest runs: :random (default; shuffled once in the coordinator) or :fingerprint (sorted). A non-nil #shuffle_seed always implies a shuffle, even if test_order is :fingerprint.
Public: Integer RNG seed for shuffled order. When nil and order is random, a seed is chosen, stored here, and printed to stderr (the number only) before workers start.
Public: Optional Array of [absolute_path, Integer line] pairs (from CLI file:line). When non-empty, only tests whose #line matches, or that have an enclosing #group opened on that file:line, are runnable.
42 43 44 |
# File 'lib/verity/configuration.rb', line 42 def location_filters @location_filters end |
#manifest_path ⇒ Object
Public: String path for the SQLite manifest database. Use “:memory:” for an in-process database (single-worker only; cannot be used with parallel workers). Default: “verity/manifest.db” (relative to the process working directory, typically the project root).
Public: Array of glob Strings matched against the working directory to discover test files. Default: [“verity/*/_test.rb”].
Public: Integer worker count, or :cpus / “cpus” to auto-detect from Etc.nprocessors. Default: 1.
Public: Object implementing the Verity::Reporter interface that receives lifecycle callbacks. Default: ColoredDotsReporter writing to $stdout.
Public: Test dispatch order for manifest runs: :random (default; shuffled once in the coordinator) or :fingerprint (sorted). A non-nil #shuffle_seed always implies a shuffle, even if test_order is :fingerprint.
Public: Integer RNG seed for shuffled order. When nil and order is random, a seed is chosen, stored here, and printed to stderr (the number only) before workers start.
Public: Optional Array of [absolute_path, Integer line] pairs (from CLI file:line). When non-empty, only tests whose #line matches, or that have an enclosing #group opened on that file:line, are runnable.
42 43 44 |
# File 'lib/verity/configuration.rb', line 42 def manifest_path @manifest_path end |
#reporter ⇒ Object
Public: String path for the SQLite manifest database. Use “:memory:” for an in-process database (single-worker only; cannot be used with parallel workers). Default: “verity/manifest.db” (relative to the process working directory, typically the project root).
Public: Array of glob Strings matched against the working directory to discover test files. Default: [“verity/*/_test.rb”].
Public: Integer worker count, or :cpus / “cpus” to auto-detect from Etc.nprocessors. Default: 1.
Public: Object implementing the Verity::Reporter interface that receives lifecycle callbacks. Default: ColoredDotsReporter writing to $stdout.
Public: Test dispatch order for manifest runs: :random (default; shuffled once in the coordinator) or :fingerprint (sorted). A non-nil #shuffle_seed always implies a shuffle, even if test_order is :fingerprint.
Public: Integer RNG seed for shuffled order. When nil and order is random, a seed is chosen, stored here, and printed to stderr (the number only) before workers start.
Public: Optional Array of [absolute_path, Integer line] pairs (from CLI file:line). When non-empty, only tests whose #line matches, or that have an enclosing #group opened on that file:line, are runnable.
42 43 44 |
# File 'lib/verity/configuration.rb', line 42 def reporter @reporter end |
#shuffle_seed ⇒ Object
Public: String path for the SQLite manifest database. Use “:memory:” for an in-process database (single-worker only; cannot be used with parallel workers). Default: “verity/manifest.db” (relative to the process working directory, typically the project root).
Public: Array of glob Strings matched against the working directory to discover test files. Default: [“verity/*/_test.rb”].
Public: Integer worker count, or :cpus / “cpus” to auto-detect from Etc.nprocessors. Default: 1.
Public: Object implementing the Verity::Reporter interface that receives lifecycle callbacks. Default: ColoredDotsReporter writing to $stdout.
Public: Test dispatch order for manifest runs: :random (default; shuffled once in the coordinator) or :fingerprint (sorted). A non-nil #shuffle_seed always implies a shuffle, even if test_order is :fingerprint.
Public: Integer RNG seed for shuffled order. When nil and order is random, a seed is chosen, stored here, and printed to stderr (the number only) before workers start.
Public: Optional Array of [absolute_path, Integer line] pairs (from CLI file:line). When non-empty, only tests whose #line matches, or that have an enclosing #group opened on that file:line, are runnable.
42 43 44 |
# File 'lib/verity/configuration.rb', line 42 def shuffle_seed @shuffle_seed end |
#test_globs ⇒ Object
Public: String path for the SQLite manifest database. Use “:memory:” for an in-process database (single-worker only; cannot be used with parallel workers). Default: “verity/manifest.db” (relative to the process working directory, typically the project root).
Public: Array of glob Strings matched against the working directory to discover test files. Default: [“verity/*/_test.rb”].
Public: Integer worker count, or :cpus / “cpus” to auto-detect from Etc.nprocessors. Default: 1.
Public: Object implementing the Verity::Reporter interface that receives lifecycle callbacks. Default: ColoredDotsReporter writing to $stdout.
Public: Test dispatch order for manifest runs: :random (default; shuffled once in the coordinator) or :fingerprint (sorted). A non-nil #shuffle_seed always implies a shuffle, even if test_order is :fingerprint.
Public: Integer RNG seed for shuffled order. When nil and order is random, a seed is chosen, stored here, and printed to stderr (the number only) before workers start.
Public: Optional Array of [absolute_path, Integer line] pairs (from CLI file:line). When non-empty, only tests whose #line matches, or that have an enclosing #group opened on that file:line, are runnable.
42 43 44 |
# File 'lib/verity/configuration.rb', line 42 def test_globs @test_globs end |
#test_order ⇒ Object
Public: String path for the SQLite manifest database. Use “:memory:” for an in-process database (single-worker only; cannot be used with parallel workers). Default: “verity/manifest.db” (relative to the process working directory, typically the project root).
Public: Array of glob Strings matched against the working directory to discover test files. Default: [“verity/*/_test.rb”].
Public: Integer worker count, or :cpus / “cpus” to auto-detect from Etc.nprocessors. Default: 1.
Public: Object implementing the Verity::Reporter interface that receives lifecycle callbacks. Default: ColoredDotsReporter writing to $stdout.
Public: Test dispatch order for manifest runs: :random (default; shuffled once in the coordinator) or :fingerprint (sorted). A non-nil #shuffle_seed always implies a shuffle, even if test_order is :fingerprint.
Public: Integer RNG seed for shuffled order. When nil and order is random, a seed is chosen, stored here, and printed to stderr (the number only) before workers start.
Public: Optional Array of [absolute_path, Integer line] pairs (from CLI file:line). When non-empty, only tests whose #line matches, or that have an enclosing #group opened on that file:line, are runnable.
42 43 44 |
# File 'lib/verity/configuration.rb', line 42 def test_order @test_order end |
#worker_count ⇒ Object
Public: String path for the SQLite manifest database. Use “:memory:” for an in-process database (single-worker only; cannot be used with parallel workers). Default: “verity/manifest.db” (relative to the process working directory, typically the project root).
Public: Array of glob Strings matched against the working directory to discover test files. Default: [“verity/*/_test.rb”].
Public: Integer worker count, or :cpus / “cpus” to auto-detect from Etc.nprocessors. Default: 1.
Public: Object implementing the Verity::Reporter interface that receives lifecycle callbacks. Default: ColoredDotsReporter writing to $stdout.
Public: Test dispatch order for manifest runs: :random (default; shuffled once in the coordinator) or :fingerprint (sorted). A non-nil #shuffle_seed always implies a shuffle, even if test_order is :fingerprint.
Public: Integer RNG seed for shuffled order. When nil and order is random, a seed is chosen, stored here, and printed to stderr (the number only) before workers start.
Public: Optional Array of [absolute_path, Integer line] pairs (from CLI file:line). When non-empty, only tests whose #line matches, or that have an enclosing #group opened on that file:line, are runnable.
42 43 44 |
# File 'lib/verity/configuration.rb', line 42 def worker_count @worker_count end |
Class Method Details
.cpus_worker_token?(value) ⇒ Boolean
Internal: Determine whether a value represents the :cpus worker token. Accepts :cpus, :cpu, “cpus”, or “cpu” (case-insensitive).
value - Symbol or String to check.
Returns true if the value is a cpus token.
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/verity/configuration.rb', line 102 def cpus_worker_token?(value) case value when :cpus, :cpu true when String s = value.strip.downcase s == "cpus" || s == "cpu" else false end end |
Instance Method Details
#memory_manifest? ⇒ Boolean
Public: Check whether the manifest is configured as in-memory.
Returns true when manifest_path is “:memory:”.
84 85 86 |
# File 'lib/verity/configuration.rb', line 84 def memory_manifest? manifest_path == ":memory:" end |
#resolved_worker_count ⇒ Object
Public: Resolve worker_count to an Integer, expanding :cpus to the number of available processors.
Returns a positive Integer. Raises ArgumentError if the value cannot be resolved or is less than 1.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/verity/configuration.rb', line 64 def resolved_worker_count n = if self.class.cpus_worker_token?(worker_count) [Etc.nprocessors, 1].max else begin Integer(worker_count) rescue TypeError, ArgumentError raise ArgumentError, "worker_count must be a positive Integer or :cpus / \"cpus\" (got #{worker_count.inspect})" end end raise ArgumentError, "worker_count must be >= 1 (got #{n})" if n < 1 n end |
#set_defaults! ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/verity/configuration.rb', line 49 def set_defaults! @manifest_path = "verity/manifest.db" @test_globs = ["verity/**/*_test.rb"] @worker_count = :cpus @reporter = Verity::Reporters::ColoredDotsReporter.new($stdout) @test_order = :random @shuffle_seed = nil @location_filters = [] end |
#test_files ⇒ Object
Public: Expand test_globs into a sorted, deduplicated list of file paths.
Returns a sorted Array of String file paths.
91 92 93 |
# File 'lib/verity/configuration.rb', line 91 def test_files test_globs.flat_map { |pattern| Dir.glob(pattern) }.uniq.sort end |