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 unicode_literals
10 from mach
.decorators
import (
16 from mozbuild
.base
import MachCommandBase
20 class WebIDLProvider(MachCommandBase
):
21 @Command('webidl-example', category
='misc',
22 description
='Generate example files for a WebIDL interface.')
23 @CommandArgument('interface', nargs
='+',
24 help='Interface(s) whose examples to generate.')
25 def webidl_example(self
, interface
):
26 from mozwebidlcodegen
import BuildSystemWebIDL
28 manager
= self
._spawn
(BuildSystemWebIDL
).manager
30 manager
.generate_example_files(i
)
32 @Command('webidl-parser-test', category
='testing',
33 description
='Run WebIDL tests (Interface Browser parser).')
34 @CommandArgument('--verbose', '-v', action
='store_true',
35 help='Run tests in verbose mode.')
36 def webidl_test(self
, verbose
=False):
37 sys
.path
.insert(0, os
.path
.join(self
.topsrcdir
, 'other-licenses',
40 # Make sure we drop our cached grammar bits in the objdir, not
41 # wherever we happen to be running from.
42 os
.chdir(self
.topobjdir
)
44 # Now we're going to create the cached grammar file in the
45 # objdir. But we're going to try loading it as a python
46 # module, so we need to make sure the objdir is in our search
48 sys
.path
.insert(0, self
.topobjdir
);
50 from runtests
import run_tests
51 return run_tests(None, verbose
=verbose
)