at master 1.4 kB view raw
1import ../make-test-python.nix ( 2 { pkgs, ... }: 3 { 4 5 name = "timidity-with-vorbis"; 6 7 nodes.machine = 8 { pkgs, ... }: 9 { 10 environment.systemPackages = with pkgs; [ 11 (timidity.override { enableVorbis = true; }) 12 ffmpeg # # for `ffprobe` 13 ]; 14 }; 15 16 testScript = '' 17 import json 18 19 start_all() 20 21 ## TiMidity++ is around and it claims to support Ogg Vorbis. 22 machine.succeed("command -v timidity") 23 machine.succeed("timidity --help | grep 'Ogg Vorbis'") 24 25 ## TiMidity++ manages to process a MIDI input and produces an Ogg Vorbis 26 ## output file. NOTE: the `timidity` CLI succeeds even when the input file 27 ## does not exist; hence our test for the output file's existence. 28 machine.succeed("cp ${./tam-lin.midi} tam-lin.midi") 29 machine.succeed("timidity -Ov tam-lin.midi && test -e tam-lin.ogg") 30 31 ## The output file has the expected characteristics. 32 metadata_as_text = machine.succeed("ffprobe -show_format -print_format json -i tam-lin.ogg") 33 metadata = json.loads(metadata_as_text) 34 assert metadata['format']['format_name'] == 'ogg', \ 35 f"expected 'format_name' to be 'ogg', got '{metadata['format']['format_name']}'" 36 assert 37 <= float(metadata['format']['duration']) <= 38, \ 37 f"expected 'duration' to be between 37s and 38s, got {metadata['format']['duration']}s" 38 ''; 39 } 40)