From 148964c324b7c34af1364c126362aef077db50af Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Sat, 18 Feb 2023 11:36:47 +0100 Subject: 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 --- regen/regen_lib.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'regen') 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) { -- cgit v1.2.1