[gs-cvs] rev 7884 - trunk/gs/toolbin/tests
ray at ghostscript.com
ray at ghostscript.com
Thu Apr 26 16:46:30 PDT 2007
Author: ray
Date: 2007-04-26 16:46:30 -0700 (Thu, 26 Apr 2007)
New Revision: 7884
Added:
trunk/gs/toolbin/tests/main.py
trunk/gs/toolbin/tests/myoptparse.py
Modified:
trunk/gs/toolbin/tests/README
trunk/gs/toolbin/tests/run_nightly
Log:
Fix regression tools to remove dependency on PYTHONPATH since
the environment variable method isn't very convenient for those
running local regressions and add those python files from
peeves:/home/regression/python to this directory (under svn).
Modified: trunk/gs/toolbin/tests/README
===================================================================
--- trunk/gs/toolbin/tests/README 2007-04-25 20:00:00 UTC (rev 7883)
+++ trunk/gs/toolbin/tests/README 2007-04-26 23:46:30 UTC (rev 7884)
@@ -1,14 +1,5 @@
crontab executes run_nightly
-run_nightly provides the correct python environment for running run_nightly.py
- export PYTHONPATH=.:/home/regression/python:$PYTHONPATH
-
-Since we now have shared python modules in /home/regression/python,
-it needs to be added to the appropriate path.
-For example in .bashrc
-
- export PYTHONPATH=.:/home/regression/python:$PYTHONPATH
-
This addition is also helpful
export PATH=.:/home/regression/bin:$PATH
@@ -146,4 +137,4 @@
Tests with larger scope than nightly:
- run_series.py - run_nightly.py with a specified range of revisions.
\ No newline at end of file
+ run_series.py - run_nightly.py with a specified range of revisions.
Added: trunk/gs/toolbin/tests/main.py
===================================================================
--- trunk/gs/toolbin/tests/main.py 2007-04-25 20:00:00 UTC (rev 7883)
+++ trunk/gs/toolbin/tests/main.py 2007-04-26 23:46:30 UTC (rev 7884)
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+import sys, os
+
+if __name__ == "__main__":
+
Added: trunk/gs/toolbin/tests/myoptparse.py
===================================================================
--- trunk/gs/toolbin/tests/myoptparse.py 2007-04-25 20:00:00 UTC (rev 7883)
+++ trunk/gs/toolbin/tests/myoptparse.py 2007-04-26 23:46:30 UTC (rev 7884)
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+# -*- Mode: python -*-
+
+# Copyright (C) 2007 Artifex Software Inc.
+#
+# This software is provided AS-IS with no warranty, either express or
+# implied.
+#
+# This software is distributed under license and may not be copied,
+# modified or distributed except as expressly authorized under the terms
+# of the license contained in the file LICENSE in this distribution.
+#
+# For more information about licensing, please refer to
+# http://www.ghostscript.com/licensing/. For information on
+# commercial licensing, go to http://www.artifex.com/licensing/ or
+# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
+# San Rafael, CA 94903, U.S.A., +1(415)492-9861.
+
+
+import optparse
+import sys, os
+import types
+
+def parseCommandLineBasic(optionsParser=None,args=sys.argv):
+ optionsParser.add_option('--verbose','-v',action='store_true',help="noisy execution")
+
+ myself=os.path.basename(args[0])
+ options,arguments=optionsParser.parse_args()
+ options.myself=myself
+ return (options,arguments)
+
+def parseCommandLine(optionsParser=None,args=sys.argv,revisionSkip=False,testfileSkip=False,listfileSkip=False,deviceSkip=False):
+ if not optionsParser:
+ optionsParser=optparse.OptionParser()
+
+ if not testfileSkip:
+ optionsParser.add_option('--testfile','-t',action='store',help="testfile:\"test\"",default="test")
+
+ if not listfileSkip:
+ optionsParser.add_option('--listfile','-l',action='store',help="listfile:\"list\"",default="list")
+
+ if not revisionSkip:
+ optionsParser.add_option('--revision','-e',action='store',help="revision:HEAD",default="HEAD")
+
+ if not deviceSkip:
+ optionsParser.add_option('--device','-d',action='store',help="output device:ppmraw",default="ppmraw")
+ optionsParser.add_option('--resolution','-r',action='store',help="output resolution:300",default="300")
+ optionsParser.add_option('--banding','-b',action='store',help="output banding:False",default=False)
+
+ optionsParser.add_option('--quiet','-q',action='store_true',help="quiet execution")
+ optionsParser.add_option('--verbose','-v',action='store_true',help="noisy execution")
+
+ optionsParser.add_option('--nocleanup','-k',action='store_true',help="do not delete intermediate files")
+
+ myself=os.path.basename(args[0])
+ options,arguments=optionsParser.parse_args()
+ options.myself=myself
+ return (options,arguments)
+
+if __name__ == "__main__":
+
+ optionsParser=optparse.OptionParser()
+ optionsParser.add_option('--option','-o',action='store_true',help="sample additional option")
+ optionsParser.add_option('--nosvn','-s',action='store_true',help="no not update from svn")
+ optionsParser.add_option('--nomake','-m',action='store_true',help="no not make")
+
+ (options,arguments)=myoptparse.parseCommandLine(optionsParser)
+ print options.revision
+ print options.testfile
+ print arguments
+
+# (options,arguments)=parseCommandLine(optionsParser,revisionSkip=True)
+# (options,arguments)=parseCommandLine(optionsParser,revisionSkip=True,testfileSkip=True,listfileSkip=True,deviceSkip=True):
Property changes on: trunk/gs/toolbin/tests/myoptparse.py
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/gs/toolbin/tests/run_nightly
===================================================================
--- trunk/gs/toolbin/tests/run_nightly 2007-04-25 20:00:00 UTC (rev 7883)
+++ trunk/gs/toolbin/tests/run_nightly 2007-04-26 23:46:30 UTC (rev 7884)
@@ -1,309 +1,3 @@
-#!/usr/bin/env python
-# -*- Mode: python -*-
+#!/bin/sh
-# Copyright (C) 2001-2006 Artifex Software Inc.
-#
-# This software is provided AS-IS with no warranty, either express or
-# implied.
-#
-# This software is distributed under license and may not be copied,
-# modified or distributed except as expressly authorized under the terms
-# of the license contained in the file LICENSE in this distribution.
-#
-# For more information about licensing, please refer to
-# http://www.ghostscript.com/licensing/. For information on
-# commercial licensing, go to http://www.artifex.com/licensing/ or
-# contact Artifex Software, Inc., 101 Lucas Valley Road #110,
-# San Rafael, CA 94903, U.S.A., +1(415)492-9861.
-
-# $Id$
-
-import os
-import sys
-import re
-import time
-import string
-import gsconf
-import anydbm
-from popen2 import Popen4
-
-# configuration variables
-
-NOW = time.time()
-YESTERDAY = time.strftime("%Y%m%d", time.localtime(NOW - (24*60*60)))
-YESTERDAY_CTIME = time.ctime(NOW - (24*60*60))
-
-def change_gsproduct(file):
- tmpfile = "%s.tmp" % (file,)
-
- startre = re.compile("^#ifndef\ GS_PRODUCT$")
- changere = re.compile("^.*?\"[A-Za-z -]+\".*?$")
- endre = re.compile("^$")
-
- old = open(file, "r")
- new = open(tmpfile, "w")
-
- state = 0
- for line in old.readlines():
- if state == 0:
- m = startre.search(line)
- if m:
- state = 1
-
- new.write(line)
- elif state == 1:
- m = changere.search(line)
- if m:
- state = 2
- new.write("\t\"AFPL Ghostscript\"\n")
- else:
- new.write(line)
- elif state == 2:
- m = endre.search(line)
- if m:
- state = 0
-
- new.write(line)
-
-
- old.close()
- new.close()
-
- os.unlink(file)
- os.rename(tmpfile, file)
-
-def read_fnord(file):
- if os.path.exists(file):
- f = open(file)
- keyword = f.readline()
- keyword = keyword.strip()
- f.close()
- return keyword
- else:
- return ''
-
-def sendmail(frm, to, subject, text):
- import smtplib
-
- keyword = read_fnord(gsconf.codedir + 'fnord')
- if keyword:
- msg = 'From: %s\r\nTo: %s\r\nSubject: %s\r\nX-Fnord: %s\r\n\r\n%s' % (frm, to, subject, keyword, text)
- else:
- msg = 'From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s' % (frm, to, subject, text)
-
- server = smtplib.SMTP(gsconf.mail_server)
- server.sendmail(frm, to, msg)
- server.quit()
-
-def die(msg):
- sendmail(gsconf.report_from, gsconf.report_to, "error running regression", msg)
- sys.exit(0)
-
-def update_ghostscript():
- cwd = os.getcwd()
- os.chdir(gsconf.gsroot)
-
- if os.system("date >> " + gsconf.update_log_stdout) != 0: return (1, None, None, None)
- if os.system("date >> " + gsconf.update_log_stderr) != 0: return (1, None, None)
-
- starttime = time.time()
-
- # undo our product name alteration
- f = "%s/src/gscdef.c" % (gsconf.gsroot,)
- if os.path.exists(f):
- os.unlink(f)
-
- if os.system("svn update >> " + gsconf.update_log_stdout + " 2>> " +
- gsconf.update_log_stderr) != 0: return (1, None, None, None)
-
- os.system("echo 'svn update complete' >> " + gsconf.update_log_stdout)
-
- endtime = time.time()
-
- revision = "unknown"
- p = os.popen("svn info")
- for line in p:
- if line[:10] == "Revision: ":
- revision = line[10:]
- break
-
- os.system("echo 'revision is " + str(revision) + "' >> " +
- gsconf.update_log_stdout)
-
- change_gsproduct("%s/src/gscdef.c" % (gsconf.gsroot,))
-
- os.system("echo 'product change complete' >> " + gsconf.update_log_stdout)
-
- if os.system("./autogen.sh --prefix=/home/regression/gshead/ > " +
- gsconf.config_log_stdout + " 2> " +
- gsconf.config_log_stderr) != 0: return (2, None, None, revision)
-
- os.system("echo 'configuration complete' >> " + gsconf.update_log_stdout)
-
- if os.system("make clean > /dev/null 2> /dev/null") != 0:
- return (-1, None, None, revision)
-
- os.system("echo 'make clean complete' >> " + gsconf.update_log_stdout)
-
- if os.system("make > " + gsconf.make_log_stdout + " 2> " +
- gsconf.make_log_stderr) != 0: return (3, None, None, revision)
-
- os.system("echo 'make complete' >> " + gsconf.update_log_stdout)
-
- if os.system("make install > " + gsconf.install_log_stdout + " 2> " + \
- gsconf.install_log_stderr) != 0: return (4, None, None, revision)
-
- os.system("echo 'make install complete' >> " + gsconf.update_log_stdout)
-
- return (0, starttime, endtime, revision)
-
-def get_file(f):
- file = open(f, 'r')
- lines = file.readlines()
- file.close()
- return string.join(lines, '')
-
-# set umask
-os.umask(0002)
-
-(err, starttime, endtime, revision) = update_ghostscript()
-if err != 0:
- if err == 1:
- msg = "Ghostscript update failed updating from SVN.\n\n"
- msg = msg + "stdout log:\n\n"
- msg = msg + get_file(gsconf.update_log_stdout)
- msg = msg + "\nstderr log:\n\n"
- msg = msg + get_file(gsconf.update_log_stderr)
- die(msg)
- elif err == 2:
- msg = "Ghostscript update failed during configuration.\n\n"
- msg = msg + "stdout log:\n\n"
- msg = msg + get_file(gsconf.make_log_stdout)
- msg = msg + "\nstderr log:\n\n"
- msg = msg + get_file(gsconf.make_log_stderr)
- die(msg)
- elif err == 3:
- msg = "Ghostscript update failed during make.\n\n"
- msg = msg + "stdout log:\n\n"
- msg = msg + get_file(gsconf.make_log_stdout)
- msg = msg + "\nstderr log:\n\n"
- msg = msg + get_file(gsconf.make_log_stderr)
- die(msg)
- elif err == 4:
- msg = "Ghostscript update failed during install.\n\n"
- msg = msg + "stdout log:\n\n"
- msg = msg + get_file(gsconf.install_log_stdout)
- msg = msg + "\nstderr log:\n\n"
- msg = msg + get_file(gsconf.install_log_stderr)
- die(msg)
- else:
- die("Unknown error updating Ghostscript")
-
-# rotate and start new log files
-try:
- for i in range(int(gsconf.rotate) - 1, 0, -1):
- if os.path.isfile(gsconf.log_stdout + ".%d" % (i,)):
- os.rename(gsconf.log_stdout + ".%d" % (i,),
- gsconf.log_stdout + ".%d" % (i + 1,))
- if os.path.isfile(gsconf.log_stderr + ".%d" % (i,)):
- os.rename(gsconf.log_stderr + ".%d" % (i,),
- gsconf.log_stderr + ".%d" % (i + 1,))
- if os.path.isfile(gsconf.log_regression + ".%d" % (i,)):
- os.rename(gsconf.log_regression + ".%d" % (i,),
- gsconf.log_regression + ".%d" % (i + 1,))
-
- if os.path.isfile(gsconf.log_stdout):
- os.rename(gsconf.log_stdout, gsconf.log_stdout + ".1")
- if os.path.isfile(gsconf.log_stderr):
- os.rename(gsconf.log_stderr, gsconf.log_stderr + ".1")
- if os.path.isfile(gsconf.log_regression):
- os.rename(gsconf.log_regression, gsconf.log_regression + ".1")
-
- log = open(gsconf.log_stdout, "w")
- log.close()
- log = open(gsconf.log_stderr, "w")
- log.close()
-except:
- die("The log files were not able to be rotated and opened")
-
-p = os.popen(gsconf.regression_script + " --track 2>&1")
-if p == None:
- die("Could not open and run the regression script.")
-
-regout = '\n\nThe complete list of regressions for today:\n'
-pattern = 'ok$'
-msg = ''
-for line in p.readlines():
- if re.search(pattern, line):
- continue
- regout += line
-
-p.close()
-
-# now do the daily diff
-diff = 'The following regression changes happened since yesterday\'s report:\n'
-
-p = os.popen(gsconf.diff_script + " " + YESTERDAY + " 2>&1")
-if p:
- for line in p.readlines():
- diff = diff + line
- p.close()
-else:
- diff = diff + 'no changes\n'
-
-# Get updated baselines
-baselines = 'The following files had their baselines updated:\n'
-p = Popen4(gsconf.get_baselines + " '" + YESTERDAY_CTIME + "'", 1)
-if p:
- for line in p.fromchild.readlines():
- baselines = baselines + line
- p.wait()
-else:
- baselines = baselines + 'no updates\n'
-baselines += "\n\n"
-
-# Prepend checkout times
-times = "SVN checkout for this report started at " + time.strftime("%a, %d %b %Y %H:%M:%S %Z", time.localtime(starttime)) + "\n"
-times += "SVN checkout ended at " + time.strftime("%a, %d %b %Y %H:%M:%S %Z", time.localtime(endtime)) + "\n"
-times += "complete regression run took %.0f seconds.\n" % (time.time()-NOW)
-times += "Testing revision " + revision + "\n"
-times += "\n"
-
-# Prepend host information
-p = os.popen('hostname -f')
-if p:
- hostname = string.strip(p.readline())
- p.close()
-else:
- hostname = 'unknown host'
-host = "Running regression test on " + hostname + " ("
-p = os.popen('uname -m -o')
-if p:
- host += string.strip(p.readline())
- p.close()
-host += ')\n\n'
-
-# Build the report and capture it in a rotating log file
-log = open(gsconf.log_regression, "w")
-msg = host + times + baselines + diff
-log.write(msg)
-log.write(regout)
-log.close()
-
-# Always include the main body in the email on Mondays
-if time.gmtime().tm_wday == 0:
- msg += regout
-# Otherwise trip by size
-elif len(regout) < 300*1024:
- msg += regout
-else:
- msg += "(report omitted due to length)\n"
-
-retry = 1
-while retry:
- try:
- sendmail(gsconf.report_from, gsconf.report_to, 'gs regression report - %s' % (time.strftime('%Y-%m-%d'),), msg)
- time.sleep(5)
- retry = 0
- except:
- pass
+/home/regression/regression/run_nightly.py
More information about the gs-cvs
mailing list