예제 #1
0
 def test_is_declaring_file(self):
   scheduler = mock.Mock()
   mapper = LegacyAddressMapper(scheduler, None, '')
   self.assertTrue(mapper.is_declaring_file(Address('path', 'name'), 'path/BUILD'))
   self.assertTrue(mapper.is_declaring_file(Address('path', 'name'), 'path/BUILD.suffix'))
   self.assertFalse(mapper.is_declaring_file(Address('path', 'name'), 'path/not_a_build_file'))
   self.assertFalse(mapper.is_declaring_file(Address('path', 'name'), 'differing-path/BUILD'))
예제 #2
0
    def iter_target_addresses_for_sources(self, sources):
        """Bulk, iterable form of `target_addresses_for_source`."""
        # Walk up the buildroot looking for targets that would conceivably claim changed sources.
        sources_set = set(sources)
        subjects = [
            AscendantAddresses(directory=d)
            for d in self._unique_dirs_for_sources(sources_set)
        ]

        for hydrated_targets in self._engine.product_request(
                HydratedTargets, subjects):
            for hydrated_target in hydrated_targets.dependencies:
                legacy_address = hydrated_target.adaptor.address

                # Handle BUILD files.
                if any(
                        LegacyAddressMapper.is_declaring_file(
                            legacy_address, f) for f in sources_set):
                    yield legacy_address
                else:
                    # Handle claimed files.
                    target_files_iter = self._iter_owned_files_from_hydrated_target(
                        hydrated_target)
                    if any(source_file in sources_set
                           for source_file in target_files_iter):
                        # At least one file in this targets sources match our changed sources - emit its address.
                        yield legacy_address
예제 #3
0
  def iter_target_addresses_for_sources(self, sources):
    """Bulk, iterable form of `target_addresses_for_source`."""
    # Walk up the buildroot looking for targets that would conceivably claim changed sources.
    sources_set = set(sources)
    subjects = [AscendantAddresses(directory=d) for d in self._unique_dirs_for_sources(sources_set)]

    for hydrated_targets in self._engine.product_request(HydratedTargets, subjects):
      for hydrated_target in hydrated_targets.dependencies:
        legacy_address = hydrated_target.adaptor.address

        # Handle BUILD files.
        if any(LegacyAddressMapper.is_declaring_file(legacy_address, f) for f in sources_set):
          yield legacy_address
        else:
          if any(self._owns_source(source, hydrated_target) for source in sources_set):
            yield legacy_address
예제 #4
0
  def iter_target_addresses_for_sources(self, sources):
    """Bulk, iterable form of `target_addresses_for_source`."""
    # Walk up the buildroot looking for targets that would conceivably claim changed sources.
    sources_set = set(sources)
    subjects = [AscendantAddresses(directory=d) for d in self._unique_dirs_for_sources(sources_set)]

    for legacy_target in self._engine.product_request(LegacyTarget, subjects):
      legacy_address = legacy_target.adaptor.address

      # Handle BUILD files.
      if any(LegacyAddressMapper.is_declaring_file(legacy_address, f) for f in sources_set):
        yield legacy_address
      else:
        # Handle claimed files.
        target_files_iter = self._iter_owned_files_from_legacy_target(legacy_target)
        if any(source_file in sources_set for source_file in target_files_iter):
          # At least one file in this targets sources match our changed sources - emit its address.
          yield legacy_address
예제 #5
0
 def test_is_declaring_file(self):
   scheduler = mock.Mock()
   mapper = LegacyAddressMapper(scheduler, '')
   self.assertTrue(mapper.is_declaring_file(Address('path', 'name'), 'path/BUILD'))
   self.assertTrue(mapper.is_declaring_file(Address('path', 'name'), 'path/BUILD.suffix'))
   self.assertFalse(mapper.is_declaring_file(Address('path', 'name'), 'path/not_a_build_file'))
   self.assertFalse(mapper.is_declaring_file(Address('path', 'name'), 'differing-path/BUILD'))
   self.assertFalse(mapper.is_declaring_file(
     BuildFileAddress(target_name='name', rel_path='path/BUILD.new'),
     'path/BUILD'))
   self.assertTrue(mapper.is_declaring_file(
     BuildFileAddress(target_name='name', rel_path='path/BUILD'),
     'path/BUILD'))
예제 #6
0
 def test_is_declaring_file(self):
   scheduler = mock.Mock()
   mapper = LegacyAddressMapper(scheduler, '')
   self.assertTrue(mapper.is_declaring_file(Address('path', 'name'), 'path/BUILD'))
   self.assertTrue(mapper.is_declaring_file(Address('path', 'name'), 'path/BUILD.suffix'))
   self.assertFalse(mapper.is_declaring_file(Address('path', 'name'), 'path/not_a_build_file'))
   self.assertFalse(mapper.is_declaring_file(Address('path', 'name'), 'differing-path/BUILD'))
   self.assertFalse(mapper.is_declaring_file(
     BuildFileAddress(target_name='name', rel_path='path/BUILD.new'),
     'path/BUILD'))
   self.assertTrue(mapper.is_declaring_file(
     BuildFileAddress(target_name='name', rel_path='path/BUILD'),
     'path/BUILD'))
예제 #7
0
 def test_is_declaring_file(self) -> None:
     scheduler = unittest.mock.Mock()
     mapper = LegacyAddressMapper(scheduler, "")
     self.assertTrue(mapper.is_declaring_file(Address("path", "name"), "path/BUILD"))
     self.assertTrue(mapper.is_declaring_file(Address("path", "name"), "path/BUILD.suffix"))
     self.assertFalse(mapper.is_declaring_file(Address("path", "name"), "path/not_a_build_file"))
     self.assertFalse(mapper.is_declaring_file(Address("path", "name"), "differing-path/BUILD"))
     self.assertFalse(
         mapper.is_declaring_file(
             BuildFileAddress(target_name="name", rel_path="path/BUILD.new"), "path/BUILD"
         )
     )
     self.assertTrue(
         mapper.is_declaring_file(
             BuildFileAddress(target_name="name", rel_path="path/BUILD"), "path/BUILD"
         )
     )
예제 #8
0
    def iter_target_addresses_for_sources(self, sources):
        """Bulk, iterable form of `target_addresses_for_source`."""
        # Walk up the buildroot looking for targets that would conceivably claim changed sources.
        sources_set = set(sources)
        subjects = [
            AscendantAddresses(directory=d)
            for d in self._unique_dirs_for_sources(sources_set)
        ]

        for hydrated_targets in self._scheduler.product_request(
                HydratedTargets, subjects):
            for hydrated_target in hydrated_targets.dependencies:
                legacy_address = hydrated_target.adaptor.address

                # Handle BUILD files.
                if any(
                        LegacyAddressMapper.is_declaring_file(
                            legacy_address, f) for f in sources_set):
                    yield legacy_address
                else:
                    if any(
                            self._owns_source(source, hydrated_target)
                            for source in sources_set):
                        yield legacy_address