Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tests/runExtraTests.py
169656 views
1
#!/usr/bin/env python
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2008-2025 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file runExtraTests.py
15
# @author Michael Behrisch
16
# @date 2012-03-29
17
18
19
import argparse
20
import glob
21
import logging
22
import os
23
import subprocess
24
25
26
def run(suffix, args, guiTests=False, chrouter=True):
27
if type(args) is list:
28
args = " ".join(args)
29
if os.name != "posix":
30
suffix += ".exe"
31
env = os.environ
32
root = os.path.abspath(os.path.dirname(__file__))
33
for d in sorted(glob.glob(os.path.join(root, "*env", "*", "activate"))):
34
env_dir = os.path.dirname(os.path.dirname(d))
35
if env.get("VIRTUAL_ENV"):
36
print("Virtual environment %s already active, ignoring %s." % (env["VIRTUAL_ENV"], env_dir))
37
else:
38
print("Using virtual environment %s." % env_dir)
39
env["VIRTUAL_ENV"] = env_dir
40
if os.name != "posix":
41
env["PATH"] = "%s\\Scripts;%s" % (env_dir, env["PATH"])
42
else:
43
env["PATH"] = "%s/bin:%s" % (env_dir, env["PATH"])
44
45
env["TEXTTEST_HOME"] = root
46
env["LANG"] = "C"
47
if "SUMO_HOME" not in env:
48
env["SUMO_HOME"] = os.path.join(root, "..")
49
for binary in ("activitygen", "emissionsDrivingCycle", "emissionsMap",
50
"dfrouter", "duarouter", "jtrrouter", "marouter",
51
"netconvert", "netedit", "netgenerate",
52
"od2trips", "polyconvert", "sumo"):
53
env[binary.upper() + "_BINARY"] = os.path.join(root, "..", "bin", binary + suffix)
54
env["GUISIM_BINARY"] = os.path.join(root, "..", "bin", "sumo-gui" + suffix)
55
apps = ("sumo.extra,sumo.extra.gcf,sumo.extra.sf,sumo.meso,"
56
"sumo.agg.ballistic,sumo.agg.idm,sumo.agg.sublanes,"
57
"sumo.astar,sumo.parallel,duarouter.astar,netconvert.gdal,polyconvert.gdal,"
58
"complex.meso,complex.libsumo,complex.libtraci")
59
if chrouter:
60
apps += ",duarouter.chrouter,duarouter.chwrapper"
61
if guiTests:
62
apps += ",sumo.meso.gui,sumo.gui.osg"
63
if os.name == "posix":
64
apps += ",complex.libsumo.gui"
65
process = subprocess.Popen("%s %s -a %s" % ("texttest", args, apps), env=env,
66
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
67
with process.stdout:
68
for line in process.stdout:
69
logging.info(line)
70
process.wait()
71
72
73
if __name__ == "__main__":
74
optParser = argparse.ArgumentParser()
75
optParser.add_argument("-s", "--suffix", default="", help="suffix to the fileprefix")
76
optParser.add_argument("-g", "--gui", default=False, action="store_true", help="run gui tests")
77
options, args = optParser.parse_known_args()
78
run(options.suffix, ["-" + a for a in args], options.gui)
79
80