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:])
def reuse_test(self): conan_reference = ConanFileReference.loads("stringutil/0.1@lasote/stable") files = {'conanfile.py': stringutil_conanfile, 'reverse.go': reverse, 'reverse_test.go': reverse_test, 'reverse.txt': reverse, 'hello/helloreverse.txt': reverse} files_without_conanfile = set(files.keys()) - set(["conanfile.py"]) self.client.save(files) self.client.run("export . lasote/stable") self.client.run("install %s --build missing" % str(conan_reference)) # Check compilation ok package_ids = self.client.paths.conan_packages(conan_reference) self.assertEquals(len(package_ids), 1) package_ref = PackageReference(conan_reference, package_ids[0]) self._assert_package_exists(package_ref, self.client.paths, files_without_conanfile) # Upload conans self.client.run("upload %s" % str(conan_reference)) # Check that conans exists on server server_paths = self.servers["default"].paths conan_path = server_paths.export(conan_reference) self.assertTrue(os.path.exists(conan_path)) # Upload package self.client.run("upload %s -p %s" % (str(conan_reference), str(package_ids[0]))) # Check library on server self._assert_package_exists_in_server(package_ref, server_paths, files_without_conanfile) # Now from other "computer" install the uploaded conans with same options (nothing) other_conan = TestClient(servers=self.servers, users={"default": [("lasote", "mypass")]}) other_conan.run("install %s --build missing" % str(conan_reference)) # Build should be empty build_path = other_conan.paths.build(package_ref) self.assertFalse(os.path.exists(build_path)) # Lib should exist self._assert_package_exists(package_ref, other_conan.paths, files_without_conanfile) reuse_conan = TestClient(servers=self.servers, users={"default": [("lasote", "mypass")]}) files = {'conanfile.py': reuse_conanfile, 'src/hello/main.go': main} reuse_conan.save(files) reuse_conan.run("install . --build missing") with CustomEnvPath(paths_to_add=['$GOPATH/bin'], var_to_add=[('GOPATH', reuse_conan.current_folder), ]): if platform.system() == "Windows": command = "hello" else: command = './hello' reuse_conan.runner('go install hello', cwd=reuse_conan.current_folder) reuse_conan.runner(command, cwd=os.path.join(reuse_conan.current_folder, 'bin')) self.assertIn("Hello, Go!", reuse_conan.user_io.out)