1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More 'no_plan';
7
8BEGIN {
9 # Override exit at BEGIN time before Git::SVN::Utils is loaded
10 # so it will see our local exit later.
11 *CORE::GLOBAL::exit = sub(;$) {
12 return @_ ? CORE::exit($_[0]) : CORE::exit();
13 };
14}
15
16use Git::SVN::Utils qw(fatal);
17
18# fatal()
19{
20 # Capture the exit code and prevent exit.
21 my $exit_status;
22 no warnings 'redefine';
23 local *CORE::GLOBAL::exit = sub { $exit_status = $_[0] || 0 };
24
25 # Trap fatal's message to STDERR
26 my $stderr;
27 close STDERR;
28 ok open STDERR, ">", \$stderr;
29
30 fatal "Some", "Stuff", "Happened";
31
32 is $stderr, "Some Stuff Happened\n";
33 is $exit_status, 1;
34}