<commit_before>use strict;
use warnings;

use Config;
use PostgresNode;
use TestLib;
use Test::More tests => 70;

my $tempdir       = TestLib::tempdir;
my $tempdir_short = TestLib::tempdir_short;

#########################################
# Basic checks

program_help_ok('pg_dump');
program_version_ok('pg_dump');
program_options_handling_ok('pg_dump');

program_help_ok('pg_restore');
program_version_ok('pg_restore');
program_options_handling_ok('pg_restore');

program_help_ok('pg_dumpall');
program_version_ok('pg_dumpall');
program_options_handling_ok('pg_dumpall');

#########################################
# Test various invalid options and disallowed combinations
# Doesn't require a PG instance to be set up, so do this first.

command_fails_like(
	[ 'pg_dump', 'qqq', 'abc' ],
	qr/\Qpg_dump: too many command-line arguments (first is "abc")\E/,
	'pg_dump: too many command-line arguments (first is "asd")');

command_fails_like(
	[ 'pg_restore', 'qqq', 'abc' ],
	qr/\Qpg_restore: too many command-line arguments (first is "abc")\E/,
	'pg_restore too many command-line arguments (first is "abc")');

command_fails_like(
	[ 'pg_dumpall', 'qqq', 'abc' ],
	qr/\Qpg_dumpall: too many command-line arguments (first is "qqq")\E/,
	'pg_dumpall: too many command-line arguments (first is "qqq")');

command_fails_like(
	[ 'pg_dump', '-s', '-a' ],
qr/\Qpg_dump: options -s\/--schema-only and -a\/--data-only cannot be used together\E/,
'pg_dump: options -s/--schema-only and -a/--data-only cannot be used together'
);

command_fails_like(
	[ 'pg_restore', '-s', '-a' ],
qr/\Qpg_restore: options -s\/--schema-only and -a\/--data-only cannot be used together\E/,
'pg_restore: options -s/--schema-only and -a/--data-only cannot be used together'
);

command_fails_like(
	[ 'pg_restore', '-d', 'xxx', '-f', 'xxx' ],
qr/\Qpg_restore: options -d\/--dbname and -f\/--file cannot be used together\E/,
	'pg_restore: options -d/--dbname and -f/--file cannot be used together');

command_fails_like(
	[ 'pg_dump', '-c', '-a' ],
qr/\Qpg_dump: options -c\/--clean and -a\/--data-only cannot be used together\E/,
	'pg_dump: options -c/--clean and -a/--data-only cannot be used together');

command_fails_like(
	[ 'pg_restore', '-c', '-a' ],
qr/\Qpg_restore: options -c\/--clean and -a\/--data-only cannot be used together\E/,
'pg_restore: options -c/--clean and -a/--data-only cannot be used together');

command_fails_like(
	[ 'pg_dump', '--inserts', '-o' ],
qr/\Qpg_dump: options --inserts\/--column-inserts and -o\/--oids cannot be used together\E/,
'pg_dump: options --inserts/--column-inserts and -o/--oids cannot be used together'
);

command_fails_like(
	[ 'pg_dump', '--if-exists' ],
	qr/\Qpg_dump: option --if-exists requires option -c\/--clean\E/,
	'pg_dump: option --if-exists requires option -c/--clean');

command_fails_like(
	[ 'pg_dump', '-j' ],
	qr/\Qpg_dump: option requires an argument -- 'j'\E/,
	'pg_dump: option requires an argument -- \'j\'');

command_fails_like(
	[ 'pg_dump', '-j3' ],
	qr/\Qpg_dump: parallel backup only supported by the directory format\E/,
	'pg_dump: parallel backup only supported by the directory format');

command_fails_like(
	[ 'pg_dump', '-j', '-1' ],
	qr/\Qpg_dump: invalid number of parallel jobs\E/,
	'pg_dump: invalid number of parallel jobs');

command_fails_like(
	[ 'pg_dump', '-F', 'garbage' ],
	qr/\Qpg_dump: invalid output format\E/,
	'pg_dump: invalid output format');

command_fails_like(
	[ 'pg_restore', '-j', '-1' ],
	qr/\Qpg_restore: invalid number of parallel jobs\E/,
	'pg_restore: invalid number of parallel jobs');

command_fails_like(
	[ 'pg_restore', '--single-transaction', '-j3' ],
qr/\Qpg_restore: cannot specify both --single-transaction and multiple jobs\E/,
	'pg_restore: cannot specify both --single-transaction and multiple jobs');

command_fails_like(<commit_msg>pg_dump: Remove "option requires an argument -- j" test<commit_after>use strict;
use warnings;

use Config;
use PostgresNode;
use TestLib;
use Test::More tests => 70;

my $tempdir       = TestLib::tempdir;
my $tempdir_short = TestLib::tempdir_short;

#########################################
# Basic checks

program_help_ok('pg_dump');
program_version_ok('pg_dump');
program_options_handling_ok('pg_dump');

program_help_ok('pg_restore');
program_version_ok('pg_restore');
program_options_handling_ok('pg_restore');

program_help_ok('pg_dumpall');
program_version_ok('pg_dumpall');
program_options_handling_ok('pg_dumpall');

#########################################
# Test various invalid options and disallowed combinations
# Doesn't require a PG instance to be set up, so do this first.

command_fails_like(
	[ 'pg_dump', 'qqq', 'abc' ],
	qr/\Qpg_dump: too many command-line arguments (first is "abc")\E/,
	'pg_dump: too many command-line arguments (first is "asd")');

command_fails_like(
	[ 'pg_restore', 'qqq', 'abc' ],
	qr/\Qpg_restore: too many command-line arguments (first is "abc")\E/,
	'pg_restore too many command-line arguments (first is "abc")');

command_fails_like(
	[ 'pg_dumpall', 'qqq', 'abc' ],
	qr/\Qpg_dumpall: too many command-line arguments (first is "qqq")\E/,
	'pg_dumpall: too many command-line arguments (first is "qqq")');

command_fails_like(
	[ 'pg_dump', '-s', '-a' ],
qr/\Qpg_dump: options -s\/--schema-only and -a\/--data-only cannot be used together\E/,
'pg_dump: options -s/--schema-only and -a/--data-only cannot be used together'
);

command_fails_like(
	[ 'pg_restore', '-s', '-a' ],
qr/\Qpg_restore: options -s\/--schema-only and -a\/--data-only cannot be used together\E/,
'pg_restore: options -s/--schema-only and -a/--data-only cannot be used together'
);

command_fails_like(
	[ 'pg_restore', '-d', 'xxx', '-f', 'xxx' ],
qr/\Qpg_restore: options -d\/--dbname and -f\/--file cannot be used together\E/,
	'pg_restore: options -d/--dbname and -f/--file cannot be used together');

command_fails_like(
	[ 'pg_dump', '-c', '-a' ],
qr/\Qpg_dump: options -c\/--clean and -a\/--data-only cannot be used together\E/,
	'pg_dump: options -c/--clean and -a/--data-only cannot be used together');

command_fails_like(
	[ 'pg_restore', '-c', '-a' ],
qr/\Qpg_restore: options -c\/--clean and -a\/--data-only cannot be used together\E/,
'pg_restore: options -c/--clean and -a/--data-only cannot be used together');

command_fails_like(
	[ 'pg_dump', '--inserts', '-o' ],
qr/\Qpg_dump: options --inserts\/--column-inserts and -o\/--oids cannot be used together\E/,
'pg_dump: options --inserts/--column-inserts and -o/--oids cannot be used together'
);

command_fails_like(
	[ 'pg_dump', '--if-exists' ],
	qr/\Qpg_dump: option --if-exists requires option -c\/--clean\E/,
	'pg_dump: option --if-exists requires option -c/--clean');

command_fails_like(
	[ 'pg_dump', '-j3' ],
	qr/\Qpg_dump: parallel backup only supported by the directory format\E/,
	'pg_dump: parallel backup only supported by the directory format');

command_fails_like(
	[ 'pg_dump', '-j', '-1' ],
	qr/\Qpg_dump: invalid number of parallel jobs\E/,
	'pg_dump: invalid number of parallel jobs');

command_fails_like(
	[ 'pg_dump', '-F', 'garbage' ],
	qr/\Qpg_dump: invalid output format\E/,
	'pg_dump: invalid output format');

command_fails_like(
	[ 'pg_restore', '-j', '-1' ],
	qr/\Qpg_restore: invalid number of parallel jobs\E/,
	'pg_restore: invalid number of parallel jobs');

command_fails_like(
	[ 'pg_restore', '--single-transaction', '-j3' ],
qr/\Qpg_restore: cannot specify both --single-transaction and multiple jobs\E/,
	'pg_restore: cannot specify both --single-transaction and multiple jobs');

command_fails_like(
{'fraction_non_alphanumeric': 0.19052659433712624, 'fraction_numerical': 0.0015877216194760519, 'mean_word_length': 4.3269908386187454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2338334', 'n_tokens_mistral': 2700, 'n_tokens_neox': 2648, 'n_words': 741}