abort("Expected Ruby 3.4+, but got #{RUBY_VERSION}.") if RUBY_VERSION < '3.4.0'
require 'csv'
def edky(*args) = `cargo run --quiet --features=cli -- #{args.map(&:to_s).map(&:inspect).join(' ')}`.split("\n")
FORMATS = edky(:list).map(&:to_sym).freeze
SAMPLES = CSV.table('../data/samples.csv')
.inject({}) { |hash, row| hash[row[:format].to_sym] = row[:sample]; hash }
.freeze
task :default => :check
desc "Check all #{FORMATS.size}×#{FORMATS.size}=#{FORMATS.size**2} format conversions"
task check: %w[../data/samples.csv] do |t|
failures = []
FORMATS.each do |from|
FORMATS.each do |to|
input = SAMPLES[from]
args = [:convert, "--from", from, "--to", to, input]
output = edky(*args)
if $?.success? && output.size == 1 && output[0] == SAMPLES[to]
p [:Ok, from, to, *output]
else
p [:Err, from, to, *output]
failures << [from, to]
end
end
end
abort("Failures: #{failures.inspect}") unless failures.empty?
end