From 1c643916a303d129e03312d36ba5d3870e25d850 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 10 Dec 2019 18:53:35 -0500 Subject: [PATCH] Tests: Add copy_if_golden to harness. --- test_regress/driver.pl | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/test_regress/driver.pl b/test_regress/driver.pl index c2aadd541..ab1d60acd 100755 --- a/test_regress/driver.pl +++ b/test_regress/driver.pl @@ -2008,6 +2008,17 @@ sub files_identical { } } +sub copy_if_golden { + my $self = (ref $_[0]? shift : $Self); + my $fn1 = shift; + my $fn2 = shift; + if ($ENV{HARNESS_UPDATE_GOLDEN}) { # Update golden files with current + warn "%Warning: HARNESS_UPDATE_GOLDEN set: cp $fn1 $fn2\n"; + eval "use File::Copy;"; + File::Copy::copy($fn1, $fn2); + } +} + sub vcd_identical { my $self = (ref $_[0]? shift : $Self); my $fn1 = shift; @@ -2028,11 +2039,7 @@ sub vcd_identical { if ($out ne '') { print $out; $self->error("VCD miscompare $fn1 $fn2\n"); - if ($ENV{HARNESS_UPDATE_GOLDEN}) { # Update golden files with current - warn "%Warning: HARNESS_UPDATE_GOLDEN set: cp $fn1 $fn2\n"; - eval "use File::Copy;"; - File::Copy::copy($fn1,$fn2); - } + $self->copy_if_golden($fn1, $fn2); return 0; } } @@ -2047,11 +2054,7 @@ sub vcd_identical { if ($a ne $b) { print "$a\n$b\n" if $::Debug; $self->error("VCD hier mismatch $fn1 $fn2\n"); - if ($ENV{HARNESS_UPDATE_GOLDEN}) { # Update golden files with current - warn "%Warning: HARNESS_UPDATE_GOLDEN set: cp $fn1 $fn2\n"; - eval "use File::Copy;"; - File::Copy::copy($fn1,$fn2); - } + $self->copy_if_golden($fn1, $fn2); return 0; } }