tests/run-multitests.py: Change to dir of test script when running it.
This matches the behaviour of run-tests.py, which sets cwd to the directory containing the test script, which helps to isolate the filesystem. It means that the SSL tests no longer need to know the name of their containing directory to find the certificate files, and helps to run these tests on bare-metal. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
a003ac2f73
commit
f0392b8d3d
@ -11,8 +11,8 @@ except ImportError:
|
||||
PORT = 8000
|
||||
|
||||
# These are test certificates. See tests/README.md for details.
|
||||
cert = cafile = "multi_net/rsa_cert.der"
|
||||
key = "multi_net/rsa_key.der"
|
||||
cert = cafile = "rsa_cert.der"
|
||||
key = "rsa_key.der"
|
||||
|
||||
try:
|
||||
os.stat(cafile)
|
||||
|
@ -11,8 +11,8 @@ except ImportError:
|
||||
PORT = 8000
|
||||
|
||||
# These are test certificates. See tests/README.md for details.
|
||||
cert = cafile = "multi_net/rsa_cert.der"
|
||||
key = "multi_net/rsa_key.der"
|
||||
cert = cafile = "rsa_cert.der"
|
||||
key = "rsa_key.der"
|
||||
|
||||
try:
|
||||
os.stat(cafile)
|
||||
|
@ -11,8 +11,8 @@ except ImportError:
|
||||
PORT = 8000
|
||||
|
||||
# These are test certificates. See tests/README.md for details.
|
||||
cert = cafile = "multi_net/rsa_cert.der"
|
||||
key = "multi_net/rsa_key.der"
|
||||
cert = cafile = "rsa_cert.der"
|
||||
key = "rsa_key.der"
|
||||
|
||||
try:
|
||||
os.stat(cafile)
|
||||
|
@ -11,8 +11,8 @@ except ImportError:
|
||||
PORT = 8000
|
||||
|
||||
# These are test certificates. See tests/README.md for details.
|
||||
cert = cafile = "multi_net/rsa_cert.der"
|
||||
key = "multi_net/rsa_key.der"
|
||||
cert = cafile = "rsa_cert.der"
|
||||
key = "rsa_key.der"
|
||||
|
||||
try:
|
||||
os.stat(cafile)
|
||||
|
@ -10,8 +10,8 @@ except ImportError:
|
||||
PORT = 8000
|
||||
|
||||
# These are test certificates. See tests/README.md for details.
|
||||
certfile = "multi_net/rsa_cert.der"
|
||||
keyfile = "multi_net/rsa_key.der"
|
||||
certfile = "rsa_cert.der"
|
||||
keyfile = "rsa_key.der"
|
||||
|
||||
try:
|
||||
os.stat(certfile)
|
||||
|
@ -11,8 +11,8 @@ except ImportError:
|
||||
PORT = 8000
|
||||
|
||||
# These are test certificates. See tests/README.md for details.
|
||||
cert = cafile = "multi_net/rsa_cert.der"
|
||||
key = "multi_net/rsa_key.der"
|
||||
cert = cafile = "rsa_cert.der"
|
||||
key = "rsa_key.der"
|
||||
|
||||
try:
|
||||
os.stat(cafile)
|
||||
|
@ -12,8 +12,8 @@ except ImportError:
|
||||
PORT = 8000
|
||||
|
||||
# These are test certificates. See tests/README.md for details.
|
||||
cert = cafile = "multi_net/rsa_cert.der"
|
||||
key = "multi_net/rsa_key.der"
|
||||
cert = cafile = "rsa_cert.der"
|
||||
key = "rsa_key.der"
|
||||
|
||||
try:
|
||||
os.stat(cafile)
|
||||
|
@ -11,8 +11,8 @@ except ImportError:
|
||||
PORT = 8000
|
||||
|
||||
# These are test certificates. See tests/README.md for details.
|
||||
certfile = "multi_net/rsa_cert.der"
|
||||
keyfile = "multi_net/rsa_key.der"
|
||||
certfile = "rsa_cert.der"
|
||||
keyfile = "rsa_key.der"
|
||||
|
||||
try:
|
||||
os.stat(certfile)
|
||||
|
@ -11,8 +11,8 @@ except ImportError:
|
||||
PORT = 8000
|
||||
|
||||
# These are test certificates. See tests/README.md for details.
|
||||
cert = cafile = "multi_net/rsa_cert.der"
|
||||
key = "multi_net/rsa_key.der"
|
||||
cert = cafile = "rsa_cert.der"
|
||||
key = "rsa_key.der"
|
||||
|
||||
try:
|
||||
os.stat(cafile)
|
||||
|
@ -11,8 +11,8 @@ except ImportError:
|
||||
PORT = 8000
|
||||
|
||||
# These are test certificates. See tests/README.md for details.
|
||||
cert = cafile = "multi_net/rsa_cert.der"
|
||||
key = "multi_net/rsa_key.der"
|
||||
cert = cafile = "rsa_cert.der"
|
||||
key = "rsa_key.der"
|
||||
|
||||
try:
|
||||
os.stat(cafile)
|
||||
|
@ -11,8 +11,8 @@ except ImportError:
|
||||
PORT = 8000
|
||||
|
||||
# These are test certificates. See tests/README.md for details.
|
||||
cert = cafile = "multi_net/rsa_cert.der"
|
||||
key = "multi_net/rsa_key.der"
|
||||
cert = cafile = "rsa_cert.der"
|
||||
key = "rsa_key.der"
|
||||
|
||||
try:
|
||||
os.stat(cafile)
|
||||
|
@ -11,8 +11,8 @@ except ImportError:
|
||||
PORT = 8000
|
||||
|
||||
# These are test certificates. See tests/README.md for details.
|
||||
cert = cafile = "multi_net/expired_cert.der"
|
||||
key = "multi_net/rsa_key.der"
|
||||
cert = cafile = "expired_cert.der"
|
||||
key = "rsa_key.der"
|
||||
|
||||
try:
|
||||
os.stat(cafile)
|
||||
|
@ -27,13 +27,15 @@ import pyboard
|
||||
|
||||
if os.name == "nt":
|
||||
CPYTHON3 = os.getenv("MICROPY_CPYTHON3", "python3.exe")
|
||||
MICROPYTHON = os.getenv(
|
||||
"MICROPY_MICROPYTHON", test_dir + "/../ports/windows/build-standard/micropython.exe"
|
||||
MICROPYTHON = os.path.abspath(
|
||||
os.getenv(
|
||||
"MICROPY_MICROPYTHON", test_dir + "/../ports/windows/build-standard/micropython.exe"
|
||||
)
|
||||
)
|
||||
else:
|
||||
CPYTHON3 = os.getenv("MICROPY_CPYTHON3", "python3")
|
||||
MICROPYTHON = os.getenv(
|
||||
"MICROPY_MICROPYTHON", test_dir + "/../ports/unix/build-standard/micropython"
|
||||
MICROPYTHON = os.path.abspath(
|
||||
os.getenv("MICROPY_MICROPYTHON", test_dir + "/../ports/unix/build-standard/micropython")
|
||||
)
|
||||
|
||||
# For diff'ing test output
|
||||
@ -155,6 +157,7 @@ class PyInstance:
|
||||
class PyInstanceSubProcess(PyInstance):
|
||||
def __init__(self, argv, env=None):
|
||||
self.argv = argv
|
||||
self.cwd = None
|
||||
self.env = {n: v for n, v in (i.split("=") for i in env)} if env else None
|
||||
self.popen = None
|
||||
self.finished = True
|
||||
@ -163,8 +166,9 @@ class PyInstanceSubProcess(PyInstance):
|
||||
return self.argv[0].rsplit("/")[-1]
|
||||
|
||||
def prepare_script_from_file(self, filename, prepend, append):
|
||||
# Make tests run in an isolated environment (i.e. `import io` would
|
||||
# otherwise get the `tests/io` directory).
|
||||
# Make tests run in the directory of the test file, and in an isolated environment
|
||||
# (i.e. `import io` would otherwise get the `tests/io` directory).
|
||||
self.cwd = os.path.dirname(filename)
|
||||
remove_cwd_from_sys_path = b"import sys\nsys.path.remove('')\n\n"
|
||||
return remove_cwd_from_sys_path + super().prepare_script_from_file(
|
||||
filename, prepend, append
|
||||
@ -179,6 +183,7 @@ class PyInstanceSubProcess(PyInstance):
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
input=script,
|
||||
cwd=self.cwd,
|
||||
env=self.env,
|
||||
)
|
||||
output = p.stdout
|
||||
@ -192,6 +197,7 @@ class PyInstanceSubProcess(PyInstance):
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
cwd=self.cwd,
|
||||
env=self.env,
|
||||
)
|
||||
self.finished = False
|
||||
|
Loading…
Reference in New Issue
Block a user