def simulator_is(*names): """ Check that current simulator is any of names """ supported_names = [sim.name for sim in SimulatorFactory.supported_simulators()] for name in names: assert name in supported_names return SimulatorFactory.select_simulator().name in names
def simulator_is(*names): """ Check that current simulator is any of names """ supported_names = [ sim.name for sim in SimulatorFactory.supported_simulators() ] for name in names: assert name in supported_names return SimulatorFactory.select_simulator().name in names
def from_args(cls, args, compile_builtins=True): """ Create VUnit instance from args namespace. Intended for users who adds custom command line options. See :class:`vunit.vunit_cli.VUnitCLI` class to learn about adding custom command line options. :param args: The parsed argument namespace object :param compile_builtins: Do not compile builtins. Used for VUnit internal testing. :returns: A :class:`.VUnit` object instance """ def test_filter(name): return any(fnmatch(name, pattern) for pattern in args.test_patterns) return cls(output_path=args.output_path, clean=args.clean, vhdl_standard=select_vhdl_standard(), use_debug_codecs=args.use_debug_codecs, no_color=args.no_color, verbose=args.verbose, xunit_xml=args.xunit_xml, log_level=args.log_level, test_filter=test_filter, list_only=args.list, list_files_only=args.files, compile_only=args.compile, keep_compiling=args.keep_compiling, elaborate_only=args.elaborate, compile_builtins=compile_builtins, simulator_factory=SimulatorFactory(args), num_threads=args.num_threads, exit_0=args.exit_0)
def set_sim_option(self, name, value): """ Set sim option """ known_options = SimulatorFactory.sim_options() if name not in known_options: LOGGER.error("Unknown sim_option %r, expected one of %r", name, known_options) raise ValueError(name) self.sim_options[name] = value
def _check_compile_option(self, name): """ Check that the compile option is valid """ if name in self._alias: new_name = self._alias[name] LOGGER.warning("Deprecated compile_option %r use %r instead", name, new_name) name = new_name known_options = SimulatorFactory.compile_options() if name not in known_options: LOGGER.error("Unknown compile_option %r, expected one of %r", name, known_options) raise ValueError(name)
def set_sim_option(self, name, value, scope=create_scope()): """ Set sim option within scope """ if name in self._alias: new_name = self._alias[name] LOGGER.warning("Deprecated sim_option %r use %r instead", name, new_name) name = new_name if name.startswith("vsim_extra_args"): value = value.split() known_options = SimulatorFactory.sim_options() if name not in known_options: LOGGER.error("Unknown sim_option %r, expected one of %r", name, known_options) raise ValueError(name) if scope not in self._sim_options: self._sim_options[scope] = {} self._sim_options[scope][name] = value
def has_simulator(): return SimulatorFactory.select_simulator().is_available()
def _create_argument_parser(description=None, for_documentation=False): """ Create the argument parser :param description: A custom short description of the command line tool :param for_documentation: When used for user guide documentation :returns: The created :mod:`argparse` parser object """ description = 'VUnit command line tool.' if description is None else description if for_documentation: default_output_path = "./vunit_out" else: default_output_path = join(abspath(os.getcwd()), "vunit_out") parser = argparse.ArgumentParser(description=description) parser.add_argument('test_patterns', metavar='tests', nargs='*', default='*', help='Tests to run') parser.add_argument('-l', '--list', action='store_true', default=False, help='Only list all test cases') parser.add_argument('--compile', action='store_true', default=False, help='Only compile project without running tests') parser.add_argument('--elaborate', action='store_true', default=False, help='Only elaborate test benches without running') parser.add_argument('--clean', action='store_true', default=False, help='Remove output path first') parser.add_argument('-o', '--output-path', default=default_output_path, help='Output path for compilation and simulation artifacts') parser.add_argument('-x', '--xunit-xml', default=None, help='Xunit test report .xml file') parser.add_argument('--exit-0', default=False, action="store_true", help=('Exit with code 0 even if a test failed. ' 'Still exits with code 1 on fatal errors such as compilation failure')) parser.add_argument('-v', '--verbose', action="store_true", default=False, help='Print test output immediately and not only when failure') parser.add_argument('--no-color', action='store_true', default=False, help='Do not color output') parser.add_argument('--log-level', default="warning", choices=["info", "error", "warning", "debug"], help=("Log level of VUnit internal python logging. " "Used for debugging")) parser.add_argument('-p', '--num-threads', type=positive_int, default=1, help=('Number of tests to run in parallel. ' 'Test output is not continuously written in verbose mode with p > 1')) SimulatorFactory.add_arguments(parser, for_all_simulators=for_documentation) com = parser.add_argument_group("com", description="Flags specific to the com message passing package") com.add_argument('--use-debug-codecs', action='store_true', default=False, help='Run with debug features enabled') return parser
def _create_argument_parser(description=None, for_documentation=False): """ Create the argument parser :param description: A custom short description of the command line tool :param for_documentation: When used for user guide documentation :returns: The created :mod:`argparse` parser object """ if description is None: description = 'VUnit command line tool version %s' % version() if for_documentation: default_output_path = "./vunit_out" else: default_output_path = join(abspath(os.getcwd()), "vunit_out") parser = argparse.ArgumentParser(description=description) parser.add_argument('test_patterns', metavar='tests', nargs='*', default='*', help='Tests to run') parser.add_argument('-l', '--list', action='store_true', default=False, help='Only list all test cases') parser.add_argument('-f', '--files', action='store_true', default=False, help='Only list all files in compile order') parser.add_argument('--compile', action='store_true', default=False, help='Only compile project without running tests') parser.add_argument( '-k', '--keep-compiling', action='store_true', default=False, help= 'Continue compiling even after errors only skipping files that depend on failed files' ) parser.add_argument('--elaborate', action='store_true', default=False, help='Only elaborate test benches without running') parser.add_argument('--clean', action='store_true', default=False, help='Remove output path first') parser.add_argument( '-o', '--output-path', default=default_output_path, help='Output path for compilation and simulation artifacts') parser.add_argument('-x', '--xunit-xml', default=None, help='Xunit test report .xml file') parser.add_argument( '--exit-0', default=False, action="store_true", help= ('Exit with code 0 even if a test failed. ' 'Still exits with code 1 on fatal errors such as compilation failure' )) parser.add_argument( '-v', '--verbose', action="store_true", default=False, help='Print test output immediately and not only when failure') parser.add_argument('--no-color', action='store_true', default=False, help='Do not color output') parser.add_argument('--log-level', default="warning", choices=["info", "error", "warning", "debug"], help=("Log level of VUnit internal python logging. " "Used for debugging")) parser.add_argument( '-p', '--num-threads', type=positive_int, default=1, help=( 'Number of tests to run in parallel. ' 'Test output is not continuously written in verbose mode with p > 1' )) parser.add_argument( "-u", "--unique-sim", action="store_true", default=False, help= "Do not re-use the same simulator process for running different test cases (slower)" ) parser.add_argument('--version', action='version', version=version()) SimulatorFactory.add_arguments(parser, for_all_simulators=for_documentation) com = parser.add_argument_group( "com", description="Flags specific to the com message passing package") com.add_argument('--use-debug-codecs', action='store_true', default=False, help='Run with debug features enabled') return parser