tests: mark certain commands as not to produce a hash result

This is used by the controller to determine which commands to prefix
with (*) markers in case of test failure.
This commit is contained in:
Moritz Bunkus 2017-08-12 09:59:23 +02:00
parent 9282f65953
commit 932fc8f8bd
7 changed files with 35 additions and 24 deletions

View File

@ -13,7 +13,7 @@ test "extraction" do
end
test "propedit" do
sys "cp #{file} #{tmp}"
cp file, tmp
propedit tmp, "--replace-attachment '=0:data/text/chap1.txt'"
hash_tmp
end

View File

@ -3,7 +3,7 @@
describe "mkvpropedit / create voids for 130 bytes long gaps"
test "propedit" do
sys "cp data/mkv/propedit-gaps-130-bytes.mkv #{tmp}"
cp "data/mkv/propedit-gaps-130-bytes.mkv", tmp
propedit tmp, "--edit track:s1 --set flag-default=0"
hash_tmp
end

View File

@ -4,7 +4,7 @@
describe "mkvpropedit / changing track properties and tags for the same track simultaneously"
test "tags and props" do
merge "data/avi/v.avi", :keep_tmp => true
merge "data/avi/v.avi", :keep_tmp => true, :no_result => true
propedit tmp, "--tags track:v1:data/text/tags-nested-simple.xml -e track:v1 --set display-width=1234"
hash_tmp
end

View File

@ -8,7 +8,7 @@ def args *arrays
end
test "set all attributes" do
merge "--no-audio data/avi/v.avi"
merge "--no-audio data/avi/v.avi", :no_result => true
src = tmp
colour_attributes = [
@ -43,19 +43,19 @@ test "set all attributes" do
hashes = []
work = "#{src}-1"
sys "cp #{src} #{work}"
cp src, work
propedit work, "--edit track:v1 --set pixel-width=1024"
hashes << hash_file(work)
sys "cp #{src} #{work}"
cp src, work
propedit work, "--edit track:v1 --set pixel-width=1024 #{args(colour_attributes)}"
hashes << hash_file(work)
sys "cp #{src} #{work}"
cp src, work
propedit work, "--edit track:v1 --set pixel-width=1024 #{args(colour_mastering_meta_attributes)}"
hashes << hash_file(work)
sys "cp #{src} #{work}"
cp src, work
propedit work, "--edit track:v1 --set pixel-width=1024 #{args(colour_attributes, colour_mastering_meta_attributes)}"
hashes << hash_file(work)
@ -63,28 +63,28 @@ test "set all attributes" do
end
test "delete attributes" do
merge "--no-audio --max-frame-light 0:41 --min-luminance 0:42 data/avi/v.avi"
merge "--no-audio --max-frame-light 0:41 --min-luminance 0:42 data/avi/v.avi", :no_result => true
hashes = []
src = tmp
work = "#{src}-1"
sys "cp #{src} #{work}"
cp src, work
propedit work, "--edit track:v1 --delete language"
hashes << hash_file(work)
# sys "mkvinfo #{work} >&2"
sys "cp #{src} #{work}"
cp src, work
propedit work, "--edit track:v1 --delete language --delete min-luminance"
hashes << hash_file(work)
# sys "mkvinfo #{work} >&2"
sys "cp #{src} #{work}"
cp src, work
propedit work, "--edit track:v1 --delete language --delete max-frame-light"
hashes << hash_file(work)
# sys "mkvinfo #{work} >&2"
sys "cp #{src} #{work}"
cp src, work
propedit work, "--edit track:v1 --delete language --delete max-frame-light --delete min-luminance"
hashes << hash_file(work)
# sys "mkvinfo #{work} >&2"

View File

@ -126,9 +126,13 @@ class Controller
expected_results = @results.hash?(class_name).split(/-/)
actual_results = result.split(/-/)
idx = 0
current_test.commands.each_with_index do |command, idx|
msg += " " + ((expected_results[idx] != actual_results[idx]) ? "(*)" : " ") + " #{command}\n"
current_test.commands.each do |command|
command = { :command => command } unless command.is_a?(Hash)
prefix = !command[:no_result] && (expected_results[idx] != actual_results[idx]) ? "(*)" : " "
msg += " #{prefix} #{command[:command]}\n"
idx += 1 unless command[:no_result]
end
if (update_failed)

View File

@ -235,7 +235,7 @@ class SimpleTest
output = options[:output] || self.tmp
command = "../src/mkvmerge --engage no_variable_data -o #{output} #{args.first}"
self.sys command, :exit_code => options[:exit_code]
self.sys command, :exit_code => options[:exit_code], :no_result => options[:no_result]
end
def identify *args
@ -247,7 +247,7 @@ class SimpleTest
command = "../src/mkvmerge --identify --identification-format #{format} --engage no_variable_data #{args.first}"
self.sys command, :exit_code => options[:exit_code]
self.sys command, :exit_code => options[:exit_code], :no_result => options[:no_result]
end
def identify_json *args
@ -256,7 +256,7 @@ class SimpleTest
command = "../src/mkvmerge --identify --identification-format json --engage no_variable_data #{args.first}"
output, _ = self.sys(command, :exit_code => options[:exit_code])
output, _ = self.sys(command, :exit_code => options[:exit_code], :no_result => options[:no_result])
return JSON.load(output.join(''))
end
@ -269,7 +269,7 @@ class SimpleTest
output = "> #{output}" unless %r{^[>\|]}.match(output)
output = '' if options[:output] == :return
command = "../src/mkvinfo --engage no_variable_data --ui-language en_US #{args.first} #{output}"
self.sys command, :exit_code => options[:exit_code]
self.sys command, :exit_code => options[:exit_code], :no_result => options[:no_result]
end
def extract *args
@ -279,7 +279,7 @@ class SimpleTest
mode = options[:mode] || :tracks
command = "../src/mkvextract --engage no_variable_data #{mode} #{args.first} " + options.keys.select { |key| key.is_a?(Numeric) }.sort.collect { |key| "#{key}:#{options[key]}" }.join(' ')
self.sys command, :exit_code => options[:exit_code]
self.sys command, :exit_code => options[:exit_code], :no_result => options[:no_result]
end
def propedit file_name, *args
@ -287,7 +287,7 @@ class SimpleTest
fail ArgumentError if args.empty?
command = "../src/mkvpropedit --engage no_variable_data #{file_name} #{args.first}"
*result = self.sys command, :exit_code => options[:exit_code]
*result = self.sys command, :exit_code => options[:exit_code], :no_result => options[:no_result]
self.sys "../src/tools/ebml_validator -M #{file_name}", dont_record_command: true if FileTest.exists?("../src/tools/ebml_validator")
@ -300,7 +300,7 @@ class SimpleTest
fail ArgumentError if args.empty?
command = args.shift
@commands << command unless options[:dont_record_command]
@commands << { :command => command, :no_result => options[:no_result] } unless options[:dont_record_command]
if !%r{>}.match command
temp_file = Tempfile.new('mkvtoolnix-test-output')
@ -320,6 +320,13 @@ class SimpleTest
return exit_code
end
def cp source, target, *args
options = args.extract_options!
options[:no_result] = true unless options.key?(:no_result)
sys "cp '#{source}' '#{target}'", options
end
def error reason
show_message " Failed. Reason: #{reason}"
raise "test failed"

View File

@ -61,8 +61,8 @@ class Test
def sys(command, *arg)
options = arg.extract_options!
@commands << command unless options[:dont_record_command]
@debug_commands << command unless options[:dont_record_command]
@commands << { :command => command, :no_result => options[:no_result] } unless options[:dont_record_command]
@debug_commands << command unless options[:dont_record_command]
command << " >/dev/null 2>/dev/null " unless (/>/.match(command))
puts "COMMAND #{command}" if ENV['DEBUG']