Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/Git-SVN/Utils/fatal.t # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / Git-SVN / Utils / fatal.t` 34 lines ยท 658 bytes Raw Blame History 1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 use Test::More 'no_plan'; 7 8 BEGIN { 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 16 use 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 }