Exemplo n.º 1
0
    def reuse_test(self):
        self._export_upload("hello0/0.1@lasote/stable")
        self._export_upload("hello1/0.1@lasote/stable", 1, [0])
        self._export_upload("hello2/0.1@lasote/stable", 2, [0])
        self._export_upload("hello3/0.1@lasote/stable", 3, [1, 2])

        client = TestClient(servers=self.servers, users=[("lasote", "mypass")])  # Mocked userio
        conan_reference = ConanFileReference.loads("hello4/0.2@lasote/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/0.1@lasote/stable --all")
        self.assertEqual(str(client.user_io.out).count("Uploading package"), 1)
        client.run("upload hello1/0.1@lasote/stable --all")
        self.assertEqual(str(client.user_io.out).count("Uploading package"), 1)
        client.run("upload hello2/0.1@lasote/stable --all")
        self.assertEqual(str(client.user_io.out).count("Uploading package"), 1)
        client.run("upload hello0/0.1@lasote/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/0.2@lasote/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:])
Exemplo n.º 2
0
    def reuse_test(self):
        self._export_upload("hello0/0.1@lasote/stable")
        self._export_upload("hello1/0.1@lasote/stable", 1, [0])
        self._export_upload("hello2/0.1@lasote/stable", 2, [0])
        self._export_upload("hello3/0.1@lasote/stable", 3, [1, 2])

        client = TestClient(servers=self.servers, users=[("lasote", "mypass")])  # Mocked userio
        conan_reference = ConanFileReference.loads("hello4/0.2@lasote/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 = os.sep.join([".", "bin", "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/0.1@lasote/stable --all")
        self.assertEqual(str(client.user_io.out).count("Uploading package"), 1)
        client.run("upload hello1/0.1@lasote/stable --all")
        self.assertEqual(str(client.user_io.out).count("Uploading package"), 1)
        client.run("upload hello2/0.1@lasote/stable --all")
        self.assertEqual(str(client.user_io.out).count("Uploading package"), 1)
        client.run("upload hello0/0.1@lasote/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/0.2@lasote/stable")

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

        client2.run("install --build missing")
        command = os.sep.join([".", "bin", "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:])
Exemplo n.º 3
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))
Exemplo n.º 4
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))
Exemplo n.º 5
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/1.2.1@frodo/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/1.2.1@frodo/stable", self.client.user_io.out)
Exemplo n.º 6
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)
Exemplo n.º 7
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/1.2.1@frodo/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/1.2.1@frodo/stable", self.client.user_io.out)
Exemplo n.º 8
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)
Exemplo n.º 9
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/1.2.1@frodo/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)
Exemplo n.º 10
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/1.2.1@frodo/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)
Exemplo n.º 11
0
    def check_upload_confirm_question_test(self):
        user_io = MockedUserIO({"default": [("lasote", "mypass")]},
                               out=TestBufferConanOutput())
        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/1.2.1@frodo/stable", self.client.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/1.2.1@frodo/stable",
                         self.client.out)
Exemplo n.º 12
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/0.1@lasote/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))
Exemplo n.º 13
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/0.1@lasote/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))
Exemplo n.º 14
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={"default":[("lasote", "mypass")]})

        # Export and upload the conanfile
        self.conan_reference = ConanFileReference.loads("hello0/0.1@lasote/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))
Exemplo n.º 15
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/1.2.1@frodo/stable" % num, self.client.user_io.out)

        self.client.run("upload Hello0* --confirm")
        self.assertIn("Uploaded conan recipe 'Hello0/1.2.1@frodo/stable' to 'default'",
                      self.client.user_io.out)
        self.assertNotIn("Uploading Hello1/1.2.1@frodo/stable", self.client.user_io.out)
Exemplo n.º 16
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/1.2.1@frodo/stable" % num,
                          self.client.out)

        self.client.run("upload Hello0* --confirm")
        self.assertIn("Uploading Hello0/1.2.1@frodo/stable", self.client.out)
        self.assertIn("Recipe is up to date, upload skipped", self.client.out)
        self.assertNotIn("Hello1", self.client.out)
        self.assertNotIn("Hello2", self.client.out)
        self.assertNotIn("Hello3", self.client.out)
Exemplo n.º 17
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/1.2.1@frodo/stable" % num, self.client.user_io.out)

        self.client.run("upload Hello0* --confirm")
        self.assertIn("Uploading Hello0/1.2.1@frodo/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)
Exemplo n.º 18
0
    def reuse_test(self):
        self._export_upload("hello0/0.1@lasote/stable")
        self._export_upload("hello1/0.1@lasote/stable", 1, [0])
        self._export_upload("hello2/0.1@lasote/stable", 2, [0])
        self._export_upload("hello3/0.1@lasote/stable", 3, [1, 2])

        client = TestClient(servers=self.servers,
                            users={"default": [("lasote", "mypass")]})
        ref = ConanFileReference.loads("hello4/0.2@lasote/stable")
        files3 = hello_conan_files(ref=ref, number=4, deps=[3], lang='go')
        client.save(files3)
        client.run("install . --build missing")
        client.run("build .")

        with environment_append({
                "PATH": ['$GOPATH/bin'],
                'GOPATH': client.current_folder
        }):
            with client.chdir("src"):
                client.run_command('go install hello4_main')
        if platform.system() == "Windows":
            command = "hello4_main"
        else:
            command = './hello4_main'
        with client.chdir("bin"):
            client.run_command(command)

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

        # Try to upload and reuse the binaries
        client.run("upload hello3/0.1@lasote/stable --all")
        self.assertEqual(str(client.out).count("Uploading package"), 1)
        client.run("upload hello1/0.1@lasote/stable --all")
        self.assertEqual(str(client.out).count("Uploading package"), 1)
        client.run("upload hello2/0.1@lasote/stable --all")
        self.assertEqual(str(client.out).count("Uploading package"), 1)
        client.run("upload hello0/0.1@lasote/stable --all")
        self.assertEqual(str(client.out).count("Uploading package"), 1)
        #
        client2 = TestClient(servers=self.servers,
                             users={"default": [("lasote", "mypass")]})
        ref = ConanFileReference.loads("hello4/0.2@lasote/stable")

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

        client2.run("install . --build missing")
        with environment_append({
                "PATH": ['$GOPATH/bin'],
                'GOPATH': client2.current_folder
        }):
            with client2.chdir("src"):
                client2.run_command('go install hello4_main')
        if platform.system() == "Windows":
            command = "hello4_main"
        else:
            command = './hello4_main'
        with client2.chdir("bin"):
            client2.run_command(command)

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