srcanamdw/codescanner/pyinstaller/buildtests/runtests.py
author noe\swadi
Thu, 18 Feb 2010 12:29:02 +0530
changeset 1 22878952f6e2
permissions -rw-r--r--
Committing the CodeScanner Core tool This component has been moved from the StaticAnaApps package. BUG : 5889 (http://developer.symbian.org/webbugs/show_bug.cgi?id=5889).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     1
#!/usr/bin/env python
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     2
# Copyright (C) 2005, Giovanni Bajo
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     3
# Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc.
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     4
#
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     5
# This program is free software; you can redistribute it and/or
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     6
# modify it under the terms of the GNU General Public License
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     7
# as published by the Free Software Foundation; either version 2
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     8
# of the License, or (at your option) any later version.
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     9
#
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    10
# This program is distributed in the hope that it will be useful,
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    13
# GNU General Public License for more details.
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    14
#
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    16
# along with this program; if not, write to the Free Software
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    18
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    19
# This program will execute any file with name test*<digit>.py. If your test
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    20
# need an aditional dependency name it test*<digit><letter>.py to be ignored
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    21
# by this program but be recognizable by any one as a dependency of that
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    22
# particual test.
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    23
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    24
import os, sys, glob, string
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    25
import shutil
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    26
try:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    27
    here=os.path.dirname(__file__)
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    28
except NameError:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    29
    here=os.path.dirname(sys.argv[0])
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    30
PYTHON = sys.executable
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    31
if sys.platform[:3] == 'win':
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    32
    if string.find(PYTHON, ' ') > -1:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    33
        PYTHON='"%s"' % PYTHON
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    34
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    35
def clean():
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    36
    distdirs = glob.glob(os.path.join(here, 'disttest*'))
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    37
    for dir in distdirs:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    38
        try:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    39
            shutil.rmtree(dir)
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    40
        except OSError, e:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    41
            print e
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    42
    builddirs = glob.glob(os.path.join(here, 'buildtest*'))
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    43
    for dir in builddirs:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    44
        try:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    45
            shutil.rmtree(dir)
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    46
        except OSError, e:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    47
            print e
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    48
    wfiles = glob.glob(os.path.join(here, 'warn*.txt'))
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    49
    for file in wfiles:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    50
        try:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    51
            os.remove(file)
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    52
        except OSError, e:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    53
            print e
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    54
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    55
def runtests():
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    56
    global here
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    57
    sources = glob.glob(os.path.join(here, 'test*[0-9].py'))
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    58
    path = os.environ["PATH"]
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    59
    for src in sources:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    60
        print
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    61
        print "################## EXECUTING TEST %s ################################" % src
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    62
        print
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    63
        test = os.path.splitext(os.path.basename(src))[0]
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    64
        os.system('%s ../Build.py %s' % (PYTHON, test+".spec"))
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    65
        # Run the test in a clean environment to make sure they're really self-contained
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    66
        del os.environ["PATH"]
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    67
        os.system('dist%s%s%s' % (test, os.sep, test))
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    68
        os.environ["PATH"] = path
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    69
        print "################## FINISHING TEST %s  ################################" % src
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    70
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    71
if __name__ == '__main__':
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    72
    if len(sys.argv) == 1:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    73
        clean()
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    74
        runtests()
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    75
    if '--clean' in sys.argv:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    76
        clean()
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    77
    if '--run' in sys.argv:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    78
        runtests()
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    79
    raw_input("Press any key to exit")