コード例 #1
0
    def test_json(self):

        # Upload to server Hello1 => Hello0 and Hello2 => Hello0
        files = cpp_hello_conan_files("Hello0", "1.0", deps=[], build=False)
        self.client.save(files)
        self.client.run("export . lasote/stable")

        files = cpp_hello_conan_files("Hello1",
                                      "1.0",
                                      deps=["Hello0/1.0@lasote/stable"],
                                      build=False)
        self.client.save(files)
        self.client.run("export . lasote/stable")

        files = cpp_hello_conan_files("Hello2",
                                      "1.0",
                                      deps=["Hello0/1.0@lasote/stable"],
                                      build=False)
        self.client.save(files)
        self.client.run("export . lasote/stable")
        self.client.run("install Hello1/1.0@lasote/stable --build missing")
        self.client.run("install Hello2/1.0@lasote/stable --build missing")
        self.client.run("upload '*' -c --all")

        # Remove all from local cache
        self.client.run("remove '*' -f")

        # Now activate logs and install both Hello1 and Hello2
        trace_file = os.path.join(temp_folder(), "conan_trace.log")
        with tools.environment_append({"CONAN_TRACE_FILE": trace_file}):
            self.client.run("install Hello0/1.0@lasote/stable")
            self.client.run("upload '*' -c --all")
            data = get_build_info(trace_file).serialize()
            # Only uploaded 2 modules, the Hello0 recipe and the Hello0 package
            # without dependencies
            self.assertEquals(len(data["modules"]), 2)
            self.assertEquals(len(data["modules"][0]["dependencies"]), 0)
            self.assertEquals(len(data["modules"][0]["dependencies"]), 0)
            self.assertEquals(len(data["modules"][0]["artifacts"]), 3)

            # Now upload the rest of them
            self.client.run("install Hello1/1.0@lasote/stable --build missing")
            self.client.run("install Hello2/1.0@lasote/stable --build missing")
            self.client.run("upload '*' -c --all")
            data = get_build_info(trace_file).serialize()
            self.assertEquals(len(data["modules"]), 6)
            for mod_name in [
                    "Hello1/1.0@lasote/stable", "Hello2/1.0@lasote/stable"
            ]:
                module = _get_module(data, mod_name)
                self.assertEquals(3, len(module["dependencies"]))
                self.assertEquals(3, len(module["artifacts"]))
                for dep in module["dependencies"]:
                    self.assertTrue(
                        dep["id"].startswith("Hello0/1.0@lasote/stable"))
コード例 #2
0
ファイル: command.py プロジェクト: yiakwy/conan
def runv1():
    output = ConanOutput(sys.stdout, sys.stderr, True)
    parser = argparse.ArgumentParser(description='Extracts build-info from a specified '
                                                 'conan trace log and return a valid JSON')
    parser.add_argument('trace_path', help='Path to the conan trace log file e.g.: '
                                           '/tmp/conan_trace.log')
    parser.add_argument("--output", default=False,
                        help='Optional file to output the JSON contents, if not specified the JSON'
                             ' will be printed to stdout')

    try:
        args = parser.parse_args()

        if not os.path.exists(args.trace_path):
            output.error("Conan trace log not found! '%s'" % args.trace_path)
            exit(1)
        if args.output and not os.path.exists(os.path.dirname(args.output)):
            output.error("Output file directory not found! '%s'" % args.trace_path)
            exit(1)

        info = get_build_info(args.trace_path)
        the_json = json.dumps(info.serialize())
        if args.output:
            save(args.output, the_json)
        else:
            output.write(the_json)
    except Exception as exc:
        output.error(exc)
        exit(1)
    except SystemExit:
        output.writeln("")
        output.warn("Use 'conan_build_info --v2' to see the usage of the new recommended way to "
                    "generate build info using lockfiles")
コード例 #3
0
    def test_cross_remotes(self):

        # Upload to alternative server Hello0 but Hello1 to the default
        self.client.save({"conanfile.py": GenConanfile("Hello0", "1.0")})
        self.client.run("export . lasote/stable")

        self.client.save({
            "conanfile.py":
            GenConanfile("Hello1",
                         "1.0").with_requires("Hello0/1.0@lasote/stable")
        })
        self.client.run("export . lasote/stable")

        self.client.run("export . lasote/stable")
        self.client.run("install Hello1/1.0@lasote/stable --build missing")

        self.client.run("upload 'Hello0*' -c --all -r alternative")
        self.client.run("upload 'Hello1*' -c --all -r default")

        trace_file = os.path.join(temp_folder(), "conan_trace.log")
        with tools.environment_append({"CONAN_TRACE_FILE": trace_file}):
            # Will retrieve the Hello0 deps from the alternative
            self.client.run("install Hello1/1.0@lasote/stable --build")

            # Upload to the default, not matching the Hello0 remote
            self.client.run("upload 'Hello1*' -c --all -r default")

            data = get_build_info(trace_file).serialize()
            self.assertEqual(len(data["modules"]), 2)
            module = _get_module(data, "Hello1/1.0@lasote/stable")
            self.assertEqual(0, len(module["dependencies"]))
コード例 #4
0
def run():

    parser = argparse.ArgumentParser(description='Extracts build-info from a specified '
                                                 'conan trace log and return a valid JSON')
    parser.add_argument('trace_path', help='Path to the conan trace log file e.j: '
                                           '/tmp/conan_trace.log')
    parser.add_argument("--output", default=False,
                        help='Optional file to output the JSON contents, if not specified the JSON'
                             ' will be printed to stdout')

    args = parser.parse_args()

    if not os.path.exists(args.trace_path):
        print("Error, conan trace log not found! '%s'" % args.trace_path)
        exit(1)
    if args.output and not os.path.exists(os.path.dirname(args.output)):
        print("Error, output file directory not found! '%s'" % args.trace_path)
        exit(1)

    try:
        info = get_build_info(args.trace_path)
        the_json = json.dumps(info.serialize())
        if args.output:
            save(args.output, the_json)
        else:
            print(the_json)
    except Exception as exc:
        print(exc)
        exit(1)
コード例 #5
0
    def test_cross_remotes(self):

        # Upload to alternative server Hello0 but Hello1 to the default
        files = cpp_hello_conan_files("Hello0", "1.0", deps=[], build=False)
        self.client.save(files)
        self.client.run("export . lasote/stable")

        files = cpp_hello_conan_files("Hello1", "1.0", deps=["Hello0/1.0@lasote/stable"], build=False)
        self.client.save(files)
        self.client.run("export . lasote/stable")

        self.client.run("export . lasote/stable")
        self.client.run("install Hello1/1.0@lasote/stable --build missing")

        self.client.run("upload 'Hello0*' -c --all -r alternative")
        self.client.run("upload 'Hello1*' -c --all -r default")

        trace_file = os.path.join(temp_folder(), "conan_trace.log")
        with tools.environment_append({"CONAN_TRACE_FILE": trace_file}):
            # Will retrieve the Hello0 deps from the alternative
            self.client.run("install Hello1/1.0@lasote/stable --build")

            # Upload to the default, not matching the Hello0 remote
            self.client.run("upload 'Hello1*' -c --all -r default")

            data = get_build_info(trace_file).serialize()
            self.assertEquals(len(data["modules"]), 2)
            module = _get_module(data, "Hello1/1.0@lasote/stable")
            self.assertEquals(0, len(module["dependencies"]))
コード例 #6
0
    def test_json(self):

        # Upload to server Hello1 => Hello0 and Hello2 => Hello0
        files = cpp_hello_conan_files("Hello0", "1.0", deps=[], build=False)
        self.client.save(files)
        self.client.run("export . lasote/stable")

        files = cpp_hello_conan_files("Hello1", "1.0", deps=["Hello0/1.0@lasote/stable"], build=False)
        self.client.save(files)
        self.client.run("export . lasote/stable")

        files = cpp_hello_conan_files("Hello2", "1.0", deps=["Hello0/1.0@lasote/stable"], build=False)
        self.client.save(files)
        self.client.run("export . lasote/stable")
        self.client.run("install Hello1/1.0@lasote/stable --build missing")
        self.client.run("install Hello2/1.0@lasote/stable --build missing")
        self.client.run("upload '*' -c --all")

        # Remove all from local cache
        self.client.run("remove '*' -f")

        # Now activate logs and install both Hello1 and Hello2
        trace_file = os.path.join(temp_folder(), "conan_trace.log")
        with tools.environment_append({"CONAN_TRACE_FILE": trace_file}):
            self.client.run("install Hello0/1.0@lasote/stable")
            self.client.run("upload '*' -c --all")
            data = get_build_info(trace_file).serialize()
            # Only uploaded 2 modules, the Hello0 recipe and the Hello0 package
            # without dependencies
            self.assertEquals(len(data["modules"]), 2)
            self.assertEquals(len(data["modules"][0]["dependencies"]), 0)
            self.assertEquals(len(data["modules"][0]["dependencies"]), 0)
            self.assertEquals(len(data["modules"][0]["artifacts"]), 3)

            # Now upload the rest of them
            self.client.run("install Hello1/1.0@lasote/stable --build missing")
            self.client.run("install Hello2/1.0@lasote/stable --build missing")
            self.client.run("upload '*' -c --all")
            data = get_build_info(trace_file).serialize()
            self.assertEquals(len(data["modules"]), 6)
            for mod_name in ["Hello1/1.0@lasote/stable", "Hello2/1.0@lasote/stable"]:
                module = _get_module(data, mod_name)
                self.assertEquals(3, len(module["dependencies"]))
                self.assertEquals(3, len(module["artifacts"]))
                for dep in module["dependencies"]:
                    self.assertTrue(dep["id"].startswith("Hello0/1.0@lasote/stable"))
コード例 #7
0
    def test_only_download(self):
        files = cpp_hello_conan_files("Hello", "1.0", build=False)
        self.client.save(files)
        self.client.run("export . lasote/stable")
        self.client.run("upload '*' -c --all")
        trace_file = os.path.join(temp_folder(), "conan_trace.log")
        self.client.run("remove '*' -f")
        with tools.environment_append({"CONAN_TRACE_FILE": trace_file}):
            self.client.run("install Hello/1.0@lasote/stable --build")

        data = get_build_info(trace_file).serialize()
        self.assertEquals(len(data["modules"]), 1)
        self.assertEquals(data["modules"][0]["id"], "DownloadOnly")
        self.assertEquals(len(data["modules"][0]["artifacts"]), 0)
        self.assertEquals(len(data["modules"][0]["dependencies"]), 3)
コード例 #8
0
    def test_only_download(self):
        files = cpp_hello_conan_files("Hello", "1.0", build=False)
        self.client.save(files)
        self.client.run("export . lasote/stable")
        self.client.run("upload '*' -c --all")
        trace_file = os.path.join(temp_folder(), "conan_trace.log")
        self.client.run("remove '*' -f")
        with tools.environment_append({"CONAN_TRACE_FILE": trace_file}):
            self.client.run("install Hello/1.0@lasote/stable --build")

        data = get_build_info(trace_file).serialize()
        self.assertEquals(len(data["modules"]), 1)
        self.assertEquals(data["modules"][0]["id"], "DownloadOnly")
        self.assertEquals(len(data["modules"][0]["artifacts"]), 0)
        self.assertEquals(len(data["modules"][0]["dependencies"]), 3)
コード例 #9
0
    def test_only_download(self):
        self.client.save({
            "conanfile.py":
            GenConanfile("Hello", "1.0").with_exports("*").with_package_file(
                "file", "content"),
            "file.h":
            ""
        })
        self.client.run("export . lasote/stable")
        self.client.run("upload '*' -c --all")
        trace_file = os.path.join(temp_folder(), "conan_trace.log")
        self.client.run("remove '*' -f")
        with tools.environment_append({"CONAN_TRACE_FILE": trace_file}):
            self.client.run("install Hello/1.0@lasote/stable --build")

        data = get_build_info(trace_file).serialize()
        self.assertEqual(len(data["modules"]), 1)
        self.assertEqual(data["modules"][0]["id"], "DownloadOnly")
        self.assertEqual(len(data["modules"][0]["artifacts"]), 0)
        self.assertEqual(len(data["modules"][0]["dependencies"]), 3)
コード例 #10
0
 def test_invalid_tracer(self):
     trace_file = os.path.join(temp_folder(), "conan_trace.log")
     save(trace_file, "invalid contents")
     with six.assertRaisesRegex(self, Exception, "INVALID TRACE FILE!"):
         get_build_info(trace_file).serialize()
コード例 #11
0
 def test_invalid_tracer(self):
     trace_file = os.path.join(temp_folder(), "conan_trace.log")
     save(trace_file, "invalid contents")
     with self.assertRaisesRegexp(Exception, "INVALID TRACE FILE!"):
         get_build_info(trace_file).serialize()