Esempio n. 1
0
    def test_no_dependencies_for_node_bundle(self):
        with temporary_dir() as tmp_dir:
            with temporary_dir() as tmp_dir_2:
                touch(os.path.join(tmp_dir, 'a'))
                node_module_target = self.make_target(
                    self.node_module_target_name_full, NodeModule)
                node_module_target_2 = self.make_target(
                    self.node_module_target_name_full_2, NodeModule)

                target = self.make_target(
                    self.target_name_full,
                    NodeBundle,
                    node_module=self.node_module_target_name_full,
                    dependencies=[node_module_target, node_module_target_2],
                )

                resolved_node_paths = NodePaths()
                resolved_node_paths.resolved(node_module_target, tmp_dir)
                resolved_node_paths.resolved(node_module_target_2, tmp_dir_2)
                task_context = self.context(target_roots=[target])
                task_context.products.safe_create_data(
                    NodePaths, init_func=lambda: resolved_node_paths)
                task = self.create_task(task_context)

                self.assertRaises(TargetDefinitionException, task.execute)
Esempio n. 2
0
  def test_render_npm_package_dependency(self):
    node_module_target = self.make_target(':a', NodeModule)
    node_remote_module_target = self.make_target(':b', NodeRemoteModule, version='1.2.3')

    node_paths = NodePaths()
    node_paths.resolved(node_module_target, '/path/to/node_module_target')
    node_paths.resolved(node_remote_module_target, '/path/to/node_remote_module_target')

    self.assertEqual(
      '/path/to/node_module_target',
      NodeTask.render_npm_package_dependency(node_paths, node_module_target))

    self.assertEqual(
      '1.2.3',
      NodeTask.render_npm_package_dependency(node_paths, node_remote_module_target))
Esempio n. 3
0
  def _run_test_and_get_products(self, node_modules_and_files=None):
    resolved_node_paths = NodePaths()
    for node_module, files in node_modules_and_files:
      tmp_dir = safe_mkdtemp()
      for f in files or []:
        shutil.copy(f, tmp_dir)
      resolved_node_paths.resolved(node_module, tmp_dir)
    task_context = self.context(target_roots=[node_modules_and_files[0][0]])
    task_context.products.safe_create_data(NodePaths, init_func=lambda: resolved_node_paths)
    task = self.create_task(task_context)
    task.execute()

    bundleable_js_product = task.context.products.get_data('bundleable_js')
    runtime_classpath_product = task.context.products.get_data('runtime_classpath')
    return bundleable_js_product, runtime_classpath_product, resolved_node_paths