def main(self, argv): # self._print_env() (params, cmake_argv) = self._parse_command_line(argv) if params.install_dir: top_dir = util.get_top_dir() os.chdir(top_dir) script_dir = util.get_script_dir() # print("sys.path: ", sys.path) script_installer = BuildScriptInstaller(verbose=True) script_installer.install_script( params.install_dir, os.path.join(script_dir, 'cmake.py'), self._cmake_mod_list) elif params.py_cache_dirs: for dname in params.py_cache_dirs: if not os.path.exists(dname): continue if not os.path.isdir(dname): continue self._remove_pycache(dname) else: # Apply additional checks on params. self._check_params(params) if self._sys_info.is_linux() or self._sys_info.is_macosx(): self._remove_make_env_vars() # Delayed construction to get the current log level at construction time of CMakeLauncher. self._cmake_launcher = cmksupp.CMakeLauncher() self._cmake_launcher.launch(params, cmake_argv)
def _find_toolchains_dir(self): toolchains_dir = os.path.join(util.get_script_dir(), '..', 'cmake', 'toolchains') if not os.path.exists(toolchains_dir): self._logger.warning( "toolchains dir {} does not exist.".format(toolchains_dir)) return None toolchains_dir = os.path.normpath(toolchains_dir) return toolchains_dir
def get_test_data_top_dir(): """Returns the default test data directory based on the script directory avoiding hardcoded paths while switching between BoostBuild and CMakeBuild.""" script_dir_up = os.path.normpath(os.path.join(util.get_script_dir(), '..')) repo_name = os.path.basename(script_dir_up) # repo_name: either BoostBuild or CMakeBuild top_dir = util.get_top_dir() test_data_dir = os.path.join(top_dir, 'TestData', repo_name) assert os.path.exists(test_data_dir) return test_data_dir
def main(self, argv): # self._print_env() (params, cmake_argv) = self._parse_command_line(argv) if params.install_dir: top_dir = util.get_top_dir() os.chdir(top_dir) script_dir = util.get_script_dir() script_installer = BuildScriptInstaller(top_dir, verbose=True) #if ver.version_compare(self._sys_info.get_python_version(), (3, 0)) >= 0: # script_installer.install_script(params.install_dir, os.path.join(script_dir, 'cmake3.py'), self._cmake_mod_list, rename='cmake.py') #else: # script_installer.install_script(params.install_dir, os.path.join(script_dir, 'cmake.py'), self._cmake_mod_list) script_installer.install_script( params.install_dir, os.path.join(script_dir, 'cmake.py'), self._cmake_mod_list) else: # Apply additional checks on params. self._check_params(params) if self._sys_info.is_linux() or self._sys_info.is_macosx(): self._remove_make_env_vars() # Delayed construction to get the current log level at construction time of CMakeLauncher. self._cmake_launcher = cmksupp.CMakeLauncher() self._cmake_launcher.launch(params, cmake_argv)
def __call__(self): parser = argparse.ArgumentParser() util.app_args_add_log_level(parser) parser.add_argument( "-v", action="store", type=int, dest="verbosity_level", default=2, help= "change the default verbosity level of the python unit test framework." ) parser.add_argument("--with-android", action="store_true", dest="with_android", default=False, help="include android tests.") parser.add_argument("--with-cuda", action="store_true", dest="with_cuda", default=False, help="include android tests.") parser.add_argument("--with-vlc", action="store_true", dest="with_vlc", default=False, help="include VLC tests.") parser.add_argument("--with-all", action="store_true", dest="with_all", default=False, help="include all optional tests.") parser.add_argument( "unit_tests", action="store", nargs='*', help= "specify one or more unit tests to run. By default all tests will be run." ) args = parser.parse_args() # configure the python logger asap util.app_configure_logging(args.log_level) # print("verbosity_level:", args.verbosity_level) # get the workspace top_dir = util.get_top_dir() # change to top_dir os.chdir(top_dir) # get the boost build script directory script_dir = util.get_script_dir() test_loader = unittest.TestLoader() # All unit tests live in the package bb.test test_package_prefix = 'pyhhi.build.test' py_module_nm_list = [] if args.unit_tests: # One or more test modules are specified. for arg in args.unit_tests: if arg.startswith('test_'): py_module_nm_list.append(arg) else: py_module_nm_list.append('test_' + arg) else: # Construct the default test suite containing all test modules. # test_suite = test_loader.discover(test_package_prefix, 'test_*.py') for file in glob.glob( os.path.join(script_dir, 'pyhhi', 'build', 'test', 'test_*.py')): (py_module_nm, ext) = os.path.splitext(os.path.basename(file)) py_module_nm_list.append(py_module_nm) for file in glob.glob( os.path.join(script_dir, 'pyhhi', 'cmbuild', 'test', 'test_*.py')): (py_module_nm, ext) = os.path.splitext(os.path.basename(file)) py_module_nm_list.append(py_module_nm) py_module_nm_list = self._filter_module_list( args, py_module_nm_list) test_module_names = [] for prefix in ['pyhhi.build.test', 'pyhhi.cmbuild.test']: #prefix_path = os.path.join(script_dir, prefix.split('.')) prefix_path = os.path.join(script_dir, prefix.replace('.', os.sep)) for py_module_nm in py_module_nm_list: if os.path.exists( os.path.join(prefix_path, py_module_nm + '.py')): test_module_names.append(prefix + '.' + py_module_nm) #test_module_names = [test_package_prefix + '.' + x for x in py_module_nm_list] print("test module list: ", test_module_names) test_suite = test_loader.loadTestsFromNames(test_module_names) # and run tests ... test_runner = unittest.TextTestRunner(verbosity=args.verbosity_level) test_runner.run(test_suite)