| 1 |
|
| 2 |
# Copyright (c) 2021-2025, PostgreSQL Global Development Group |
| 3 |
|
| 4 |
# Test the incremental JSON parser with semantic routines, and compare the |
| 5 |
# output with the expected output. |
| 6 |
|
| 7 |
use strict; |
| 8 |
use warnings FATAL => 'all'; |
| 9 |
|
| 10 |
use PostgreSQL::Test::Utils; |
| 11 |
use Test::More; |
| 12 |
use FindBin; |
| 13 |
|
| 14 |
use File::Temp qw(tempfile); |
| 15 |
|
| 16 |
my $test_file = "$FindBin::RealBin/../tiny.json"; |
| 17 |
my $test_out = "$FindBin::RealBin/../tiny.out"; |
| 18 |
|
| 19 |
my @exes = ( |
| 20 |
[ "test_json_parser_incremental", ], |
| 21 |
[ "test_json_parser_incremental", "-o", ], |
| 22 |
[ "test_json_parser_incremental_shlib", ], |
| 23 |
[ "test_json_parser_incremental_shlib", "-o", ]); |
| 24 |
|
| 25 |
foreach my $exe (@exes) |
| 26 |
{ |
| 27 |
note "testing executable @$exe"; |
| 28 |
|
| 29 |
my ($stdout, $stderr) = run_command([ @$exe, "-s", $test_file ]); |
| 30 |
|
| 31 |
is($stderr, "", "no error output"); |
| 32 |
|
| 33 |
my $dir = PostgreSQL::Test::Utils::tempdir; |
| 34 |
my ($fh, $fname) = tempfile(DIR => $dir); |
| 35 |
|
| 36 |
print $fh $stdout, "\n"; |
| 37 |
|
| 38 |
close($fh); |
| 39 |
|
| 40 |
my @diffopts = ("-u"); |
| 41 |
push(@diffopts, "--strip-trailing-cr") if $windows_os; |
| 42 |
($stdout, $stderr) = |
| 43 |
run_command([ "diff", @diffopts, $fname, $test_out ]); |
| 44 |
|
| 45 |
is($stdout, "", "no output diff"); |
| 46 |
is($stderr, "", "no diff error"); |
| 47 |
} |
| 48 |
|
| 49 |
done_testing(); |