Skip to content
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

Add |wpt| command frontend #6237

Closed
wants to merge 5 commits into from
Closed

Add |wpt| command frontend #6237

wants to merge 5 commits into from

Conversation

jgraham
Copy link
Contributor

@jgraham jgraham commented Jun 14, 2017

This change is Reviewable

@jgraham
Copy link
Contributor Author

jgraham commented Jun 14, 2017

Not quite done yet (missing docs), but should work in the current state.

@bobholt
Copy link
Contributor

bobholt commented Jun 14, 2017

One apparent bug, and yes, docs are welcome.

Realizing this may be a bit of a naive question: Why this approach and not something like setup.py where wpt aliases run/install/etc. commands in setup.py?


Reviewed 11 of 11 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks pending.


tools/lint/lint.py, line 768 at r1 (raw file):

if __name__ == "__main__":
    args = create_parser.parse_args()

Looks like this should be create_parser().parse_args().


Comments from Reviewable

@jgraham
Copy link
Contributor Author

jgraham commented Jun 14, 2017

AFAIK if you create a setup.py then the user has to create their own virtualenv and run python setup.py install &c. Making it possible to run everything from a single command without any setup apart from cloning the repo is very desirable (we could consider adding a command to install the virtualenv tool as well, for example). This approach is based heavily — in spirit if not im implementation — on Mozilla's mach command, which has the same advantage of not requiring any python-specific knowledge to e.g. start a build.

@w3c-bots
Copy link

w3c-bots commented Jun 14, 2017

View the complete job log.

Firefox (nightly)

Testing web-platform-tests at revision 6967685
Using browser at version BuildID 20170612100241; SourceStamp 27cad9749cddf68e11fdd4e5d73dad84a8f8cf23
Starting 10 test iterations
No tests run.

@w3c-bots
Copy link

w3c-bots commented Jun 14, 2017

View the complete job log.

Sauce (safari)

Testing web-platform-tests at revision 6967685
Using browser at version 10.0
Starting 10 test iterations
No tests run.

@w3c-bots
Copy link

w3c-bots commented Jun 14, 2017

View the complete job log.

Chrome (unstable)

Testing web-platform-tests at revision 6967685
Using browser at version 61.0.3141.7 dev
Starting 10 test iterations
No tests run.

@w3c-bots
Copy link

w3c-bots commented Jun 14, 2017

View the complete job log.

Sauce (MicrosoftEdge)

Testing web-platform-tests at revision 6967685
Using browser at version 14.14393
Starting 10 test iterations
No tests run.

@jugglinmike
Copy link
Contributor

Happy to see further consolidation happening. This patch omits at least three files: /wpt, /tools/lint/commands.json, /tools/manifest/commands.json. I recommend naming those "commands" files wpt_commands.json to give a hint about their purpose in the otherwise-unrelated directories. I'll hold off on further review until I'm able to play with this locally.

README.md Outdated

* `wpt run` - For running tests in a browser
* `wpt lint` - For running the lint against all tests
* `wpt manifest` - For updating or generating a `MANIFEST.json` test manifest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intentionally omit install-browser?


if __name__ == '__main__':
args = parser.parse_args()
run(None, **vars(args))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the new wpt utility exposing the functionality from a more unified
interface, I can't think of a reason to maintain this module as an executable.
What do you say we remove this and update ci_unittest.sh to use wpt
instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you've updated ci_unittest.sh, but this script is still executable. Do you have a use case in mind for executing this file directly?

tools/wpt/wpt.py Outdated
parser.add_argument("--venv", action="store", help="Path to an existing virtualenv to use")
parser.add_argument("--debug", action="store_true", help="Run the debugger in case of an exception")
subparsers = parser.add_subparsers(dest="command")
for command, props in commands.iteritems():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other parts of WPT's infrastructure are tested in Python 3; are you interested
in supporting that platform with the wpt utility? I'm not the best choice for
reviewing for Python 3 compatibility concerns, but I could try (e.g.
iteritems isn't available there). If not, I'll refrain from pointing out
incompatibilities.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shrug. I guess I ought to make this work with Python 3, but wptrunner doesn't, for example, so it won't be super useful.

tools/wpt/run.py Outdated
@@ -1,3 +1,4 @@
# wpt command:run:main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having trouble understanding the purpose of this comment. Is it a vestige of some previous implementation strategy? Or am I missing something about the current patch?


update_from_cli(**vars(opts))
print run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errant print statement

@@ -0,0 +1,2 @@
{"install-browser": {"path": "install.py", "script": "run", "parser": "get_parser", "help": "Install browser components",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wpt install-browser firefox browser looks a bit redundant, while wpt install-browser firefox webdriver is a little misleading. What do you think
about calling this sub-command install instead?

tools/wpt/run.py Outdated
@@ -295,10 +310,7 @@ def main():
venv.install_requirements(os.path.join(wpt_root, "tools", "wptrunner", "requirements.txt"))
venv.install("requests")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary, but it allows the file to be run directly from the command line, which seems somewhat useful to keep for now.

@@ -0,0 +1,2 @@
{"run": {"path": "run.py", "script": "run", "parser": "create_parser", "help": "Run tests in a browser",
"virtualenv": true, "install": ["requests"], "requirements": ["../wptrunner/requirements.txt"]}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the "requests" module is necessary to use the wptrunner module, why isn't it listed in wptrunner/requirements.txt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's necessary to install the browser/webdriver/prefs/etc. so it's a requirement for wpt run but not for wptrunner itself.

@jgraham jgraham force-pushed the wpt_frontend branch 4 times, most recently from b78831b to c2c13cd Compare June 19, 2017 17:25
@jgraham jgraham force-pushed the wpt_frontend branch 3 times, most recently from 40ef52c to 7aa63c8 Compare June 20, 2017 13:27
@jgraham jgraham force-pushed the wpt_frontend branch 2 times, most recently from 5ded5b9 to 00a0fcd Compare June 23, 2017 12:12
@jgraham
Copy link
Contributor Author

jgraham commented Jun 23, 2017

This is ready and waiting for review.

Copy link
Contributor

@jugglinmike jugglinmike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README.md file contains a few lingering references to wptrun: wptrun --help, wptrun --wptrunner-help wptrun --binary=path product (I don't think this last one is supported by wpt, though).

The lint.whitelist file includes a reference to the wptrun.py file that this patch renames. The tests pass, so I guess this can be removed (rather than updated).

Would you mind removing the wptrun, lintandwhitelist` executables from the top level of the project?


if __name__ == '__main__':
args = parser.parse_args()
run(None, **vars(args))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you've updated ci_unittest.sh, but this script is still executable. Do you have a use case in mind for executing this file directly?

tools/wpt/run.py Outdated
@@ -7,11 +7,14 @@
import tarfile
from distutils.spawn import find_executable

wpt_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend os.pardir for consistency with the change to tools/manifest/update.py.

tools/wpt/wpt.py Outdated


here = os.path.dirname(__file__)
wpt_root = os.path.abspath(os.path.join(here, "..", ".."))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment regarding os.pardir

@jgraham
Copy link
Contributor Author

jgraham commented Jun 26, 2017

I want to leave the executables for now in case downstream consumers are making use of them in scripts or integrations. They can be removed in a followup once this has been announced.

@jgraham
Copy link
Contributor Author

jgraham commented Jun 28, 2017

@jugglinmike updated this.

@jugglinmike
Copy link
Contributor

Got it. This latest version is rebased on master, but I can't execute wptrun from master at the moment, so I'll need to work that out before I can continue the review here. See #6375 (comment)

@jugglinmike
Copy link
Contributor

A couple of the documented options for the run sub-command do not work.

Specifying --binary produces the following output:

$ ./wptrun --binary /opt/mozilla/firefox-nightly/firefox firefox url/a-element.html 
usage: wptrun [-h] [--yes] [--wptrunner-help] product [tests [tests ...]] ...
wptrun: error: unrecognized arguments: --binary

Specifying --wptrunner-help produces the following output:

$ ./wpt run --wptrunner-help
Traceback (most recent call last):
  File "./wpt", line 5, in <module>
    wpt.main()
  File "/home/mike/projects/bocoup/google-wpt/web-platform-tests/tools/wpt/wpt.py", line 100, in main
    kwargs = vars(parser.parse_args(command_args))
  File "/usr/lib/python2.7/argparse.py", line 1701, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python2.7/argparse.py", line 1733, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python2.7/argparse.py", line 1939, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib/python2.7/argparse.py", line 1879, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib/python2.7/argparse.py", line 1807, in take_action
    action(self, namespace, argument_values, option_string)
  File "/home/mike/projects/bocoup/google-wpt/web-platform-tests/tools/wpt/run.py", line 37, in __call__
    from wptrunner import wptcommandline
  File "/home/mike/projects/bocoup/google-wpt/web-platform-tests/tools/wptrunner/wptrunner/wptcommandline.py", line 9, in <module>
    import wpttest
  File "/home/mike/projects/bocoup/google-wpt/web-platform-tests/tools/wptrunner/wptrunner/wpttest.py", line 4, in <module>
    import mozinfo
ImportError: No module named mozinfo

...although I receive similar errors when using wptrun as defined in master today.

This is intended to provide a single point of entry for all wpt
commands and make it easier to share infrastructure like
virtual environments. Commands are defined via a commands.json file in
the directory containing the command.

This isi still pretty rough, but it basically works.
@gsnedders
Copy link
Member

There's a lot of new untested code here, especially given @jugglinmike found issues earlier. :/

@jugglinmike
Copy link
Contributor

The command wptrun firefox url/a-element.html now executes as expected, but
the equivalent using the wpt executable still produces that error on my
system:

$ ./wpt run firefox url/a-element.html 
Traceback (most recent call last):
  File "./wpt", line 5, in <module>
    wpt.main()
  File "/home/mike/projects/bocoup/google-wpt/web-platform-tests/tools/wpt/wpt.py", line 98, in main
    script, parser = import_command(command, props)
  File "/home/mike/projects/bocoup/google-wpt/web-platform-tests/tools/wpt/wpt.py", line 70, in import_command
    parser = getattr(mod, props["parser"])()
  File "/home/mike/projects/bocoup/google-wpt/web-platform-tests/tools/wpt/run.py", line 45, in create_parser
    from wptrunner import wptcommandline
  File "/home/mike/projects/bocoup/google-wpt/web-platform-tests/tools/wptrunner/wptrunner/wptcommandline.py", line 9, in <module>
    import wpttest
  File "/home/mike/projects/bocoup/google-wpt/web-platform-tests/tools/wptrunner/wptrunner/wpttest.py", line 4, in <module>
    import mozinfo
ImportError: No module named mozinfo

@jgraham
Copy link
Contributor Author

jgraham commented Jul 15, 2017

Closing this in favour of #6421 that ended up fixing some issues here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants