1#!/usr/bin/perl
   2use strict;
   4use warnings;
   5use Test::More 'no_plan';
   7BEGIN {
   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}
  15use Git::SVN::Utils qw(fatal);
  17# 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        # Trap fatal's message to STDERR
  26        my $stderr;
  27        close STDERR;
  28        ok open STDERR, ">", \$stderr;
  29        fatal "Some", "Stuff", "Happened";
  31        is $stderr, "Some Stuff Happened\n";
  33        is $exit_status, 1;
  34}