📄 mtest.py.in
字号:
#!@PYTHON@# The contents of this file are subject to the MonetDB 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://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html## 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 the MonetDB Database System.## The Initial Developer of the Original Code is CWI.# Portions created by CWI are Copyright (C) 1997-2007 CWI.# All Rights Reserved.#TODO:#=====# - check all TODO's below# - tidy -up HTML-generation by "keeping in mind" during testing,# which OUT/ERR differ or not and which tests were skipped.# dump HTML-stuff only at end# print an ascii summary at end, too# - if no diffs, but warnings, say so at end# - produce, keep & reference LOG# - add a "grep-like" function and replace "inlined" grep# contains(<file>,<string>)# - do multi-level prompting?# - normalize all path's used# - remove one of milM, milStry: Trueexcept NameError: # provide values for old Python versions False, True = 0, 1import osimport sysimport fileinputimport popen2import shutilimport reimport randomimport timeimport socketimport structimport select#import signal#import getpassimport Mfilterimport profimport stringF_SKIP = -1F_OK = 0F_WARN = 1F_ERROR = 2FAILURES = { F_SKIP : "F_SKIP", F_OK : "F_OK", F_WARN : "F_WARN", F_ERROR : "F_ERROR"}CONDITIONALS = { # X == true => @X_TRUE@='', @X_FALSE@='#' # X == false => @X_TRUE@='#', @X_FALSE@='' # MonetDB: 'CROSS_COMPILING' : "@CROSS_COMPILING_FALSE@", 'DOCTOOLS' : "@DOCTOOLS_FALSE@", 'HAVE_JAVA' : "@HAVE_JAVA_FALSE@", 'HAVE_PCRE' : "@HAVE_PCRE_FALSE@", 'HAVE_PERL' : "@HAVE_PERL_FALSE@", 'HAVE_PERL_DEVEL' : "@HAVE_PERL_DEVEL_FALSE@", 'HAVE_PERL_SWIG' : "@HAVE_PERL_SWIG_FALSE@", 'HAVE_PHP' : "@HAVE_PHP_FALSE@", 'HAVE_PYTHON' : "@HAVE_PYTHON_FALSE@", 'HAVE_PYTHON_DEVEL': "@HAVE_PYTHON_DEVEL_FALSE@", 'HAVE_PYTHON_SWIG' : "@HAVE_PYTHON_SWIG_FALSE@", 'HAVE_SWIG' : "@HAVE_SWIG_FALSE@", 'LINK_STATIC' : "@LINK_STATIC_FALSE@", 'NOT_WIN32' : "@NOT_WIN32_FALSE@", 'PROFILING' : "@PROFILING_FALSE@", # SQL: 'NATIVE_WIN32' : "@NATIVE_WIN32_FALSE@", # unknown at compile time, as Mtest.py is compiled with MonetDB(4); # hence, we set them at runtime in main() below 'HAVE_MONETDB5' : "@HAVE_MONETDB5_FALSE@", 'HAVE_MONETDB4' : "@HAVE_MONETDB4_FALSE@", 'MONET4' : "@MONET4_FALSE@", 'MONET5' : "@MONET5_FALSE@",}# a bunch of classes to help with generating (X)HTML filesclass _Encode: # mix-in class for encoding text and attribute values so that they # don't get interpreted as something else by the browser def encode(self, data, attr): map = [('&', '&'), # MUST be first ('<', '<'), ('>', '>'), (None, None), # following chars only translated in attr values (attr is True) ('"', '"'), ('\t', '	'), ('\n', ' '), ('\r', ' '), ] for c, tr in map: if c is None: if not attr: break continue data = data.replace(c, tr) return dataclass Element(_Encode): # class to represent an (X)HTML element with its attributes and # children # inline elements, we do not add newlines to the contents of these # elements inline = ['tt','i','b','big','small','em','strong','dfn','code', 'samp','kbd','var','cite','abbr','acronym','a','img', 'object','br','script','map','q','sub','sup','span', 'bdo','input','select','textarea','label','button','font'] # empty elements empty = ['link', 'basefont', 'br', 'area', 'img', 'param', 'hr', 'input', 'col', 'frame', 'isindex', 'base', 'meta', ] xml = True # write XHTML instead of HTML def __init__(self, tag, attrdict = None, *children): self.tag = tag if attrdict is None: attrdict = {} self.attrdict = attrdict if children is None: children = [] self.isempty = tag.lower() in self.empty if self.isempty: if children: raise ValueError("empty element can't have children") self.children = None else: self.children = list(children) def __str__(self): # string representation of the element with its children s = ['<%s' % self.tag] attrlist = self.attrdict.items() attrlist.sort() for name, value in attrlist: s.append(' %s="%s"' % (name, self.encode(value, True))) if self.children or (not self.xml and not self.isempty): s.append('>') for c in self.children: s.append(str(c)) s.append('</%s>' % self.tag) elif self.xml: s.append('/>') else: s.append('>') # empty HTML element return ''.join(s) def write(self, f, newline = False): # write the element with its children to a file # if newline is set, add newlines at strategic points if self.tag.lower() == 'html': # before we write the DOCTYPE we should really check # whether the document conforms... if self.xml: f.write('<!DOCTYPE html PUBLIC ' '"-//W3C//DTD XHTML 1.0 Transitional//EN"\n' ' ' '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n') else: f.write('<!DOCTYPE html PUBLIC ' '"-//W3C//DTD HTML 4.01 Transitional//EN"\n' ' ' '"http://www.w3.org/TR/html4/loose.dtd">\n') inline = self.tag.lower() in self.inline f.write('<%s' % self.tag) attrlist = self.attrdict.items() attrlist.sort() for name, value in attrlist: f.write(' %s="%s"' % (name, self.encode(value, True))) if self.children or (not self.xml and not self.isempty): if not inline: for c in self.children: if not isinstance(c, Element): inline = True break f.write('>') if newline and not inline: f.write('\n') for c in self.children: c.write(f, newline and not inline) f.write('</%s>' % self.tag) elif self.xml: f.write('/>') else: f.write('>') # empty HTML element if newline: f.write('\n') def addchild(self, child): self.children.append(child) def addchildren(self, children): for child in children: self.children.append(child) def inschild(self, index, child): self.children.insert(index, child)class Text(_Encode): # class to represent text in (X)HTML def __init__(self, text = '', raw = False): self.text = text self.raw = raw def __str__(self): if self.raw: return self.text return self.encode(self.text, False) def write(self, f, newline = False): f.write(str(self)) if newline and not self.raw: f.write('\n')class Comment: # class to represent an (X)HTML comment (not currently used) def __init__(self, text): self.text = text def __str__(self): return '<!--%s-->' % self.text def write(self, f, newline = False): f.write(str(self))def _configure(str): # expand configure variables in str and return result config = [ ('${source}', '@QXMONETDB_SOURCE@'), ('${build}', '@QXMONETDB_BUILD@'), ('${bindir}', '@QXbindir@'),## ('${sbindir}', '@QXsbindir@'), ('${libexecdir}', '@QXlibexecdir@'), ('${datarootdir}', '@QXdatarootdir@'), ('${datadir}', '@QXdatadir@'), ('${sysconfdir}', '@QXsysconfdir@'),## ('${sharedstatedir}', '@QXsharedstatedir@'), ('${localstatedir}', '@QXlocalstatedir@'), ('${libdir}', '@QXlibdir@'), ('${includedir}', '@QXincludedir@'),## ('${oldincludedir}', '@QXoldincludedir@'), ('${infodir}', '@QXinfodir@'), ('${mandir}', '@QXmandir@'), ('${Qbindir}', '@QXbindir@'),## ('${Qsbindir}', '@QXsbindir@'), ('${Qlibexecdir}', '@QXlibexecdir@'), ('${Qdatarootdir}', '@QXdatarootdir@'), ('${Qdatadir}', '@QXdatadir@'), ('${Qsysconfdir}', '@QXsysconfdir@'),## ('${Qsharedstatedir}', '@QXsharedstatedir@'), ('${Qlocalstatedir}', '@QXlocalstatedir@'), ('${Qlibdir}', '@QXlibdir@'), ('${Qincludedir}', '@QXincludedir@'),## ('${Qoldincludedir}', '@QXoldincludedir@'), ('${Qinfodir}', '@QXinfodir@'), ('${Qmandir}', '@QXmandir@'), # put these at end (in this order!) for efficiency ('${exec_prefix}', '@QXexec_prefix@'), ('${Qexec_prefix}', '@QXexec_prefix@'), ('${prefix}', '@QXprefix@'), ('${Qprefix}', '@QXprefix@'), ] changed = True while '$' in str and changed: changed = False for key, val in config: nstr = str.replace(key, val) changed = changed or str != nstr str = nstr return str# add dir where monet_options is installed to sys.path# we must expand configure variables in the processsys.path.append(_configure(os.path.join('@QXdatadir@','@PACKAGE@','python')))import monet_optionsSTDOUT = sys.stdoutSTDERR = sys.stdout # errblack = 'black' # #000000white = 'white' # #ffffffred = 'red' # #ff0000lime = 'lime' # #00ff00green = '#00aa00'darkgreen = '#005500'orange = '#ffaa00'stylesheet = Element('style', None, Text('''.error { font-weight: bold; font-style: italic; color: red; }.warning { font-weight: bold; color: orange; }.good { }.header { font-family: helvetica, arial; text-align: center; }.black { color: black; }'''))TIMES = []random.seed(time.time())def Usage (options) : try: monet_options.usage(options, '%s [options] ( [<dir>] [<tests>] | [<dirs>] )' % THISFILE) except monet_options.Error: pass sys.stderr.write(""" <dir> : if present, %(prog)s behaves as if called in <dir>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -