Commit cc1af1d
ingest_mdir: fix --list-tests handling
There are 2 problems with the --list-tests command:
- The arguments --tree and the --patch/--mdir group are marked as
required=True, forcing argparse to demand them even when they aren't
needed (like for --list-tests).
- The main() function tries to access args.tree before checking if
--list-tests was specified, which would cause a crash even if the
parser requirement was removed. This problem is masked by the first
one, so it makes sense to handle them together.
$ ./ingest_mdir.py --list-tests # should have succeeded
ingest_mdir.py: error: the following arguments are required: --tree
$ ./ingest_mdir.py --tree dummy --list-tests
ingest_mdir.py: error: one of the arguments --patch --mdir is required
$ ./ingest_mdir.py --tree dummy --patch dummy2 --list-tests # only this variant succeeds
Remove the required=True from the patch_arg group and the --tree
argument, and add manual handling for them if --list-tests wasn't
specified.
Also, move the args.tree dereference after the list_tests check and
the manual verification that the argument was provided.
Signed-off-by: Vladimir Oltean <[email protected]>1 parent ee7cf4a commit cc1af1d
1 file changed
+12
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
290 | | - | |
291 | 289 | | |
292 | 290 | | |
293 | 291 | | |
| 292 | + | |
294 | 293 | | |
295 | 294 | | |
296 | 295 | | |
297 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
298 | 306 | | |
299 | 307 | | |
300 | 308 | | |
| |||
0 commit comments