예제 #1
0
    def testSimple(self):
        iface_cache = self.config.iface_cache
        s = solver.DefaultSolver(self.config)

        foo = iface_cache.get_interface('http://foo/Binary.xml')
        self.import_feed(foo.uri, 'Binary.xml')
        foo_src = iface_cache.get_interface('http://foo/Source.xml')
        self.import_feed(foo_src.uri, 'Source.xml')
        compiler = iface_cache.get_interface('http://foo/Compiler.xml')
        self.import_feed(compiler.uri, 'Compiler.xml')

        binary_arch = arch.Architecture({None: 1}, {None: 1})
        assert str(binary_arch).startswith("<Arch")
        s.solve('http://foo/Binary.xml', binary_arch)

        assert s.ready
        assert s.feeds_used == set([foo.uri]), s.feeds_used
        assert s.selections[foo].id == 'sha1=123'

        # Now ask for source instead
        s.solve('http://foo/Binary.xml',
                arch.SourceArchitecture(binary_arch),
                command_name='compile')
        assert s.ready, s.get_failure_reason()
        assert s.feeds_used == set([foo.uri, foo_src.uri,
                                    compiler.uri]), s.feeds_used
        assert s.selections[foo].id == 'sha1=234'  # The source
        assert s.selections[
            compiler].id == 'sha1=345'  # A binary needed to compile it

        assert not s.details
예제 #2
0
    def testDetails(self):
        iface_cache = self.config.iface_cache
        s = solver.DefaultSolver(self.config)

        foo_binary_uri = 'http://foo/Binary.xml'
        foo = iface_cache.get_interface(foo_binary_uri)
        self.import_feed(foo_binary_uri, 'Binary.xml')
        foo_src = iface_cache.get_interface('http://foo/Source.xml')
        self.import_feed(foo_src.uri, 'Source.xml')
        compiler = iface_cache.get_interface('http://foo/Compiler.xml')
        self.import_feed(compiler.uri, 'Compiler.xml')

        binary_arch = arch.Architecture({None: 1}, {None: 1})
        s.record_details = True
        s.solve('http://foo/Binary.xml',
                arch.SourceArchitecture(binary_arch),
                command_name='compile')
        assert s.ready, s.get_failure_reason()

        foo_src_impls = iface_cache.get_feed(foo_src.uri).implementations
        foo_impls = iface_cache.get_feed(foo.uri).implementations
        compiler_impls = iface_cache.get_feed(compiler.uri).implementations

        assert len(s.details) == 2
        self.assertEquals(
            [(foo_src_impls['sha1=234'], None),
             (foo_impls['sha1=123'], 'Unsupported machine type')],
            sorted(s.details[foo]))
        assert s.details[compiler] == [(compiler_impls['sha1=345'], None)]
예제 #3
0
    def get_arch_for(self, requirements, interface=None):
        """Return the Architecture we would use when solving for this interface.
		Normally, this architecture is constructed from the OS and CPU type in the requirements,
		using the host platform's settings if these are not given.
		If interface is the root, then we wrap this in a SourceArchitecture if looking
		for source code and (for backwards compatibility) we enable use="testing" dependencies
		if the command is "test".
		@param requirements: the overall requirements for the solve
		@type requirements: L{requirements.Requirements}
		@param interface: the interface of interest
		@type interface: L{model.Interface}
		@return: the architecture that would be used
		@rtype: L{architecture.Architecture}
		@since: 1.9"""
        root_arch = arch.get_architecture(requirements.os, requirements.cpu)
        if interface is None or interface.uri == requirements.interface_uri:
            if requirements.source:
                root_arch = arch.SourceArchitecture(root_arch)
            if requirements.command == 'test':
                # This is for old feeds that have use='testing' instead of the newer
                # 'test' command for giving test-only dependencies.
                root_arch = arch.Architecture(root_arch.os_ranks,
                                              root_arch.machine_ranks)
                root_arch.use = frozenset([None, "testing"])
            return root_arch
        # Assume we use the same arch for all descendants
        return root_arch.child_arch
예제 #4
0
 def testCommand(self):
     s = solver.DefaultSolver(self.config)
     binary_arch = arch.Architecture({None: 1}, {None: 1})
     s.solve(command_dep, binary_arch)
     command = s.selections.selections[s.selections.interface].get_command(
         "run")
     dep, = command.requires
     dep_impl = s.selections.selections[dep.interface]
     assert dep_impl.get_command("run").path == "test-gui"
예제 #5
0
    def testRecursive(self):
        iface_cache = self.config.iface_cache
        s = solver.DefaultSolver(self.config)

        foo = iface_cache.get_interface('http://foo/Recursive.xml')
        self.import_feed(foo.uri, 'Recursive.xml')

        binary_arch = arch.Architecture({None: 1}, {None: 1})
        s.record_details = True
        s.solve('http://foo/Recursive.xml', binary_arch)
        assert s.ready

        foo_impls = iface_cache.get_feed(foo.uri).implementations

        assert len(s.details) == 1
        assert s.details[foo] == [(foo_impls['sha1=abc'], None)]