bug 401170 New Changes for Minotaur test tool reviewer: bhearsum

This commit is contained in:
ctalbert@mozilla.com 2008-01-07 16:54:00 -08:00
Родитель f691199828
Коммит e1f38d5df6
16 изменённых файлов: 1072 добавлений и 78 удалений

Просмотреть файл

@ -4,14 +4,15 @@
DO NOT FORGET TRAILING SLASH!!:
Windows: content minotaur file:///c:/code/minotaur/
Mac/Linux: content minotaur file:///Users/clint/code/Minotaur/workspace/
3. Run Minotaur - run it without commands to get a usage statement
4. Run Minotaur - results will be in <buildname>-<locale> directory in the
3. If you will be using mozDownload.py - ensure that wget is installed!
4. Run Minotaur - run it without commands to get a usage statement
5. Run Minotaur - results will be in <buildname>/<version>/<locale> directory in the
MINOTAUR_DIR folder
== To get verification files for a first run of a build ==
1. Run Minotaur without the "verification" args, this means without -b -o and
-c options
2. The output.xml and bookmarks.html will be placed in <buildname>-<locale>
2. The output.xml and bookmarks.html will be placed in <buildname>/<version>/<locale>
directory in the MINOTAUR_DIR folder
3. View the http.log that was generated (or partner specs) and create a
release.txt file where the first (and only) line is the release channel name
@ -22,14 +23,12 @@
those files to diff against.
== Known Issues and Troubleshooting ==
* On Windows, there is no Http Debug Log: Depending on which bash shell you
use on Windows, the settings to turn on HTTP Debug logging may not be
properly exported. If this is the case, you will need to export those two
variables by hand. The variables are:
export NSPR_LOG_MODULES=nsHttp:5,nsSocketTransport:5,nsHostResolver:5
export NSPR_LOG_FILE=c:/tmp/http.log
* No Firefox windows appear when I run Minotaur, and the Firefox process (may)
hang out in the system process list after the test finishes: If you see this
then Firefox is trying to tell you that your tests.manifest file is messed up.
Either it has the wrong path, or you forgot the trailing slash.
* On Mac, you should use the following style paths:
<path to firefox.app>/Contents/MacOS This is the proper -f parameter path for a
mac. So, for example, if firefox is installed in applications, this becomes:
/Applications/Firefox.app/Contents/MacOS/

Просмотреть файл

@ -31,7 +31,8 @@
import re
from optparse import OptionParser
from logAppender import LogAppender
from logAppender import LogAppender, stderrCatcher
import sys
aus2link = re.compile(".*https:\/\/aus2.mozilla.org.*")
@ -51,6 +52,7 @@ def checkHttpLog(httpLogFile, releaseChannel):
def main(httpFile, releaseFile, log):
lf = LogAppender(log)
sys.stderr = stderrCatcher(lf)
rf = open(releaseFile, "r")
# Ensure we don't pick up spurious newlines
channel = rf.readline().split("\n")

Просмотреть файл

@ -34,12 +34,15 @@
from optparse import OptionParser
from checkBookmarks import bookmarkParser
from logAppender import LogAppender
from logAppender import LogAppender, stderrCatcher
import sys
# The Main function
def main(left, right, log):
# Instantiate the log writer
lw = LogAppender(log)
# Redirect stderr
sys.stderr = stderrCatcher(lw)
# Parse the left hand file
leftParser = bookmarkParser()

Просмотреть файл

@ -32,18 +32,26 @@
#
# ***** END LICENSE BLOCK *****
import re
from optparse import OptionParser
import platform
cygwinmatch = re.compile(".*cygwin.*", re.I)
def getPlatform():
print platform.system()
# On Vista, python reports "Microsoft" and on cygwin shells it can report
# several different strings that contain the word "cygwin"
if platform.system() == "Microsoft" or cygwinmatch.search(platform.system()):
print "Windows"
else:
print platform.system()
def getFxName(os):
if os == "Darwin":
print "firefox-bin"
elif os == "Linux":
print "firefox"
elif os == "Windows":
else:
print "firefox.exe"
def main(os, fxname):

Просмотреть файл

@ -0,0 +1,80 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Corporation Code.
#
# The Initial Developer of the Original Code is
# Clint Talbert.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Clint Talbert <ctalbert@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
options="f:m:p:"
function usage()
{
cat<<EOF
usage:
$script -f FirefoxDir -m MinotaurDir -p partnerName
variable description
============= ================================================
-m MinotaurDir required, the path to the directory where Minotaur is
-f firefoxDir required, path to Firefox installed build
-p partnerName required, name of the partner extension
NOTES
======
Uses checks the partner preference file in the firefoxDir for the initial value
of the browser.EULA.2.accpected" preference, and stores that value into a file
in the minotaur directory.
EOF
exit 2
}
while getopts $options optname ;
do
case $optname in
m) minotaurdir=$OPTARG;;
f) fxdir=$OPTARG;;
p) ptrname=$OPTARG;;
esac
done
# If anything is not defined, display the usage string above
if [[ -z "$fxdir" || -z "$ptrname" || -z "$minotaurdir" ]]
then
usage
fi
grep "browser.EULA.2.accepted" $fxdir/extensions/$ptrname/defaults/preferences/partner.js > $minotaurdir/EULA.txt
sed '/browser.EULA.2.accepted/s/false/true/' $fxdir/extensions/$ptrname/defaults/preferences/partner.js > $fxdir/extensions/$ptrname/defaults/preferences/partner-new.js
cp $fxdir/extensions/$ptrname/defaults/preferences/partner-new.js $fxdir/extensions/$ptrname/defaults/preferences/partner.js

Просмотреть файл

@ -0,0 +1,43 @@
#!/usr/bin/expect
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Corporation Code.
#
# The Initial Developer of the Original Code is
# Clint Talbert.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Clint Talbert <ctalbert@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
spawn hdiutil attach -verbose -noautoopen -mountpoint ./mnt $argv
expect {
"byte" {send "G"; exp_continue}
"Y/N" {send "Y\r"; exp_continue}
}

Просмотреть файл

@ -0,0 +1,46 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Corporation Code.
#
# The Initial Developer of the Original Code is
# Clint Talbert.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Clint Talbert <ctalbert@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
#!/bin/sh
#set -x
mkdir -p mnt
./installdmg-expect.ex $1
rsync -a ./mnt/* $2
hdiutil detach mnt
rm -rdf ./mnt

Просмотреть файл

@ -35,10 +35,24 @@
#
# ***** END LICENSE BLOCK *****
# Class to append data to a text file
# Class to append data to a text file. It also provides a method to handle
# information going to stderr. To use the stderr redirect, make this call after
# you instantiate LogAppender:
# import sys
# sys.stderr=stderrCatcher(<logFileAppenderObject>)
class stderrCatcher:
def __init__(self, logappender=0):
self.lf = logappender
def write(self, stuff):
if self.lf:
self.lf.onStdError(stuff)
class LogAppender:
def __init__(self, file):
self.logFile = open(file, "a")
def onStdError(self, str):
self.logFile.write("STDERR:" + str + "\n")
def writeLog(self, str):
self.logFile.write(str + "\n")
return str

Просмотреть файл

@ -1,30 +1,52 @@
#!/bin/bash
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Corporation Code.
#
# The Initial Developer of the Original Code is
# Clint Talbert.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Clint Talbert <ctalbert@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
# *!*!*!*!*!*!*!*!*!*!**! NOTICE *!*!*!*!*!*!**!*!*!*!*!*!*!*!**!*!*!*!*!*!*!*!
# If you wish to change the location of the profile directory, then you will
# need to extensively edit this file. For simplicity, the profile directory
# is hard coded to:
# Darwin/Linux:
# /tmp/profile
# Windows
# C:\tmp\profile
# Note that this value cannot be parameterized in the CreateProfile call, and
# this is why it was opted for a hard-coded path. If that call can be
# parameterized, then the paths should be returned to a non-hardcoded path
# and getOsInfo can be modified to return a proper path that "CreateProfile"
# can accept (only accepts full, native paths: i.e. /Users/clint/tmp/profile
# not ~/tmp/profile or $Profile.
#!/bin/bash
# Uncomment following line for debug output
# set -x
options="n:f:m:l:o:b:c:"
options="n:f:m:l:o:b:c:v:"
function usage()
{
cat<<EOF
usage:
$script -n buildName -f FirefoxDir -m MinotaurDir -l locale -o outputXML -b bookmarks -c release-channel
$script -n buildName -f FirefoxDir -m MinotaurDir -l locale -o outputXML -b bookmarks -c release-channel -v FirefoxVersion
variable description
============= ================================================
@ -35,6 +57,7 @@ variable description
-o outputXML optional, the output XML to compare against
-b bookmarks optional, bookmarks.html to compare against
-c release-channel optional, release-channel verification file
-v firefox Version required, the firefox version number under test
Notes
==========
@ -42,8 +65,11 @@ Notes
information for you to use on future runs of this build and locale.
* minotaurdir/tests.manifest must also point to the containing directory
of the minotaur tests, with a trailing slash
* Output will be in ./<buildname>-<locale>/ relevant to the directory where
Minotaur was run from.
* Output will be in ./<buildname>/<version>/<locale>/ relevant to the directory
where Minotaur was run from.
* Note that the test REQUIRES that you have write access to ~/ on your machine,
yes, that goes for Windows machines too. Your shell should resolve ~/ somewhere
on your box.
EOF
exit 2
@ -59,11 +85,12 @@ do
o) outputVerify=$OPTARG;;
b) bookmarksVerify=$OPTARG;;
c) releaseVerify=$OPTARG;;
v) fxver=$OPTARG;;
esac
done
# If anything is not defined, display the usage string above
if [[ -z "$fxname" || -z "$fxdir" || -z "$locale" || -z "$minotaurdir" ]]
if [[ -z "$fxname" || -z "$fxdir" || -z "$locale" || -z "$minotaurdir" || -z "$fxver" ]]
then
usage
fi
@ -72,43 +99,34 @@ fi
OS=$(python getOsInfo.py)
FFX_EXE=$(python getOsInfo.py -o $OS -f)
if [ $OS = "Windows" ]; then
baseProfile=c:/tmp
else
baseProfile=/tmp
fi
rm -rf $baseProfile/test
rm -rf $baseProfile/profile
mkdir $baseProfile
cp ${minotaurdir}/tests.manifest $fxdir/chrome/.
#CreateProfile: NOTICE: See above
if [ $OS = "Windows" ]; then
$fxdir/$FFX_EXE -CreateProfile 'minotaurTestProfile C:\tmp\profile'
else
$fxdir/$FFX_EXE -CreateProfile 'minotaurTestProfile /tmp/profile'
fi
# Use the default profile location because Ffx 3 can't hack non-default profiles
$fxdir/$FFX_EXE -CreateProfile minotaurTestProfile
mkdir $baseProfile/profile
cp ${minotaurdir}/user.js $baseProfile/profile/.
$fxdir/$FFX_EXE -P minotaurTestProfile -chrome chrome://minotaur/content/quit.xul
sleep 10
cp ${minotaurdir}/user.js $baseProfile/profile/.
# Turn on http debugging
export NSPR_LOG_MODULES=nsHttp:5,nsSocketTransport:5,nsHostResolver:5
export NSPR_LOG_FILE=$baseProfile/http.log
rm $baseProfile/http.log
#run the tests
$fxdir/$FFX_EXE -P minotaurTestProfile -chrome chrome://minotaur/content
# create verification repository
mkdir ${minotaurdir}/$fxname-$locale
cp $baseProfile/profile/test-* ${minotaurdir}/$fxname-$locale/.
cp $baseProfile/http.log ${minotaurdir}/$fxname-$locale/http.log
mkdir ${minotaurdir}/$fxname
mkdir ${minotaurdir}/$fxname/$fxver
mkdir ${minotaurdir}/$fxname/$fxver/$locale
resultsdir=${minotaurdir}/$fxname/$fxver/$locale
# Turn on http debugging - we now put the log file directly into the resultsdir
export NSPR_LOG_MODULES=nsHttp:5,nsSocketTransport:5,nsHostResolver:5
export NSPR_LOG_FILE=${resultsdir}/http.log
# Remove any existing log file
if [ -f $resultsdir/http.log ]; then
rm $resultsdir/http.log
fi
#run the extraction
$fxdir/$FFX_EXE -P minotaurTestProfile -chrome chrome://minotaur/content
cp ./test-output.xml $resultsdir/test-output.xml
cp ./test-bookmarks.html $resultsdir/test-bookmarks.html
# If verification files not given, then skip verification
if [[ -z "$outputVerify" || -z "$bookmarksVerify" || -z "$releaseVerify" ]]; then
@ -116,27 +134,31 @@ if [[ -z "$outputVerify" || -z "$bookmarksVerify" || -z "$releaseVerify" ]]; the
else
# Do Verification
#Prepare the log file
rm $fxname-$locale/results.log
rm $fxname/$fxver/$locale/results.log
#Perform the output.xml diff
diff ${minotaurdir}/$fxname-$locale/test-output.xml $outputVerify >> ${minotaurdir}/$fxname-$locale/results.log
diff $resultsdir/test-output.xml $outputVerify >> $resultsdir/results.log
# Check the Bookmarks file
python diffBookmarks.py -l ${minotaurdir}/$fxname-$locale/test-bookmarks.html -r $bookmarksVerify -f ${minotaurdir}/$fxname-$locale/results.log
python diffBookmarks.py -l $resultsdir/test-bookmarks.html -r $bookmarksVerify -f $resultsdir/results.log
# Check the Http Debug Log to catch the release channel
python checkReleaseChannel.py -d ${minotaurdir}/$fxname-$locale/http.log -r $releaseVerify -l ${minotaurdir}/$fxname-$locale/results.log
python checkReleaseChannel.py -d $resultsdir/http.log -r $releaseVerify -l $resultsdir/results.log
# Check to see if we fail or pass
if [ -s ${minotaurdir}/$fxname-$locale/results.log ]; then
if [ -s $resultsdir/results.log ]; then
echo !!!!!!!!!!!!! TEST FAILS !!!!!!!!!!!!!!
echo Results.log:
cat $resultsdir/results.log
else
echo ------------- TEST PASSES -------------
fi
fi
#CLEANUP
# Uncomment this line if you want to delete the firefox install directory
# rm -rdf $fxdir
rm -rf $baseProfile/profile
rm -rf $baseProfile/test
rm ./test-output.xml
rm ./test-bookmarks.html
rm $fxdir/chrome/tests.manifest
if [ -f ${minotaurdir}/EULA.txt ]; then
rm ${minotaurdir}/EULA.txt
fi

Просмотреть файл

@ -1,4 +1,42 @@
<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is Mozilla Corporation Code.
-
- The Initial Developer of the Original Code is
- Alice Nodelman.
- Portions created by the Initial Developer are Copyright (C) 2007
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Alice Nodelman <anodelman@mozilla.com>
- Clint Talbert <ctalbert@mozilla.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="minotaurWindow"

Просмотреть файл

@ -0,0 +1,164 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Corporation Code.
#
# The Initial Developer of the Original Code is
# Clint Talbert.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Clint Talbert <ctalbert@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
import urllib
import urlparse
import shutil
import subprocess
from optparse import OptionParser
import os
_mozdownload_debug = False
def debug(str):
if _mozdownload_debug:
print "DEBUG DOWNLOAD.py: " + str
# Overrides some of the FancyURLopener functionality so that we can send in
# our auth info. It only tries once. If the auth info is wrong, it throws.
class mozURLopener(urllib.FancyURLopener):
def __init__(self, **kwargs):
if kwargs['user'] != "":
self.user = kwargs['user']
self.passwd = kwargs['passwd']
else:
self.user = ""
self.passwd = ""
self.triedPassword = False
urllib.FancyURLopener.__init__(self)
def prompt_user_passwd (self, host, realm):
debug("mozURLopener: Sending Password")
self.triedPassword = True
return(self.user, self.passwd)
def http_error_401(self, url, fp, errcode, errmsg, headers, data=None):
debug("mozURLOpener: GOT a 401!!!")
if not self.triedPassword:
return urllib.FancyURLopener.http_error_401(self, url, fp, errcode, errmsg, headers, data=None)
else:
# Password was incorrect, throw a 401
raise IOError, 401
return None
class MozDownloader:
def __init__(self, **kwargs):
assert (kwargs['url'] != "" and kwargs['url'] != None)
assert (kwargs['dest'] != "" and kwargs['dest'] != None)
self.url = kwargs['url']
self.dest = kwargs['dest']
self.error = 0
self.user = kwargs['user']
self.passwd = kwargs['password']
def download(self):
# Attempt to use urllib for this instead of wget
try:
opener = mozURLopener(user=self.user, passwd=self.passwd)
data = opener.open(self.url)
#Ensure directory exists
self.ensureDest()
destfile = open(self.dest, "wb")
destfile.write(data.read())
destfile.close()
except:
print "Download did not work - is your username and password correct?"
def ensureDest(self):
try:
# Work around the fact that the os.path module doesn't understand ~/ paths
if self.dest[0] == "~":
self.dest = self.dest.replace("~", "${HOME}", 1)
headpath = os.path.split(self.dest)[0]
headpath = os.path.expandvars(headpath)
try:
if not os.path.exists(headpath):
os.makedirs(headpath)
except:
print "Error creating directory for download"
except:
self.error = 1
def moveToDest(self):
try:
# Grab the name of the downloaded file from the URL
parsedUrl = urlparse.urlparse(self.url)
path = parsedUrl[2]
pathElements = path.split("/")
filename = pathElements[len(pathElements) - 1]
print filename
# Create directory - we assume that the name of the file is the last
# parameter on the path
if self.dest[0] == "~":
self.dest = self.dest.replace("~", "${HOME}", 1)
headpath = os.path.split(self.dest)[0]
headpath = os.path.expandvars(headpath)
try:
if not os.path.exists(headpath):
os.makedirs(headpath)
except:
print "Error creating destination directory"
# Move it to destination location and file name
self.dest = os.path.expandvars(self.dest)
debug(self.dest)
shutil.move("./" + urllib.unquote(filename), self.dest)
except:
self.error = 1
if __name__ == "__main__":
parser = OptionParser()
parser.add_option("-d", "--Destination", dest="dest",
help="Destination file to download to",
metavar="DEST_FILE")
parser.add_option("-u", "--URL", dest="url",
help="URL to download from", metavar="URL")
parser.add_option("-n", "--userName", dest="user",
help="User name if needed (optional)",
metavar="USERNAME")
parser.add_option("-p", "--Password", dest="password",
help="Password for User name (optional)",
metavar="PASSWORD")
(options, args) = parser.parse_args()
# Run it
mozDwnld = MozDownloader(url=options.url, dest=options.dest, user=options.user,
password=options.password)
mozDwnld.download()

Просмотреть файл

@ -0,0 +1,293 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Corporation Code.
#
# The Initial Developer of the Original Code is
# Clint Talbert.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Clint Talbert <ctalbert@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
from optparse import OptionParser
import platform
import subprocess
import re
import time
import string
import os
import shutil
isDMG = re.compile(".*\.dmg")
isTARBZ = re.compile(".*\.tar\.bz")
isTARGZ = re.compile(".*\.tar\.gz")
isZIP = re.compile(".*\.zip")
isEXE = re.compile(".*\.exe")
_mozInstall_debug = False
def debug(s):
if _mozInstall_debug:
print "DEBUG: " + s
cygwinmatch = re.compile(".*cygwin.*", re.I)
# Copied from mozilla/testing/release/minotaur/getOSInfo.py - want this class
# to be self-sufficient without requiring another "non-standard" python lib,
# so duplicated this function from there.
def getPlatform():
# On Vista, python reports "Microsoft" and on cygwin shells it can report
# several different strings that contain the word "cygwin"
if platform.system() == "Microsoft" or cygwinmatch.search(platform.system()):
return "Windows"
else:
return platform.system()
class MozUninstaller:
def __init__(self, **kwargs):
debug("uninstall constructor")
assert (kwargs['dest'] != "" and kwargs['dest'] != None)
assert (kwargs['productName'] != "" and kwargs['productName'] != None)
assert (kwargs['branch'] != "" and kwargs['dest'] != None)
self.dest = kwargs['dest']
self.productName = kwargs['productName']
self.branch = kwargs['branch']
# Handle the case where we haven't installed yet
if not os.path.exists(self.dest):
return
if getPlatform() == "Windows":
try:
self.doWindowsUninstall()
except:
debug("Windows Uninstall threw - not overly urgent or worrisome")
if os.path.exists(self.dest):
try:
os.rmdir(self.dest)
except OSError:
# Directories are still there - kill them all!
self.rmdirRecursive(self.dest)
def doWindowsUninstall(self):
debug("do windowsUninstall")
if self.branch == "1.8.0":
uninstexe = self.dest + "/uninstall/uninstall.exe"
uninstini = self.dest + "/uninstall/uninstall.ini"
debug("uninstexe: " + uninstexe)
debug("uninstini: " + uninstini)
if os.path.exists(uninstexe):
# modify uninstall.ini to run silently
debug("modifying uninstall.ini")
args = "sed -i.bak 's/Run Mode=Normal/Run Mode=Silent/' " + uninstini
proc = subprocess.Popen(args, shell=True)
# Todo handle error
proc.wait()
proc = subprocess.Popen(uninstexe, shell=True)
proc.wait()
elif self.branch == "1.8.1" or self.branch == "1.8" or self.branch == "1.9":
debug("we are in 1.8 uninstall land")
uninst = self.dest + "/uninstall/uninst.exe"
helper = self.dest + "/uninstall/helper.exe"
debug("uninst: " + uninst)
debug("helper: " + helper)
if os.path.exists(helper):
debug("helper exists")
args = helper + " /S /D=" + os.path.normpath(self.dest)
debug("running helper with args: " + args)
proc = subprocess.Popen(args, shell=True)
proc.wait()
elif os.path.exists(uninst):
args = uninst + " /S /D=" + os.path.normpath(self.dest)
debug("running uninst with args: " + args)
proc = subprocess.Popen(args, shell=True)
proc.wait()
else:
uninst = self.dest + "/" + self.product + "/uninstall/uninstaller.exe"
args = uninst + " /S /D=" + os.path.normpath(self.dest)
debug("running uninstaller with args: " + args)
proc = subprocess.Popen(args, shell=True)
proc.wait()
time.sleep(10)
# This code is lifted directly from the buildbot code. That we use here. I
# can't call it in buildbot without importing a trillion other things.
# Original Source: http://mxr.mozilla.org/mozilla/source/tools/buildbot/buildbot/slave/commands.py#59
def rmdirRecursive(self, dir):
"""This is a replacement for shutil.rmtree that works better under
windows. Thanks to Bear at the OSAF for the code."""
if not os.path.exists(dir):
return
if os.path.islink(dir):
os.remove(dir)
return
# Verify the directory is read/write/execute for the current user
os.chmod(dir, 0700)
for name in os.listdir(dir):
full_name = os.path.join(dir, name)
# on Windows, if we don't have write permission we can't remove
# the file/directory either, so turn that on
if os.name == 'nt':
if not os.access(full_name, os.W_OK):
# I think this is now redundant, but I don't have an NT
# machine to test on, so I'm going to leave it in place
# -warner
os.chmod(full_name, 0600)
if os.path.isdir(full_name):
self.rmdirRecursive(full_name)
else:
os.chmod(full_name, 0700)
os.remove(full_name)
os.rmdir(dir)
class MozInstaller:
def __init__(self, **kwargs):
debug("install constructor!")
assert (kwargs['dest'] != "" and kwargs['dest'] != None)
assert (kwargs['src'] != "" and kwargs['src'] != None)
assert (kwargs['productName'] != "" and kwargs['productName'] != None)
assert (kwargs['branch'] != "" and kwargs['branch'] != None)
self.src = kwargs['src']
self.dest = kwargs['dest']
self.productName = kwargs['productName']
self.branch = kwargs['branch']
debug("running uninstall")
uninstaller = MozUninstaller(dest = self.dest, productName = self.productName,
branch = self.branch)
if isDMG.match(self.src):
self.installDmg()
elif isTARBZ.match(self.src):
self.installTarBz()
elif isTARGZ.match(self.src):
self.installTarGz()
elif isZIP.match(self.src):
self.installZip()
elif isEXE.match(self.src):
self.installExe()
# Simple utility function to get around python's path module's inability
# to understand ~/... style paths
def normalizePath(self, path):
if path[0] == "~":
path = path.replace("~", "${HOME}", 1)
path = os.path.expandvars(path)
debug("NORMALIZE: path: " + path)
try:
if not os.path.exists(path):
os.makedirs(path)
except:
# TODO: Better catch and error message
print "Error creating destination directory"
return path
def installDmg(self):
# Ensure our destination directory exists
self.dest = self.normalizePath(self.dest)
args = "sh installdmg.sh " + self.src + " " + self.dest
proc = subprocess.Popen(args, shell=True)
proc.wait()
# TODO: throw stderr
def installTarBz(self):
# Ensure our destination directory exists
self.dest = self.normalizePath(self.dest)
self.unTar("-jxvf")
def installTarGz(self):
# Ensure our destination directory exists
self.dest = self.normalizePath(self.dest)
self.unTar("-zxvf")
def unTar(self, tarArgs):
args = "tar " + tarArgs + " " + self.src + " -C " + self.dest
proc = subprocess.Popen(args, shell=True)
proc.wait()
#TODO: throw stderr
def installZip(self):
self.dest = self.normalizePath(self.dest)
args = "unzip -o -d " + self.dest + " " + self.src
proc = subprocess.Popen(args, shell=True)
proc.wait()
# TODO: throw stderr
def installExe(self):
debug("running installEXE")
args = self.src + " "
if self.branch == "1.8.0":
args += "-ms -hideBanner -dd " + self.dest
else:
debug("running install exe for 1.8.1")
args += "/S /D=" + os.path.normpath(self.dest)
# Do we need a shell=True here?
proc = subprocess.Popen(args)
proc.wait()
# TODO: throw stderr
# Enable it to be called from the command line with the options
if __name__ == "__main__":
parser = OptionParser()
parser.add_option("-s", "--Source", dest="src",
help="Installation Source File (whatever was downloaded) -\
accepts Zip, Exe, Tar.Bz, Tar.Gz, and DMG",
metavar="SRC_FILE")
parser.add_option("-d", "--Destination", dest="dest",
help="Directory to install the build into", metavar="DEST")
parser.add_option("-b", "--Branch", dest="branch",
help="Branch the build is from must be one of: 1.8.0|1.8|\
1.9", metavar="BRANCH")
parser.add_option("-p", "--Product", dest="product",
help="Product name - optional should be all lowercase if\
specified: firefox, thunderbird, etc",
metavar="PRODUCT")
parser.add_option("-o", "--Operation", dest="op",
help="The operation you would like the script to perform.\
Should be either install (i) or uninstall (u)",
metavar="OP")
(options, args) = parser.parse_args()
# Run it
if string.upper(options.op) == "INSTALL" or string.upper(options.op) == "I":
installer = MozInstaller(src = options.src, dest = options.dest,
branch = options.branch, productName = options.product)
elif string.upper(options.op) == "UNINSTALL" or string.upper(options.op) == "U":
uninstaller = MozUninstaller(dest = options.dest, branch = options.branch,
productName = options.product)

Просмотреть файл

@ -0,0 +1,255 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Corporation Code.
#
# The Initial Developer of the Original Code is
# Clint Talbert.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Clint Talbert <ctalbert@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
from optparse import OptionParser
import platform
import subprocess
import re
from mozDownload import MozDownloader
from mozInstall import MozInstaller, MozUninstaller
isDebug = True
def debug(s):
if isDebug:
print "DEBUG: ",
print s
generalerr = re.compile(".*error.*")
def getPlatformDirName():
os = platform.system()
if (os == "Darwin"):
return "mac"
elif (os == "Linux"):
return "linux-i686"
else:
return "win32"
def getPlatformFirefoxName(version):
os = platform.system()
if (os == "Darwin"):
return "Firefox%20" + version + ".dmg"
elif (os == "Linux"):
return "firefox-" + version + ".tar.gz"
else:
return "Firefox%20Setup%20" + version + ".exe"
def getDownloadLocation(partner, loc):
os = platform.system()
if (os == "Darwin"):
return "~/minotaur-download/" + partner + "/" + loc + "/firefoxInst.dmg"
elif (os == "Linux"):
return "~/minotaur-download/" + partner + "/" + loc + "/firefoxInst.tar.gz"
else:
return "c:/minotaur-download/" + partner + "/" + loc + "/firefoxInst.exe"
def getInstallLocation(partner, loc, isInst):
os = platform.system()
if (os == "Darwin"):
if isInst:
return "~/minotaur-build/" + partner + "/" + loc
else:
return "~/minotaur-build/" + partner + "/" + loc + "/Firefox.app/Contents/MacOS"
elif (os == "Linux"):
if isInst:
return "~/minotaur-build/" + partner + "/" + loc
else:
return "~/minotaur-build/" + partner + "/" + loc + "/firefox"
else:
return "c:/minotaur-build/" + partner + "/" + loc
def doDownload(partner, loc, url, minDir, creds):
result = True
dwnlddir = getDownloadLocation(partner, loc)
user = ""
passwd = ""
if creds:
user = creds.split(":")[0]
passwd = creds.split(":")[1]
mozDwnld = MozDownloader(url=url, dest=dwnlddir, user=user,
password=passwd)
mozDwnld.download()
print "Downloading locale: " + loc
if result:
print "Result: DOWNLOADED"
else:
print "Result: NOT FOUND"
print "==========================="
return result
def doInstall(branch, partner, loc):
# Installs the build using the installbuild.sh script
#installs into <os>/minotaur-builds/partner/locale
print " DEBUG: doInstall"
result = True
installdir = getInstallLocation(partner, loc, True)
dwnlddir = getDownloadLocation(partner, loc)
try:
installer = MozInstaller(src = dwnlddir, dest = installdir, branch = branch,
productName = "firefox")
except:
print "DEBUG: mozinstaller threw"
result = False
print "========================="
print "Installing locale: " + loc
if result:
print "Result: Installed"
else:
print "Result: ERROR!!"
return result
def checkEULA(partner, loc, minDir, extName):
# Checks for the existance of the EULA pref and writes out its pre-install
# value. Minotuar will pick this up and report the initial value in its diff.
if (extName):
installDir = getInstallLocation(partner, loc, False)
args = "sh " + minDir + "/grabEULA.sh -f " + installDir + " -m " + minDir + " -p " + extName
print "EULA args: " + args
proc = subprocess.Popen(args, stdout=subprocess.PIPE, shell=True)
proc.wait()
print proc.stdout
def doMinotaur(partner, loc, minDir, vFiles, ausparam, version):
# If vFiles exist, then run full comparison run comparing against those files
# otherwise, create those files put the created files into partner/locale
# directories within the minotaur area
result = True
installDir = getInstallLocation(partner, loc, False)
args = "sh minotaur.sh -n " + partner + " -m " + minDir + " -f " + installDir
args += " -l " + loc + " -v " + version
debug("Minotaur args: " + args)
if vFiles:
# Then we do a full run, with comparisons
writeReleaseChannel(vFiles, loc, ausparam)
outputFile = vFiles + "/" + loc + "/" + "test-output.xml"
bkmkFile = vFiles + "/" + loc + "/" + "test-bookmarks.html"
releaseFile = vFiles + "/" + loc + "/" + "release-channel.txt"
args += " -o " + outputFile + " -b " + bkmkFile + " -c " + releaseFile
proc = subprocess.Popen(args, shell=True)
proc.wait()
else:
# Then we generate files for future reference
proc = subprocess.Popen(args, shell=True)
proc.wait()
return result
def doUninstall(branch, partner, loc):
# Uninstalls the build installed to <os>/minotuar-builds/partner/locale
result = True
installDir = getInstallLocation(partner, loc, True)
debug("Calling uninstall")
uninstaller = MozUninstaller(dest = installDir, branch = branch,
productName = "firefox")
return result
def writeReleaseChannel(vFiles, loc, aus):
filepath = vFiles + "/" + loc + "/release-channel.txt"
file = open(filepath, "w")
file.write(aus)
def main(branch, version, url, partner, vFiles, minDir, extName, creds, aus,
l10nFile):
# First we craft the URL, assuming that the next directory down is the OS so
# we append that.
plat = getPlatformDirName()
url += "/" + getPlatformDirName()
fxname = getPlatformFirefoxName(version)
try:
l10nList = open(l10nFile, "r")
except IOError:
print "Unable to find L10N File!"
for loc in l10nList:
loc = loc.strip()
# Attempt to download every locale.
debug("BEGINNING DOWNLOAD")
found = doDownload(partner, loc, url + "/" + loc + "/" + fxname, minDir, creds)
found = True
if found:
debug("BEGINNING INSTALL")
isInstalled = doInstall(branch, partner, loc)
if isInstalled:
debug("CHECKING EULA")
checkEULA(partner, loc, minDir, extName)
debug("RUNNING MINOTAUR")
doMinotaur(partner, loc, minDir, vFiles, aus, version)
debug("RUNNING UNINSTALL")
doUninstall(branch, partner, loc)
if __name__ == "__main__":
parser = OptionParser()
parser.add_option("-p", "--Partner", dest="partner", help="Partner Name",
metavar="PARTNER_NAME")
parser.add_option("-b", "--Branch", dest="branch",
help="Gecko Branch: 1.8.0|1.8.1|1.9", metavar="BRANCH")
parser.add_option("-v", "--Version ", dest="version",
help="version of firefox to be tested",
metavar="FIREFOX_VERSION")
parser.add_option("-u", "--UrlToBuild", dest="url",
help="URL to top level build location, above the OS directories",
metavar="URL")
parser.add_option("-f", "--VerificationFileLocation", dest="verificationFiles",
help="location of verification files, leave blank to create verification files",
metavar="VER_FILES")
parser.add_option("-m", "--MinotaurDirectory", dest="minDir",
help="Directory of the Minotuar code",
metavar="MINOTAUR_DIR")
parser.add_option("-e", "--ExtensionName", dest="extName",
help="Name of the partner extension. Only needed if Partner has EULA",
metavar="EXT_NAME")
parser.add_option("-c", "--Credentials", dest="creds",
help="Credentials to download the build in this form: <user>:<password>",
metavar="CREDENTIALS")
parser.add_option("-a", "--AusParameter", dest="aus",
help="The AUS parameter for the AUS URI (-cck param)",
metavar="AUS_PARAM")
parser.add_option("-l", "--L10NFile", dest="l10nFile", help="A text file\
containing the language codes for this build, separated\
by LF", metavar="L10N_FILE")
(options, args) = parser.parse_args()
# Call Main
main(options.branch, options.version, options.url, options.partner,
options.verificationFiles, options.minDir, options.extName,
options.creds, options.aus, options.l10nFile)

Просмотреть файл

@ -6,7 +6,7 @@
title="test searchbar"
orient="horizontal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!-- Widgets and markup go here -->
<!-- Widgets and markup go here -->
<script type="text/javascript" src="quit.js" />
<script type="text/javascript">goQuitApplication();</script>

Просмотреть файл

@ -54,7 +54,7 @@ var gOutFile;
function createOutputFile() {
var dirServices = Cc["@mozilla.org/file/directory_service;1"]
.createInstance(Ci.nsIProperties);
var file = dirServices.get("ProfD", Components.interfaces.nsIFile);
var file = dirServices.get("CurWorkD", Components.interfaces.nsIFile);
file.append("test-output.xml");
if (file.exists()) {
file.remove(false);
@ -139,12 +139,38 @@ function listPrefs() {
output("</section>");
}
function handleEULA() {
var dirUtils = Cc["@mozilla.org/file/directory_service;1"]
.createInstance(Ci.nsIProperties);
var eulaFile = dirUtils.get("CurWorkD", Components.interfaces.nsIFile);
eulaFile.append("EULA.txt");
if (eulaFile.exists()) {
// Then we have a EULA file, write that information into the XML output
output("\n<section id=\"eula\">\n");
var istream = Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(Ci.nsIFileInputStream);
istream.init(eulaFile, 0x01, 0444, 0);
istream.QueryInterface(Ci.nsILineInputStream);
// read lines into array
var line = {}, hasmore;
var isFirstLine = true;
do {
hasmore = istream.readLine(line);
output("<l>" + line.value + "</l>\n");
} while(hasmore);
istream.close();
output("</section>");
}
}
function listBookmarks() {
// Exports bookmarks to a testbookmarks.html file
// If we're not less than or equal to a 1.8 build, then we're using places
var dirUtils = Cc["@mozilla.org/file/directory_service;1"]
.createInstance(Ci.nsIProperties);
var file = dirUtils.get("ProfD", Components.interfaces.nsIFile);
var file = dirUtils.get("CurWorkD", Components.interfaces.nsIFile);
file.append("test-bookmarks.html");
if (file.exists()) {
file.remove(false);
@ -205,6 +231,7 @@ createOutputFile();
listEngines();
listPrefs();
listExtensions();
handleEULA();
listBookmarks();
listUpdates();
closeOutputFile();

Просмотреть файл

@ -1 +1 @@
content minotaur file:///Users/clint/code/Minotaur/workspace/
content minotaur file:///Users/ctalbert/code/minotaur/