From df79a16c64ce79da2b2fac0405b681c51df6c5d0 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 10 Mar 2018 13:49:28 +0100 Subject: [PATCH] tests: utility function for reading doc type (read) version elements --- tests/test-371doc_and_read_version.rb | 4 +--- ...t-487matroska_version_and_read_version_with_opus.rb | 4 +--- tests/test.d/simple_test.rb | 10 +++++++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/test-371doc_and_read_version.rb b/tests/test-371doc_and_read_version.rb index 4c09abb8e..466d105c7 100755 --- a/tests/test-371doc_and_read_version.rb +++ b/tests/test-371doc_and_read_version.rb @@ -18,10 +18,8 @@ test "all versions" do command = command.join ' ' merge command - output = info(tmp, :output => :return).join('') - type_version = /Document type version:\s+(\d+)/.match(output) ? $1 : '' - type_read_version = /Document type read version:\s+(\d+)/.match(output) ? $1 : '' + type_version, type_read_version = get_doc_type_versions(tmp) hashes << "#{type_version}+#{type_read_version}" end diff --git a/tests/test-487matroska_version_and_read_version_with_opus.rb b/tests/test-487matroska_version_and_read_version_with_opus.rb index 611037008..712e38bf7 100755 --- a/tests/test-487matroska_version_and_read_version_with_opus.rb +++ b/tests/test-487matroska_version_and_read_version_with_opus.rb @@ -19,10 +19,8 @@ test "all versions" do command = command.join ' ' merge command - output = info(tmp, :output => :return).join('') - type_version = /Document type version:\s+(\d+)/.match(output) ? $1 : '' - type_read_version = /Document type read version:\s+(\d+)/.match(output) ? $1 : '' + type_version, type_read_version = get_doc_type_versions(tmp) hashes << "#{type_version}+#{type_read_version}" end diff --git a/tests/test.d/simple_test.rb b/tests/test.d/simple_test.rb index 59090682d..9e2d95c8d 100644 --- a/tests/test.d/simple_test.rb +++ b/tests/test.d/simple_test.rb @@ -268,7 +268,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], :no_result => options[:no_result] + self.sys command, :exit_code => options[:exit_code], :no_result => options[:no_result], :dont_record_command => options[:dont_record_command] end def extract *args @@ -360,4 +360,12 @@ class SimpleTest end. join("/") end + + def get_doc_type_versions file_name + output = info(file_name, :output => :return, :dont_record_command => true).join('') + type_version = /Document type version:\s+(\d+)/.match(output) ? $1 : nil + type_read_version = /Document type read version:\s+(\d+)/.match(output) ? $1 : nil + + return type_version, type_read_version + end end