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!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 33 | ok(-f catfile($output, 'bih.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 34 | like($protocol, qr!bio from regex!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 35 | ok(-f catfile($output, 'bio.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 36 | like($protocol, qr!bio-pub from regex!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 37 | ok(-f catfile($output, 'bio-pub.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 38 | like($protocol, qr!l from regex!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 39 | ok(-f catfile($output, 'l.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 40 | like($protocol, qr!dpa from regex!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 41 | ok(-f catfile($output, 'dpa.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 42 | like($protocol, qr!fsp from regex!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 43 | ok(-f catfile($output, 'fsp.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 44 | like($protocol, qr!fsp-pub from regex!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 45 | ok(-f catfile($output, 'fsp-pub.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 46 | like($protocol, qr!kjl from regex!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 47 | ok(-f catfile($output, 'kjl.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 48 | like($protocol, qr!thm-lit from regex!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 49 | ok(-f catfile($output, 'thm-lit.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 50 | like($protocol, qr!wxx11 from regex!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 51 | ok(-f catfile($output, 'wxx11.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 52 | like($protocol, qr!zca from regex!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 53 | ok(-f catfile($output, 'zca.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 54 | like($protocol, qr!list2 from def-file!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 55 | ok(-f catfile($output, 'list2.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 56 | like($protocol, qr!list5 from def-file!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 57 | ok(-f catfile($output, 'list5.jsonld')); |
Akron | b31321e | 2024-07-18 11:17:46 +0200 | [diff] [blame] | 58 | like($protocol, qr!misc-lit from regex!); |
Akron | caf9e44 | 2024-07-26 12:19:15 +0200 | [diff] [blame^] | 59 | ok(-f catfile($output, 'misc-lit.jsonld')); |
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 | |