App-Test-Generator

 view release on metacpan or  search on metacpan

t/cli-fuzz-harness-generator.t  view on Meta::CPAN

	like($out, qr/Usage:/i, '--help output looks correct');
}

# --version
{
	my ($exit, $out, $err) = run_cmd($script, '--version');
	is($exit, 0, '--version exits cleanly');
	like($out, qr/\d+\.\d+/, '--version prints version');
}

# --dry-run
{
	my ($exit, $out, $err) = run_cmd(
		$script,
		'--dry-run',
		'--input', $valid_conf
	);

	is($exit, 0, '--dry-run exits cleanly');
	like($out, qr/Dry-run OK/i, '--dry-run reports success');
	is($err, '', '--dry-run emits no stderr');
}

# --dry-run should not create output
{
	my ($fh, $outfile) = tempfile();
	close $fh;
	unlink $outfile;

	my ($exit, $out, $err) = run_cmd(
		$script,
		'--dry-run',
		'--input',  $valid_conf,
		'--output', $outfile
	);

	ok(!-e $outfile, '--dry-run does not create output file');
}

# Normal generation creates output
{
	my ($fh, $outfile) = tempfile();
	close $fh;
	unlink $outfile;

	my ($exit, $out, $err) = run_cmd(
		$script,
		'--input',  $valid_conf,
		'--output', $outfile
	);

	is($exit, 0, 'Normal run exits cleanly');
	ok(-e $outfile, 'Output file created');
	ok(-s $outfile, 'Output file is non-empty');

	unlink $outfile;
}

# Invalid config fails
{
	my ($exit, $out, $err) = run_cmd($script, '--dry-run', '--input', 't/conf/does_not_exist.conf');

	isnt($exit, 0, 'Invalid config causes failure');
	like($err, qr/(No such file|failed|error)/i,
		'Error message shown for invalid input');
}

done_testing();



( run in 2.407 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )