mach_commands.py (1929B)
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/. 4 5 import os 6 import sys 7 8 from mach.decorators import Command, CommandArgument 9 from mozbuild.dirutils import mkdir 10 11 12 def get_test_parser(): 13 import runtests 14 15 return runtests.get_parser 16 17 18 @Command( 19 "webidl-example", 20 category="misc", 21 description="Generate example files for a WebIDL interface.", 22 ) 23 @CommandArgument( 24 "interface", nargs="+", help="Interface(s) whose examples to generate." 25 ) 26 def webidl_example(command_context, interface): 27 from mozwebidlcodegen import create_build_system_manager 28 29 manager = create_build_system_manager() 30 for i in interface: 31 written = manager.generate_example_files(i) 32 for path_set in written: 33 for path in path_set: 34 print(path) 35 36 37 @Command( 38 "webidl-parser-test", 39 category="testing", 40 parser=get_test_parser, 41 description="Run WebIDL tests (Interface Browser parser).", 42 ) 43 def webidl_test(command_context, **kwargs): 44 sys.path.insert(0, os.path.join(command_context.topsrcdir, "other-licenses", "ply")) 45 46 # Ensure the topobjdir exists. On a Taskcluster test run there won't be 47 # an objdir yet. 48 mkdir(command_context.topobjdir) 49 50 # Make sure we drop our cached grammar bits in the objdir, not 51 # wherever we happen to be running from. 52 os.chdir(command_context.topobjdir) 53 54 if kwargs["verbose"] is None: 55 kwargs["verbose"] = False 56 57 # Now we're going to create the cached grammar file in the 58 # objdir. But we're going to try loading it as a python 59 # module, so we need to make sure the objdir is in our search 60 # path. 61 sys.path.insert(0, command_context.topobjdir) 62 63 import runtests 64 65 return runtests.run_tests(kwargs["tests"], verbose=kwargs["verbose"])