Add structured exception for filename mismatch
authorJacob Bachmeyer <jcb@gnu.org>
Thu, 3 Nov 2022 20:41:12 +0000 (15:41 -0500)
committerJacob Bachmeyer <jcb@gnu.org>
Thu, 3 Nov 2022 20:41:12 +0000 (15:41 -0500)
This commit also changes the exception handling for exceptions carrying
long-form messages, instead of continuing to list their types individually
and removes testsuite support for a long-obsolete log message that could
never actually be produced.

gatekeeper.pl
testsuite/lib/gatekeeper.exp

index f25e9b4b4248fb1e06e15a16dd77e7618d3233fa..1bcdd523895f87ebc79eb0b21d5e9e3643950e4b 100755 (executable)
@@ -555,6 +555,22 @@ BEGIN {
   sub package_name { (shift)->{package_name} }
 }
 
+{
+  package Local::Exception::directive_filename_mismatch;
+  {our @ISA = qw(Local::Exception)}
+
+  sub summary {
+    my $self = shift;
+    return "filename element mismatch: $self->{filename} expecting $self->{stem}"}
+
+  sub message { my $self = shift; return <<"END" }
+The filename directive element does not match the name of the uploaded file.
+
+  Declared name: $self->{filename}
+  Uploaded file: $self->{stem}
+END
+}
+
 {
   package Local::Exception::directive_syntax;
   {our @ISA = qw(Local::Exception)}
@@ -2057,10 +2073,9 @@ sub validate_commands {
     # directive signature and the uploaded packet.  We already know that
     # the name of the uploaded file must match the stem of the directive
     # file name; this is how it was recognized as part of the packet.
-    fatal("The filename directive does not match name of the uploaded file."
-         ."\n\n  Filename directive: $op_header->{filename}"
-         ."\n  Uploaded file: $stem\n",1)
-      unless $stem eq $op_header->{filename};
+    throw directive_filename_mismatch =>
+      filename => $op_header->{filename}, stem => $stem
+       unless $stem eq $op_header->{filename};
   }
 }
 
@@ -2620,8 +2635,8 @@ foreach my $packet (@packets) {   # each list element is an array reference
        mail(join("\n",$E->summary,'',$E->trace_msg),1);
       } elsif ($E->type_p('package_configuration')) {
        mail($E->summary,0);
-      } elsif ($E->type_p('signature_replay')
-              || $E->type_p('unknown_package')) {
+      } elsif (UNIVERSAL::can($E, 'message')) {
+       # catch-all for exceptions carrying long-form messages
        mail($E->message,1);
       }
     } else {
index 41dbc2af36822caaf8b6911ff5f95e752f2fedd0..b6b15ecd940ed97f257cec83dde64583f52f6306 100644 (file)
@@ -736,18 +736,11 @@ proc analyze_log { base_dir name assess } {
                     exp_continue
                 }
        -re {^gatekeeper\[[0-9]+\]: \(Test\) \[PV\]\
-                The filename directive does not match name of the\
-                uploaded file.[^\r\n]+} {
+                filename element mismatch: [^\r\n]+} {
                     # from read_directive_file, on name mismatch
                     set A(validate,filename-mismatch) 1
                     exp_continue
                 }
-       -re {^gatekeeper\[[0-9]+\]: \(Test\) \[PV\]\
-                filename [^\r\n]+ does not match name of directive[^\r\n]+} {
-                    # from read_directive_file, on name mismatch
-                    set A(validate,filename-mismatch-directive) 1
-                    exp_continue
-                }
        -re {^gatekeeper\[[0-9]+\]: \(Test\) \[AA\]\
                 DEBUG: Signature made [^\r\n]+} {
                     # from read_directive_file, reporting signature timestamp