def identify(self, name: str) -> Identification: for root in self._roots: path = TargetResolver._is_group(root, name) if path is not None: return Identification('group', path) path = TargetResolver._is_standalone(root, name) if path is not None: return Identification('package', path) path = TargetResolver._is_cmake(root, name) if path is not None: return Identification('cmake', path) if name in self._virtuals: return Identification('virtual') if name in self._pkg_configs: return Identification('pkg_config', None, self._pkg_configs[name]) raise TargetNotFoundError(name)
def test_equal_ids(self): id1 = Identification('a') id2 = Identification('a') assert(id1 == id2)
def test_compare_ids_with_non_ids(self): id1 = Identification('a') assert(id1 != 5)
def test_pkg_identification(self): r = TargetResolver(self.config) assert(Identification('pkg_config', None, 'bar') == r.identify('foo'))
def test_cmake_identification(self): r = TargetResolver(self.config) assert(Identification('cmake', P('t2')) == r.identify('t2'))
def test_thirdparty_cmake_identification(self): r = TargetResolver(self.config) assert(Identification('cmake', P('r')/'thirdparty'/'t1') == \ r.identify('t1'))
def test_adapter_identification(self): r = TargetResolver(self.config) assert(Identification('package', P('r')/'adapters'/'p1') == \ r.identify('p1'))
def test_group_identification(self): r = TargetResolver(self.config) assert(Identification('group', P('r')/'groups'/'gr1') == \ r.identify('gr1'))
def test_custom_standalone_identification(self): r = TargetResolver(self.config) assert(Identification('package', P('r')/'adapters'/'p4') == \ r.identify('p4'))
def test_standalone_identification(self): r = TargetResolver(self.config) assert(Identification('package', P('r')/'standalones'/'p1') == \ r.identify('p1'))
def test_application_identification(self): r = TargetResolver(self.config) assert(Identification('application', P('r')/'applications'/'app1') == \ r.identify('app1'))