def generate_qitest_json(self):
        """ The qitest.cmake is written from CMake """
        qitest_cmake_path = os.path.join(self.build_directory, "qitest.cmake")
        tests = list()
        if os.path.exists(qitest_cmake_path):
            with open(qitest_cmake_path, "r") as fp:
                lines = fp.readlines()
        else:
            lines = list()
        parser = argparse.ArgumentParser()
        parser.add_argument("cmd", nargs="+")
        parser.add_argument("--name", required=True)
        parser.add_argument("--gtest", action="store_true",
                            help="Tell qitest this is a test using gtest")
        parser.add_argument("--timeout", type=int)
        parser.add_argument("--nightly", action="store_true")
        parser.add_argument("--perf", action="store_true")
        parser.add_argument("--working-directory")
        parser.add_argument("--env", action="append",
                            dest="environment")
        parser.set_defaults(nightly=False, perf=False)
        def log_error(message, line):
            test_name = line.split(";")[1]
            mess = "Could not parse test options for test: '%s'\n" % test_name
            mess += "Error was: %s" % message
            ui.error(mess)
        for line in lines:
            parser.error = lambda message : log_error(message, line)
            line = line.strip()
            try:
                args = parser.parse_args(args=line.split(";"))
            except __HOLE__:
                break
            test = vars(args)
            as_list = test["environment"]
            if as_list:
                test["environment"] = dict(x.split("=") for x in as_list)
            tests.append(test)
        with open(self.qitest_json, "w") as fp:
            json.dump(tests, fp, indent=2)
dataset/ETHPy150Open aldebaran/qibuild/python/qibuild/project.py/BuildProject.generate_qitest_json