def _make_empty_pm(clazz): root_dir = temp_file.make_temp_dir(delete=not clazz.DEBUG) pm_dir = path.join(root_dir, 'package_manager') am_dir = path.join(root_dir, 'artifact_manager') if clazz.DEBUG: print("root_dir:\n%s\n" % (root_dir)) am = artifact_manager_local(am_dir) return package_manager(pm_dir, am)
def _command_test(self, bt, package_tarball, test, artifacts_dir, tools_dir, tmp_dir, opts, verbose): parsed_opts = key_value_parser.parse_to_dict(opts) opts = parsed_opts if 'build_level' in opts and bt == build_target.DEFAULT: bt == opts['build_level'] bt = build_level.parse_level(bt) opts['build_level'] = bt build_blurb.set_process_name('package_tester') build_blurb.set_verbose(bool(verbose)) if not path.isfile(test): raise RuntimeError('Test not found: %s' % (test)) tmp_dir = None if tmp_dir: tmp_dir = tmp_dir else: tmp_dir = temp_file.make_temp_dir(delete=False) file_util.mkdir(tmp_dir) if not path.isdir(artifacts_dir): raise RuntimeError('Not an artifacts directory: %s' % (artifacts_dir)) if not path.isdir(tools_dir): raise RuntimeError('Not an tools directory: %s' % (tools_dir)) am = artifact_manager_local(artifacts_dir) tm = tools_manager(tools_dir, self.build_target, am) build_blurb.blurb('tester', ' build_target: %s' % (str(self.build_target))) build_blurb.blurb('tester', ' tmp_dir: %s' % (tmp_dir)) build_blurb.blurb('tester', 'artifacts_dir: %s' % (artifacts_dir)) if not package.is_package(package_tarball): raise RuntimeError('Not a valid package: %s' % (package_tarball)) test_dir = path.join(tmp_dir, 'test') source_dir = path.dirname(test) #test_config = namedtuple('test_config', 'script,package_tarball,artifact_manager,tools_manager,extra_env') test_config = package_tester.test_config( None, package_tarball, am, tm, []) # source_dir, test_dir, am, tm, target) tester = package_tester(test_config, test) result = tester.run() if not result.success: print("result: ", result) return 1 return 0
def __init__(self, root_dir=None, debug=False, recipes=None, filename=None): root_dir = root_dir or temp_file.make_temp_dir(suffix='.artifacts') self._debug = debug self.am = artifact_manager_local(root_dir) self._recipes = {} if recipes: self.add_recipes(recipes, filename=filename)
def make_artifact_manager(clazz, debug=False, recipes=None, build_target=None, mutations=None): root_dir = temp_file.make_temp_dir(delete=not debug) if debug: print("root_dir:\n%s\n" % (root_dir)) am = artifact_manager_local(root_dir) if recipes: mutations = mutations or {} check.check_build_target(build_target) tmp_packages = fake_package_unit_test.create_many_packages( recipes, mutations) for tmp_package in tmp_packages: am.publish(tmp_package, build_target, False, None) return am
def main(self): args = self.parser.parse_args() self.build_target = self.build_target_resolve(args) subcommand = getattr(args, 'subcommand', None) if subcommand: command = '%s:%s' % (args.command, subcommand) else: command = args.command if hasattr(args, 'artifacts'): self.artifact_manager = artifact_manager_local(args.artifacts) else: self.artifact_manager = artifact_manager_local(None) self.verbose = getattr(args, 'verbose', False) if self.verbose: log.configure('remanage*=info format=brief width=20') if command == 'tools:update': return self._command_tools_update() elif command == 'tools:install': return self._command_tools_install(args.dest_dir) elif command == 'tools:print': return self._command_tools_print() elif command in ['packages:install', 'packages:update']: self._packages_check_common_args(args) if command == 'packages:install': return self._command_packages_install(args.dest_dir, args.project_name, args.packages, args.wipe, args.build_target) elif command == 'packages:update': return self._command_packages_update( args.root_dir, args.wipe, args.project_name, args.downgrade, args.force, args.dont_touch_update_script, args.build_target) elif command in ['packages:uninstall']: return self._command_packages_uninstall(args.dest_dir, args.project_name, args.packages, args.build_target) elif command in ['packages:print']: return self._command_packages_print(args.root_dir, args.project_name, args.build_target) elif command in ['config:packages']: return self._command_config_packages(args.root_dir, args.project_name, args.build_target) elif command in ['config:projects']: return self._command_config_projects(args.root_dir, args.build_target) elif command == 'package:files': return self._command_package_files(args.package) elif command == 'package:info': return self._command_package_info(args.package) elif command == 'package:metadata': return self._command_package_info(args.package) elif command == 'package:info': return self._command_package_info(args.package) elif command == 'package:metadata': return self._command_package_metadata(args.package) elif command == 'test': return self._command_test(args.level, args.package_tarball, args.test, args.artifacts_dir, args.tools_dir, args.tmp_dir, args.opts, args.verbose) else: raise RuntimeError('Unknown command: %s' % (command)) return 0