mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-23 19:31:44 +00:00
tests: add test case for mkvmerge's JSON identification output
This commit is contained in:
parent
73deeabf02
commit
f1e4055e3e
@ -357,3 +357,4 @@ T_508splitting_by_parts_with_segment_linking:existence0-true-true-true-existence
|
||||
T_509rerender_track_headers_chapters_attachments:1ad646e49e231108ed8b5d1c6dce8b1c:passed:20151115-230226:0.287840782
|
||||
T_510propedit_add_attachments_without_meta_seek_present:770103c238a0f502c9ec55f0599d8544:passed:20151121-101043:0.070892905
|
||||
T_511propedit_ensure_seek_head_exists_at_front:20f53afd94e39f5bbf3f1091eefbe31d:passed:20151129-194025:0.152563199
|
||||
T_512json_identification:231941d7da79ca0eab3f8f5cd2a66e3c-ok-793233ac68c8c0af280898ec33aa6e05-ok-06dde7e7bcbec8fc9cd8f101662906dd-ok-8797f2adcd279428afa4834d93f0be34-ok-90de565f88767c95673e7b2d5ecf85d9-ok-d9c71aaad86e27979d1b5bf71cb1143f-ok-acddfd1324aa62e187f8d4023f24ec2a-ok-6c20b604bd1652766e442bf52f284a18-ok-cdf24911aad494277fd2a032affdf498-ok-dd2d4b55d2fe3f56c697371325b7d8e9-ok-7dc0464e838aa187128964387b9adcba-ok-6d365dd230156e30bfe3d60a3c6c24dc-ok-7fada0edcbd9818093ba57b78ae5706a-ok-ca5e66fad9ed5af2d672c4432cbded48-ok-b859b2500847aca0ac91918fdc8eae70-ok:passed:20151207-223859:6.280036064
|
||||
|
41
tests/test-512json_identification.rb
Executable file
41
tests/test-512json_identification.rb
Executable file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/ruby -w
|
||||
|
||||
files = %w{
|
||||
data/aac/v.aac
|
||||
data/ac3/v.ac3
|
||||
data/ssa-ass/fonts.ass
|
||||
data/vobsub/ally1-short.idx
|
||||
data/ts/timecode-overflow.m2ts
|
||||
data/mp4/aac_encoder_delay_sample.m4a
|
||||
data/mp4/o12-short.m4v
|
||||
data/mkv/complex.mkv
|
||||
data/pcm/big-endian.mka
|
||||
data/ogg/video-1.1.ogv
|
||||
data/vc1/MC.track_4113.vc1
|
||||
data/vob/pcm-48kHz-2ch-16bit.vob
|
||||
data/webm/yt3.webm
|
||||
data/wp/with-correction.wv
|
||||
data/wp/with-correction.wvc
|
||||
}
|
||||
|
||||
describe "mkvmerge / JSON identification format"
|
||||
|
||||
test "identification and validation" do
|
||||
hashes = []
|
||||
|
||||
files.each do |file|
|
||||
output, _ = identify file, :format => :json
|
||||
output = output.join ''
|
||||
|
||||
valid, errors = json_schema_identification.validate(JSON.load(output))
|
||||
|
||||
if !valid
|
||||
puts " JSON validation errors in #{file}:"
|
||||
puts errors.join("\n")
|
||||
end
|
||||
|
||||
hashes += [ output.md5, valid ? "ok" : "invalid" ]
|
||||
end
|
||||
|
||||
hashes.join '-'
|
||||
end
|
@ -1,4 +1,6 @@
|
||||
class SimpleTest
|
||||
@@json_schema_identification = nil
|
||||
|
||||
EXIT_CODE_ALIASES = {
|
||||
:success => 0,
|
||||
:warning => 1,
|
||||
@ -220,9 +222,11 @@ class SimpleTest
|
||||
options = args.extract_options!
|
||||
fail ArgumentError if args.empty?
|
||||
|
||||
verbose = options[:verbose].nil? ? true : options[:verbose]
|
||||
verbose = verbose ? "-verbose" : ""
|
||||
command = "../src/mkvmerge --identify#{verbose} --engage no_variable_data #{args.first}"
|
||||
verbose = !options[:verbose].nil? ? options[:verbose] : true
|
||||
format = options[:format] ? options[:format].to_s.downcase.gsub(/_/, '-') : verbose ? 'verbose-text' : 'text'
|
||||
|
||||
command = "../src/mkvmerge --identify --identification-format #{format} --engage no_variable_data #{args.first}"
|
||||
|
||||
self.sys command, :exit_code => options[:exit_code]
|
||||
end
|
||||
|
||||
@ -289,4 +293,20 @@ class SimpleTest
|
||||
show_message " Failed. Reason: #{reason}"
|
||||
raise "test failed"
|
||||
end
|
||||
|
||||
def json_schema_identification
|
||||
return @@json_schema_identification if @@json_schema_identification
|
||||
|
||||
require "json_schema"
|
||||
|
||||
json_store = JsonSchema::DocumentStore.new
|
||||
parser = JsonSchema::Parser.new
|
||||
expander = JsonSchema::ReferenceExpander.new
|
||||
schema = parser.parse JSON.load(File.read("../doc/mkvmerge-identification-output-schema.json"))
|
||||
|
||||
expander.expand(schema, store: json_store)
|
||||
json_store.add_schema schema
|
||||
|
||||
@@json_schema_identification = schema
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user