summaryrefslogtreecommitdiffstats
path: root/lib/python/sectracker_test/run.py
blob: ced75d56aec580c62597f33fa4740a40713177d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# sectracker_tests/run.py -- run Python tests with the correct search path
# Copyright (C) 2010 Florian Weimer <fw@deneb.enyo.de>
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from __future__ import print_function

if __name__ != "__main__":
    raise Exception("run must be executed directly")

import os.path
import subprocess
import sys

def pathsetup():
    prefix = sys.path[0]
    trailer = "/sectracker_test"
    if not os.path.exists(prefix + "/run.py") \
            or prefix[-len(trailer):] != trailer:
        raise Exception("cannot find path to ourselves")
    path = sys.path[:]
    path[0] = prefix[:-len(trailer)]
    return (prefix, path)
(ourpath, pythonpath) = pathsetup()
os.chdir(ourpath + "/..")

env = {}
env.update(os.environ)
env["PYTHONPATH"] = ":".join(pythonpath)

files = os.listdir(ourpath)
files.sort()
errors = False
for name in files:
    if name[-3:] != ".py" or name == "run.py":
        continue
    fullpath = "%s/%s" % (ourpath, name)
    print("* Running", name)
    p = subprocess.Popen(("python3", "--", fullpath), env=env)
    ret = p.wait()
    if ret != 0:
        print("Test exited with status", ret)
        print()
    errors = errors or ret != 0
if errors:
    print("ERROR: some tests aborted with errors")
    sys.exit(1)

© 2014-2024 Faster IT GmbH | imprint | privacy policy