1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, # You can obtain one at http://mozilla.org/MPL/2.0/.
5 from __future__
import absolute_import
, unicode_literals
10 from mach
.decorators
import (
16 from mozbuild
.base
import MachCommandBase
17 from mozbuild
.util
import mkdir
20 def get_test_parser():
23 return runtests
.get_parser
27 class WebIDLProvider(MachCommandBase
):
31 description
="Generate example files for a WebIDL interface.",
34 "interface", nargs
="+", help="Interface(s) whose examples to generate."
36 def webidl_example(self
, interface
):
37 from mozwebidlcodegen
import BuildSystemWebIDL
39 manager
= self
._spawn
(BuildSystemWebIDL
).manager
41 manager
.generate_example_files(i
)
46 parser
=get_test_parser
,
47 description
="Run WebIDL tests (Interface Browser parser).",
49 def webidl_test(self
, **kwargs
):
50 sys
.path
.insert(0, os
.path
.join(self
.topsrcdir
, "other-licenses", "ply"))
52 # Ensure the topobjdir exists. On a Taskcluster test run there won't be
56 # Make sure we drop our cached grammar bits in the objdir, not
57 # wherever we happen to be running from.
58 os
.chdir(self
.topobjdir
)
60 if kwargs
["verbose"] is None:
61 kwargs
["verbose"] = False
63 # Now we're going to create the cached grammar file in the
64 # objdir. But we're going to try loading it as a python
65 # module, so we need to make sure the objdir is in our search
67 sys
.path
.insert(0, self
.topobjdir
)
71 return runtests
.run_tests(kwargs
["tests"], verbose
=kwargs
["verbose"])