Module: Kumi::Dev::GoldenV2
- Defined in:
- lib/kumi/dev/golden_v2.rb
Defined Under Namespace
Classes: Representation, Runner
Constant Summary collapse
- REPRESENTATIONS =
[ Representation.new(name: "ast", extension: "txt", generator_method: :generate_ast), Representation.new(name: "input_plan", extension: "txt", generator_method: :generate_input_plan), Representation.new(name: "nast", extension: "txt", generator_method: :generate_nast), Representation.new(name: "snast", extension: "txt", generator_method: :generate_snast), Representation.new(name: "dfir", extension: "txt", generator_method: :generate_dfir), Representation.new(name: "dfir_optimized", extension: "txt", generator_method: :generate_dfir_optimized), Representation.new(name: "vecir", extension: "txt", generator_method: :generate_vecir), Representation.new(name: "loopir", extension: "txt", generator_method: :generate_loopir), Representation.new(name: "schema_ruby", extension: "rb", generator_method: :generate_schema_ruby), Representation.new(name: "schema_javascript", extension: "mjs", generator_method: :generate_schema_javascript), # Executes the generated Ruby + JS against input.json, snapshots the # outputs, and asserts Ruby == JS. No-ops (nil) for schemas without an # input.json. This is the runtime + bit-identical-parity coverage. Representation.new(name: "runtime", extension: "json", generator_method: :generate_runtime) ].freeze
- GROUPS =
{ "frontend" => %w[ast input_plan nast snast], "df" => %w[dfir dfir_optimized], "vec" => %w[vecir], "loop" => %w[loopir], "codegen" => %w[schema_ruby schema_javascript], "runtime" => %w[runtime], "all" => REPRESENTATIONS.map(&:name) }.freeze
Class Method Summary collapse
- .diff!(*names, reprs: nil, base_dir: "golden", io: $stdout) ⇒ Object
- .list(base_dir: "golden", io: $stdout) ⇒ Object
- .normalize_names(raw) ⇒ Object
- .normalize_repr_tokens(raw) ⇒ Object
-
.precompile_schemas! ⇒ Object
Precompile shared schemas so their syntax trees are available to import goldens (their JS needs the generated shared modules).
- .reprs(io: $stdout) ⇒ Object
- .update!(*names, reprs: nil, base_dir: "golden", io: $stdout) ⇒ Object
- .verify!(*names, reprs: nil, base_dir: "golden", io: $stdout) ⇒ Object
Class Method Details
.diff!(*names, reprs: nil, base_dir: "golden", io: $stdout) ⇒ Object
78 79 80 |
# File 'lib/kumi/dev/golden_v2.rb', line 78 def diff!(*names, reprs: nil, base_dir: "golden", io: $stdout) Runner.new(base_dir:, io:).diff(names: normalize_names(names), reprs:) end |
.list(base_dir: "golden", io: $stdout) ⇒ Object
62 63 64 |
# File 'lib/kumi/dev/golden_v2.rb', line 62 def list(base_dir: "golden", io: $stdout) Runner.new(base_dir:, io:).list_schemas end |
.normalize_names(raw) ⇒ Object
89 90 91 92 |
# File 'lib/kumi/dev/golden_v2.rb', line 89 def normalize_names(raw) names = Array(raw).flatten.compact.map(&:to_s).reject(&:empty?) names.empty? ? nil : names end |
.normalize_repr_tokens(raw) ⇒ Object
82 83 84 85 86 87 |
# File 'lib/kumi/dev/golden_v2.rb', line 82 def normalize_repr_tokens(raw) Array(raw) .flat_map { |entry| entry.to_s.split(",") } .map(&:strip) .reject(&:empty?) end |
.precompile_schemas! ⇒ Object
Precompile shared schemas so their syntax trees are available to import goldens (their JS needs the generated shared modules). No-op when the shared schemas aren’t loaded.
12 13 14 15 16 17 18 19 |
# File 'lib/kumi/dev/golden_v2.rb', line 12 def self.precompile_schemas! return unless defined?(Kumi::TestSharedSchemas) Kumi::TestSharedSchemas.constants.each do |const| mod = Kumi::TestSharedSchemas.const_get(const) mod.runner if mod.is_a?(Module) && mod.respond_to?(:runner) end end |
.reprs(io: $stdout) ⇒ Object
66 67 68 |
# File 'lib/kumi/dev/golden_v2.rb', line 66 def reprs(io: $stdout) Runner.new(io:).list_representations end |