spark-test commented on code in PR #60617:
URL: https://github.com/apache/spark/pull/60617#discussion_r4608147058
##########
dev/run-tests.py:
##########
@@ -401,6 +403,14 @@ def run_sparkr_tests():
print("Ignoring SparkR tests as R was not found in PATH")
+def parse_test_modules(value: str) -> list[modules.Module]:
+ try:
+ return resolve_test_modules(parse_module_names(value))
+ except ValueError as error:
+ # argparse drops ValueError text, so we wrap it as an
ArgumentTypeError.
+ raise ArgumentTypeError(str(error))
Review Comment:
**Nit (P3):** `parse_test_modules` is what carries the resolver's message,
the list of unrecognized and supported modules, into the error that
`dev/run-tests --modules` prints, but no test reaches it.
`ResolveTestModulesTests` and the doctests call only `parse_module_names` and
`resolve_test_modules`, and nothing under `dev/sparktestsupport/tests` loads
`dev/run-tests.py`.
In a repro with this `try`/`except` removed, so that the `ValueError`
reaches argparse, `--modules core,typo-module` still exits 2, but the error
line becomes `run-tests: error: argument -m/--modules: invalid
parse_test_modules value: 'core,typo-module'`. That echoes the raw value
without saying which name is unrecognized or listing the supported modules, and
the `sparktestsupport` tests run against that copy gave the same results as on
the unmodified code.
The message is correct today; the gap is only that a later edit could lose
it without any test failing. A test that drives `parse_opts()` and asserts the
resolver's wording would catch that.
**Verification:**
- **Regression:** Drive the `dev/run-tests` option parser with `--modules
core,typo-module` and check that it exits with status 2 and that the error
contains `unrecognized module(s): 'typo-module'` and `Supported modules:`.
Checking only that `typo-module` or `core` appears is not enough, because when
the resolver's `ValueError` reaches argparse the error becomes `invalid
parse_test_modules value: 'core,typo-module'`, which still contains both names.
Then confirm the check fails once the converter in `parse_test_modules`
(dev/run-tests.py, lines 406-411) is reduced to `return
resolve_test_modules(parse_module_names(value))`.
- **Behavior:** Drive the same option parser with a value that has no module
names, such as `' , '`, and check for exit status 2 with the `no module names
were provided` error. Then drive it with a registered list such as `' graphx,
core ,'` and check that it still yields the core and graphx modules in the
module registry's order.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]