diff options
author | Yves Orton <demerphq@gmail.com> | 2023-02-18 11:36:47 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2023-02-19 09:44:05 +0800 |
commit | 148964c324b7c34af1364c126362aef077db50af (patch) | |
tree | 5a29e7371d3bf8424ab19edb018f27434d0b8bb3 /regen | |
parent | ce94d21a89435e6f2c921e8908972f61a3e115bc (diff) | |
download | perl-148964c324b7c34af1364c126362aef077db50af.tar.gz |
regen/regen_lib.pl - don't leave -new files in the tree when tests fail
Unless the user requests we do so by setting REGEN_T_KEEP_CHANGES
Diffstat (limited to 'regen')
-rw-r--r-- | regen/regen_lib.pl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/regen/regen_lib.pl b/regen/regen_lib.pl index 1d250299db..37f42c3e06 100644 --- a/regen/regen_lib.pl +++ b/regen/regen_lib.pl @@ -95,13 +95,21 @@ sub close_and_rename { $fail = "'$name' and '$final_name' differ"; } } + # If someone wants to run t/porting/regen.t and keep the + # changes then they can set this env var, otherwise we + # unlink the generated file regardless. + my $keep_changes= $ENV{"REGEN_T_KEEP_CHANGES"}; + safer_unlink($name) unless $keep_changes; if ($fail) { print STDOUT "not ok - $0 $final_name\n"; die "$fail\n"; } else { print STDOUT "ok - $0 $final_name\n"; } - safer_unlink($name); + # If we get here then the file hasn't changed, and we should + # delete the new version if they have requested we keep changes + # as we wont have deleted it above like we would normally. + safer_unlink($name) if $keep_changes; return; } unless ($force) { |