tinderbox log parser b=375714 r=preed
authorrhelmer@mozilla.com
Wed, 04 Apr 2007 18:31:29 -0700
changeset 352 21142057559fd1f6918391d2b175931a1517a952
parent 351 7a312b0354a63467cf2eb903e50b2773c519e3cd
child 353 ecd72c1f4d948bf686dd211ebb726a8140a8cd14
push idunknown
push userunknown
push dateunknown
reviewerspreed
bugs375714
milestone1.9a4pre
tinderbox log parser b=375714 r=preed
tools/release/MozBuild/TinderLogParse.pm
new file mode 100644
--- /dev/null
+++ b/tools/release/MozBuild/TinderLogParse.pm
@@ -0,0 +1,63 @@
+##
+# TinderLogParse - A tinderbox log parser
+##
+
+package MozBuild::TinderLogParse;
+
+sub new {
+    my $class = shift;
+    my %args = @_;
+
+    my $logFile = $args{'logFile'};
+    if (! defined($logFile)) {
+        die("ASSERT: TinderLogParse::new logFile is a required argument");
+    }
+
+    my $this = { logFile => $logFile };
+    bless($this, $class);
+    return $this;
+}
+
+## 
+# GetBuildID - attempts to find build ID in a tinderbox log file
+#
+# Searches for a string of the form:
+#  Got Build ID: 2007030311
+# Only the buildID, '2007030311', is to be returned.
+#
+##
+
+sub GetBuildID {
+    my $this = shift;
+    my %args = @_;
+
+    my $log = $this->GetLogFileName();
+
+    my $buildID = undef;
+    my $searchString = "Got build ID ";
+
+    open (FILE, "< $log") or die("Cannot open file $log: $!");
+    while (<FILE>) {
+        if ($_ =~ /$searchString/) {
+            $buildID = $_;
+ 
+            # remove search string
+            $buildID =~ s/$searchString//;
+
+            # remove trailing slash
+            $buildID =~ s/^\.//;
+            last;
+        }
+    }
+
+    close FILE or die("Cannot close file $log: $!");
+
+    return $buildID;
+}
+
+sub GetLogFileName {
+    my $this = shift;
+    my %args = @_;
+
+    return $this->{'fileName'};
+}