Пример #1
0
    def reuse_test(self):
        self._export_upload("hello0/[email protected]/stable")
        self._export_upload("hello1/[email protected]/stable", 1, [0])
        self._export_upload("hello2/[email protected]/stable", 2, [0])
        self._export_upload("hello3/[email protected]/stable", 3, [1, 2])

        client = TestClient(servers=self.servers, users=[("lasote", "mypass")])  # Mocked userio
        conan_reference = ConanFileReference.loads("hello4/[email protected]/stable")
        files3 = hello_conan_files(conan_reference=conan_reference, number=4, deps=[3], lang='go')
        client.save(files3)
        os.chdir(client.current_folder)
        client.run("install --build missing")
        client.run("build")
        command = "say_hello" if platform.system() == "Windows" else "./say_hello"
        with CustomEnvPath(paths_to_add=['$GOPATH/bin'],
                           var_to_add=[('GOPATH', client.current_folder), ]):

            client.runner('go install hello4_main', os.path.join(client.current_folder, 'src'))
        if platform.system() == "Windows":
            command = "hello4_main"
        else:
            command = './hello4_main'
        client.runner(command, os.path.join(client.current_folder, 'bin'))

        self.assertEqual(['Hello 4', 'Hello 3', 'Hello 1', 'Hello 0', 'Hello 2', 'Hello 0'],
                         str(client.user_io.out).splitlines()[-6:])

        # Try to upload and reuse the binaries
        client.run("upload hello3/[email protected]/stable --all")
        self.assertEqual(str(client.user_io.out).count("Uploading package"), 1)
        client.run("upload hello1/[email protected]/stable --all")
        self.assertEqual(str(client.user_io.out).count("Uploading package"), 1)
        client.run("upload hello2/[email protected]/stable --all")
        self.assertEqual(str(client.user_io.out).count("Uploading package"), 1)
        client.run("upload hello0/[email protected]/stable --all")
        self.assertEqual(str(client.user_io.out).count("Uploading package"), 1)
#
        client2 = TestClient(servers=self.servers, users=[("lasote", "mypass")])  # Mocked userio
        conan_reference = ConanFileReference.loads("hello4/[email protected]/stable")

        files3 = hello_conan_files(conan_reference=conan_reference, number=4, deps=[3], lang='go')
        client2.save(files3)

        client2.run("install --build missing")
        command = "say_hello" if platform.system() == "Windows" else "./say_hello"
        with CustomEnvPath(paths_to_add=['$GOPATH/bin'],
                           var_to_add=[('GOPATH', client2.current_folder), ]):

            client2.runner('go install hello4_main', os.path.join(client2.current_folder, 'src'))
        if platform.system() == "Windows":
            command = "hello4_main"
        else:
            command = './hello4_main'
        client2.runner(command, os.path.join(client2.current_folder, 'bin'))

        self.assertEqual(['Hello 4', 'Hello 3', 'Hello 1', 'Hello 0', 'Hello 2', 'Hello 0'],
                         str(client2.user_io.out).splitlines()[-6:])
Пример #2
0
 def _export_upload(self, ref_str, number=0, deps=None):
     conan_reference = ConanFileReference.loads(ref_str)
     files = hello_conan_files(conan_reference=conan_reference, number=number, deps=deps,
                               lang='go')
     self.conan.save(files, clean_first=True)
     self.conan.run("export lasote/stable")
     self.conan.run("upload %s" % str(conan_reference))
Пример #3
0
    def check_upload_confirm_question_test(self):
        user_io = self.client.user_io
        files = hello_conan_files("Hello1", "1.2.1")
        self.client.save(files)
        self.client.run("export . frodo/stable")

        user_io.request_string = lambda _: "y"
        self.client.run("upload Hello*", user_io=user_io)
        self.assertIn("Uploading Hello1/[email protected]/stable", self.client.user_io.out)

        files = hello_conan_files("Hello2", "1.2.1")
        self.client.save(files)
        self.client.run("export . frodo/stable")

        user_io.request_string = lambda _: "n"
        self.client.run("upload Hello*", user_io=user_io)
        self.assertNotIn("Uploading Hello2/[email protected]/stable", self.client.user_io.out)
Пример #4
0
    def upload_with_pattern_and_package_error_test(self):
        files = hello_conan_files("Hello1", "1.2.1")
        self.client.save(files)
        self.client.run("export . frodo/stable")

        self.client.run("upload Hello* --confirm -p 234234234", ignore_error=True)
        self.assertIn("-p parameter only allowed with a valid recipe reference",
                      self.client.user_io.out)
Пример #5
0
    def try_upload_bad_recipe_test(self):
        files = hello_conan_files("Hello0", "1.2.1")
        self.client.save(files)
        self.client.run("export frodo/stable")
        ref = ConanFileReference.loads("Hello0/[email protected]/stable")
        os.unlink(os.path.join(self.client.client_cache.export(ref), CONAN_MANIFEST))
        with self.assertRaisesRegexp(Exception, "Command failed"):
            self.client.run("upload %s" % str(ref))

        self.assertIn("Cannot upload corrupted recipe", self.client.user_io.out)
Пример #6
0
    def setUp(self):
        test_server = TestServer()
        self.servers = {"default": test_server}
        self.conan = TestClient(servers=self.servers, users={"default": [("lasote", "mypass")]})

        # Export and upload the conanfile
        self.conan_reference = ConanFileReference.loads("hello0/[email protected]/stable")
        self.files = hello_conan_files(conan_reference=self.conan_reference, lang='go')
        self.conan.save(self.files, clean_first=True)
        self.conan.run("export lasote/stable")
        self.conan.run("upload %s" % str(self.conan_reference))
Пример #7
0
    def setUp(self):
        test_server = TestServer([("*/*@*/*", "*")],  # read permissions
                                 [],  # write permissions
                                 users={"lasote": "mypass"})  # exported users and passwords
        self.servers = {"default": test_server}
        self.conan = TestClient(servers=self.servers, users=[("lasote", "mypass")])

        # Export and upload the conanfile
        self.conan_reference = ConanFileReference.loads("hello0/[email protected]/stable")
        self.files = hello_conan_files(conan_reference=self.conan_reference, lang='go')
        self.conan.save(self.files, clean_first=True)
        self.conan.run("export lasote/stable")
        self.conan.run("upload %s" % str(self.conan_reference))
Пример #8
0
    def upload_with_pattern_test(self):
        for num in range(5):
            files = hello_conan_files("Hello%s" % num, "1.2.1")
            self.client.save(files)
            self.client.run("export . frodo/stable")

        self.client.run("upload Hello* --confirm")
        for num in range(5):
            self.assertIn("Uploading Hello%s/[email protected]/stable" % num, self.client.user_io.out)

        self.client.run("upload Hello0* --confirm")
        self.assertIn("Uploading Hello0/[email protected]/stable",
                      self.client.user_io.out)
        self.assertIn("Recipe is up to date, upload skipped", self.client.out)
        self.assertNotIn("Hello1", self.client.user_io.out)
        self.assertNotIn("Hello2", self.client.user_io.out)
        self.assertNotIn("Hello3", self.client.user_io.out)