Move infrastructure for failure tracking to common "mock" tool init file
authorJacob Bachmeyer <jcb@gnu.org>
Fri, 16 Dec 2022 03:08:21 +0000 (21:08 -0600)
committerJacob Bachmeyer <jcb@gnu.org>
Fri, 13 Jan 2023 04:42:59 +0000 (22:42 -0600)
testsuite/lib/mock.exp
testsuite/mock.gpgv/sign.exp

index 223faea92a4e54258bd436879077b110749aeb18..2db0b791ffd6d3b1d026f93683c06137f606b727 100644 (file)
@@ -29,6 +29,28 @@ set ::env(GNUPGHOME) $GNUPGHOME
 
 load_lib mockgpg.exp
 
+# invoked by DejaGnu framework when a failure is recorded
+proc mock_count_failures { args } {
+    global mock_total_failure_count mock_local_failure_count
+    incr mock_total_failure_count
+    incr mock_local_failure_count
+}
+set local_record_procs(fail) mock_count_failures
+set mock_total_failure_count 0
+set mock_local_failure_count 0
+proc mock_total_failures {} {
+    global mock_total_failure_count
+    return $mock_total_failure_count
+}
+proc mock_local_failures {} {
+    global mock_local_failure_count
+    return $mock_local_failure_count
+}
+proc mock_reset_local_failures {} {
+    global mock_local_failure_count
+    set mock_local_failure_count 0
+}
+
 proc put_file { file string } {
     set chan [open $file w]
     puts -nonewline $chan $string
index d1340ffec88e3ce88a08bf7acad8fdddacc525d2..607b0fecfb54f8121eb0a466cb14167d08b74be8 100644 (file)
@@ -58,16 +58,6 @@ proc spawn_gpgv { keyrings args } {
     eval $cmd $args
 }
 
-# invoked by DejaGnu framework when a failure is recorded
-proc gpgv_count_failures {args } {
-    global gpgv_total_failure_count gpgv_local_failure_count
-    incr gpgv_total_failure_count
-    incr gpgv_local_failure_count
-}
-set local_record_procs(fail) gpgv_count_failures
-set gpgv_total_failure_count 0
-set gpgv_local_failure_count 0
-
 # InitialCapital variable names may be used in the $expect block.
 # The "test_dir" variable is also set for the $init block.
 proc run_gpgv_test { Name stem keyrings exitCode init phases assess expect } {
@@ -75,8 +65,7 @@ proc run_gpgv_test { Name stem keyrings exitCode init phases assess expect } {
                      [file dirname [testsuite file -object -top]] test.tmp]
     file mkdir $test_dir
 
-    global gpgv_local_failure_count
-    set gpgv_local_failure_count 0
+    mock_reset_local_failures
 
     eval $init
 
@@ -128,7 +117,7 @@ proc run_gpgv_test { Name stem keyrings exitCode init phases assess expect } {
        }
     }
 
-    if { $gpgv_local_failure_count == 0 } {
+    if { [mock_local_failures] == 0 } {
        foreach scratchfile [list "${stem}" "${stem}.asc" "${stem}.sig"] {
            file delete -- [file join $test_dir $scratchfile]
        }
@@ -761,7 +750,7 @@ do_gpgv_test "expired signature from expired subkey" t9b {dgS2.gpg} 0 \
 
 #
 
-if { $gpgv_total_failure_count == 0 } {
+if { [mock_total_failures] == 0 } {
     file delete -force $GNUPGHOME
 }