diff options
| author | Damien George <damien@micropython.org> | 2025-10-03 22:50:20 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-10-20 11:18:59 +1100 |
| commit | 60edfeeead49cba018c9695a0fa10f812b1e04d9 (patch) | |
| tree | 705a9114eaf9a8dafe9c33c50d9013b200e09f7d | |
| parent | 93f13dd88291b54d4fcd8acafe5c1f8ac6d823df (diff) | |
tests/run-tests.py: Raise OSError on invalid file open for injected FS.
This makes sure that `open()` raises `OSError(ENOENT)` if the test script
attempts to open a file that does not exist.
For example, the test `tests/ports/esp32/check_err_str.py` attempts to do
this and this test currently fails when run with `--via-mpy` because the
injected filesystem lets a file by any name be opened.
The fix here tries to be as minimal as possible, so includes a size
optimisation for `stat()` to use a fixed 10-tuple. It also fixes the
`OSError` argument, which should be positive.
Signed-off-by: Damien George <damien@micropython.org>
| -rwxr-xr-x | tests/run-tests.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/run-tests.py b/tests/run-tests.py index 82a6a3d97..202abfacb 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -88,10 +88,11 @@ class __FS: return "" def stat(self, path): if path == '__injected_test.mpy': - return tuple(0 for _ in range(10)) + return (0,0,0,0,0,0,0,0,0,0) else: - raise OSError(-2) # ENOENT + raise OSError(2) # ENOENT def open(self, path, mode): + self.stat(path) return __File() vfs.mount(__FS(), '/__vfstest') os.chdir('/__vfstest') |
