Akron | a3f74f5 | 2024-07-17 17:18:17 +0200 | [diff] [blame] | 1 | #!/usr/bin/env perl |
| 2 | use strict; |
| 3 | use warnings; |
| 4 | use Test::More; |
| 5 | use File::Basename; |
| 6 | use File::Spec::Functions; |
| 7 | use Data::Dumper; |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame^] | 8 | use File::Temp qw/tempdir/; |
Akron | a3f74f5 | 2024-07-17 17:18:17 +0200 | [diff] [blame] | 9 | |
| 10 | use Test::Output; |
| 11 | use Mojo::JSON 'decode_json'; |
| 12 | |
| 13 | my $script = catfile(dirname(__FILE__), '..', 'script', 'cosmasvc2koralquery'); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame^] | 14 | my $copysrc = catdir(dirname(__FILE__), 'data'); |
Akron | a3f74f5 | 2024-07-17 17:18:17 +0200 | [diff] [blame] | 15 | my $list1 = catfile(dirname(__FILE__), 'data', 'list-example.ls'); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame^] | 16 | my $output = tempdir( CLEANUP => 1 ); |
| 17 | |
| 18 | my @call = ($script, 'list', $list1, '--copy-src', $copysrc, '--output', $output); |
Akron | a3f74f5 | 2024-07-17 17:18:17 +0200 | [diff] [blame] | 19 | |
| 20 | # Check STDOUT |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame^] | 21 | stderr_like( |
Akron | a3f74f5 | 2024-07-17 17:18:17 +0200 | [diff] [blame] | 22 | sub { |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame^] | 23 | system(@call); |
Akron | a3f74f5 | 2024-07-17 17:18:17 +0200 | [diff] [blame] | 24 | }, |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame^] | 25 | qr!redabs is not yet supported!, |
Akron | a3f74f5 | 2024-07-17 17:18:17 +0200 | [diff] [blame] | 26 | "check stdout" |
| 27 | ); |
| 28 | |
| 29 | # Check JSON |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame^] | 30 | my $protocol = join('', `@call`); |
| 31 | |
| 32 | like($protocol, qr!bih from regex!); |
| 33 | ok(-f catfile($output, 'bih.json')); |
| 34 | like($protocol, qr!bio from regex!); |
| 35 | ok(-f catfile($output, 'bio.json')); |
| 36 | like($protocol, qr!bio-pub from regex!); |
| 37 | ok(-f catfile($output, 'bio-pub.json')); |
| 38 | like($protocol, qr!l from regex!); |
| 39 | ok(-f catfile($output, 'l.json')); |
| 40 | like($protocol, qr!dpa from regex!); |
| 41 | ok(-f catfile($output, 'dpa.json')); |
| 42 | like($protocol, qr!fsp from regex!); |
| 43 | ok(-f catfile($output, 'fsp.json')); |
| 44 | like($protocol, qr!fsp-pub from regex!); |
| 45 | ok(-f catfile($output, 'fsp-pub.json')); |
| 46 | like($protocol, qr!kjl from regex!); |
| 47 | ok(-f catfile($output, 'kjl.json')); |
| 48 | like($protocol, qr!thm-lit from regex!); |
| 49 | ok(-f catfile($output, 'thm-lit.json')); |
| 50 | like($protocol, qr!wxx11 from regex!); |
| 51 | ok(-f catfile($output, 'wxx11.json')); |
| 52 | like($protocol, qr!zca from regex!); |
| 53 | ok(-f catfile($output, 'zca.json')); |
| 54 | like($protocol, qr!list2 from def-file!); |
| 55 | ok(-f catfile($output, 'list2.json')); |
| 56 | like($protocol, qr!list5 from def-file!); |
| 57 | ok(-f catfile($output, 'list5.json')); |
| 58 | like($protocol, qr!misc-lit from regex!); |
| 59 | ok(-f catfile($output, 'misc-lit.json')); |
Akron | a3f74f5 | 2024-07-17 17:18:17 +0200 | [diff] [blame] | 60 | |
| 61 | done_testing; |
| 62 | __END__ |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame^] | 63 | |
| 64 | |