Page MenuHomePhabricator

Quibble space separated options shallow arguments
Closed, ResolvedPublic

Description

Quibble has a few options that accepts multiples space separated values:

quibble 
  [--run [RUN [RUN ...]]]
  [--skip [SKIP [SKIP ...]]]
  [--commands [command [command ...]]]
  [projects [projects ...]]

So if one wants to run an explicit stage and pass some project as arguments such as:

quibble --run phpunit mediawiki/extensions/BoilerPlate

What happens is:

run['phpunit', 'mediawiki/extensions/BoilerPlate']
project[]

--run and --skip can be made ''choices'' which would only allow existing stages or all, then the project will be populated.

But --commands can be anything arbitrary. I think I will repurpose that one to accept a single value but allow multiple occurrences of it. Ie:

quibble --command 'ls -l' --command 'cat foo'

Event Timeline

hashar created this task.Mar 14 2019, 8:41 PM

Change 496125 had a related patch set uploaded (by Hashar; owner: Hashar):
[integration/quibble@master] Better arg handling

https://gerrit.wikimedia.org/r/496125

hashar moved this task from Backlog to Defect on the Quibble board.Mar 18 2019, 2:44 PM

The root cause is we have multiple arguments with args='*':

--run, --skip

Used to specify stages, since we know the stages we can migrate that to choices instead.

--commands

Run arbitrary shell snippets with:

for cmd in cmds:
    log.info(cmd)
    subprocess.check_call(cmd, shell=True, cwd=cwd)

Eg via: --commands 'echo hello' 'exec phpunit --debug'. At least in CI configs we only pass a single command, usually a shell script which is defined in the container.

I guess we can allow --commands to only get a single argument but accumulate them in a list using action='append'

projects

Additional repositories to clone.

The job mediawiki-selenium-integration-docker works around the issue by using double dashes to stop argparse from processing an option and move to the next option or argument:

--commands=mwselenium -- mediawiki/selenium
                     ^^^^

projects should be the only one using args='*' to avoid mistakes when one forget to use -- to stop processing.

hashar claimed this task.Mar 26 2019, 12:46 PM
hashar moved this task from Defect to In progress on the Quibble board.Mar 26 2019, 1:47 PM

Change 496125 merged by jenkins-bot:
[integration/quibble@master] Better arg handling

https://gerrit.wikimedia.org/r/496125

hashar closed this task as Resolved.Apr 17 2019, 11:44 AM