diff mbox

[OSSTEST,04/11] sg-run-job: Break out testid_matches_globs

Message ID 1492531012-14315-5-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson April 18, 2017, 3:56 p.m. UTC
No functional change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 sg-run-job | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/sg-run-job b/sg-run-job
index cc24b73..8f7c36f 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -133,6 +133,15 @@  proc setstatus {st} {
     jobdb::job-set-status $flight $jobinfo(job) $st
 }
 
+proc testid_matches_globs {testid globs} {
+    foreach glob [split $globs] {
+        if {[string match $glob $testid]} {
+            return 1
+        }
+    }
+    return 0
+}
+
 #---------- test script handling ----------
 
 proc run-ts {args} {
@@ -266,12 +275,9 @@  proc reap-ts {reap} {
 
     eval jobdb::step-set-status [lrange $details 0 2] $result
     jobdb::logputs stdout "finished $detstr $result $emsg"
-    foreach truncate_glob [split $truncate_globs] {
-        if {[string match $truncate_glob $testid]} {
-            jobdb::logputs stdout "truncating job now as instructed"
-            set truncate 1
-            break
-        }
+    if {[testid_matches_globs $testid $truncate_globs]} {
+        jobdb::logputs stdout "truncating job now as instructed"
+        set truncate 1
     }
     return [expr {![string compare $result pass]}]
 }