Example #1
0
  def test_scan_addresses_with_root_specified(self):
    address = Address('a', 'b')

    graph_mock = mock.Mock()
    graph_mock.inject_specs_closure = mock.Mock(return_value=[address])

    mapper = LegacyAddressMapper(graph_mock, '/some/build/root')
    absolute_root_path = '/some/build/root/a'
    mapper.scan_addresses(absolute_root_path)

    graph_mock.inject_specs_closure.assert_called_with([DescendantAddresses('a')])
Example #2
0
    def test_scan_addresses_with_root_specified(self):
        address = Address('a', 'b')

        graph_mock = mock.Mock()
        graph_mock.inject_specs_closure = mock.Mock(return_value=[address])

        mapper = LegacyAddressMapper(graph_mock, '/some/build/root')
        absolute_root_path = '/some/build/root/a'
        mapper.scan_addresses(absolute_root_path)

        graph_mock.inject_specs_closure.assert_called_with(
            [DescendantAddresses('a')])
  def test_other_throw_is_fail(self):
    # scan_addresses() should raise an error if the scheduler returns an error it can't ignore.
    class ThrowReturningScheduler(object):
      def execution_request(self, *args):
        pass

      def execute(self, *args):
        return [], [(('some-thing', None), Throw(Exception('just an exception')))]

    with temporary_dir() as build_root:
      mapper = LegacyAddressMapper(ThrowReturningScheduler(), build_root)

      with self.assertRaises(LegacyAddressMapper.BuildFileScanError) as cm:
        mapper.scan_addresses(os.path.join(build_root, 'foo'))
      self.assertIn('just an exception', str(cm.exception))
Example #4
0
  def test_other_throw_is_fail(self):
    # scan_addresses() should raise an error if the scheduler returns an error it can't ignore.
    class ThrowReturningScheduler(object):
      def execution_request(self, *args):
        pass

      def execute(self, *args):
        return ExecutionResult(None, [(('some-thing', None), Throw(Exception('just an exception')))])

    with temporary_dir() as build_root:
      mapper = LegacyAddressMapper(ThrowReturningScheduler(), build_root)

      with self.assertRaises(LegacyAddressMapper.BuildFileScanError) as cm:
        mapper.scan_addresses(os.path.join(build_root, 'foo'))
      self.assertIn('just an exception', str(cm.exception))
Example #5
0
    def test_other_throw_is_fail(self) -> None:
        # scan_addresses() should raise an error if the scheduler returns an error it can't ignore.
        class ThrowReturningScheduler:
            def execution_request(self, *args):
                pass

            def execute(self, *args):
                return [], [(("some-thing", None), Throw(Exception("just an exception")))]

        with temporary_dir() as build_root:
            mapper = LegacyAddressMapper(ThrowReturningScheduler(), build_root)

            with self.assertRaises(LegacyAddressMapper.BuildFileScanError) as cm:
                mapper.scan_addresses(os.path.join(build_root, "foo"))
            self.assertIn("just an exception", str(cm.exception))