-
-
Notifications
You must be signed in to change notification settings - Fork 32k
regrtest: simplify regex to match test names for the --fromfile option #73221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Lib/test/libregrtest/main.py uses a complex regex to find "test_builtin" in lines like '0:00:00 [ 4/400] test_builtin -- test_dict took 1 sec'. Recently, I changed (change d8222c197831) the regex to support a filename containing a list of filenames. Example: haypo@selma$ ls Lib/test/test_*xml*py >| list haypo@selma$ cat list haypo@selma$ ./python -m test --fromfile=list --list Serhiy sent me a private message to suggest to simply the regex. So here is a patch. |
FYI initially my idea was to use a very strict to avoid false positives. But when I used the feature, I found that the regex is more annoying than helping (ex: I had to modify the regex to accept filenames with directories). So I now prefer to use a very simple regex matching "test_xxx" anywhere, to have something simple and convenient. |
Reading file names from a file looks misleading. $ ls Lib/ctypes/test/*.py > list
$ head list
Lib/ctypes/test/__init__.py
Lib/ctypes/test/__main__.py
Lib/ctypes/test/test_anon.py
Lib/ctypes/test/test_array_in_pointer.py
Lib/ctypes/test/test_arrays.py
Lib/ctypes/test/test_as_parameter.py
Lib/ctypes/test/test_bitfields.py
Lib/ctypes/test/test_buffers.py
Lib/ctypes/test/test_bytes.py
Lib/ctypes/test/test_byteswap.py
$ ./python -m test --fromfile=list
Run tests sequentially
0:00:00 [ 1/51] test_anon
test test_anon crashed -- Traceback (most recent call last):
File "/home/serhiy/py/cpython/Lib/test/libregrtest/runtest.py", line 152, in runtest_inner
the_module = importlib.import_module(abstest)
File "/home/serhiy/py/cpython/Lib/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'test.test_anon'
... I wouldn't add this feature unless support full file names. |
Ah right, "Lib/ctypes/test/test_anon.py" doesn't work. I don't think --fromfile is written for developers who understand what they do, it's But please keep support for simple lists like "ls |
I don't understand the use case of it ;) , but when you need it, the patch LGTM. You can call just .group() instead of .group(0). |
New changeset a9fe5bee892b by Victor Stinner in branch 'default': |
When I modify a codec or something related to text codecs, I would like to run all codec tests, not the fully Python test suite. So I use "ls Lib/test/test_*codec*py", the list is quite list, it's annoying to have to copy/paste test names manually.
Done. Thanks for your review. I added a new unit test for filenames. |
I would use
|
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: