示例#1
0
    def test_if_cxxd_config_parser_returns_valid_configuration_when_there_are_multiple_configs_existing(
            self):
        self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section(
            [
                '\
{                                               \n\
    "configuration" : {                         \n\
        "type" : "compilation-database",        \n\
        "compilation-database" : {              \n\
            "target" : {                        \n\
                "rel" : "/tmp"                  \n\
            }                                   \n\
        },                                      \n\
        "compile-flags" : {                     \n\
            "target" : {                        \n\
                "rel" : "/tmp"                  \n\
            }                                   \n\
        }                                       \n\
     }                                          \n\
}                                               \n\
        '
            ])
        self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name,
                                                   self.project_root_directory)
        self.assertEqual(self.cxxd_config_parser.get_configuration_type(),
                         'compilation-database')
        self.assertEqual(
            self.cxxd_config_parser.get_configuration_for_target('rel'),
            self.json_compilation_database.name)
        FileGenerator.close_gen_file(self.cxxd_config)
示例#2
0
 def test_if_cxxd_config_parser_favors_compilation_db_over_txt_when_both_are_present(
         self):
     txt_comp_db = FileGenerator.gen_txt_compilation_database()
     self.assertEqual(
         os.path.normpath(
             self.parser_with_empty_config_file.
             get_configuration_for_target('')),
         self.json_compilation_database.name)
     FileGenerator.close_gen_file(txt_comp_db)
示例#3
0
    def test_if_cxxd_config_parser_returns_auto_discovery_try_harder_when_configuration_is_missing(
            self):
        self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section(
            [
                '\
{                                               \n\
}                                               \n\
        '
            ])
        self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name,
                                                   self.project_root_directory)
        self.assertEqual(self.cxxd_config_parser.get_configuration_type(),
                         'auto-discovery-try-harder')
        FileGenerator.close_gen_file(self.cxxd_config)
示例#4
0
    def test_if_cxxd_config_parser_returns_auto_discovery_for_type(self):
        self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section(
            [
                '\
{                                               \n\
    "configuration" : {                         \n\
        "type": "auto-discovery"                \n\
    }                                           \n\
}                                               \n\
        '
            ])
        self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name,
                                                   self.project_root_directory)
        self.assertEqual(self.cxxd_config_parser.get_configuration_type(),
                         'auto-discovery')
        FileGenerator.close_gen_file(self.cxxd_config)
示例#5
0
    def test_if_cxxd_config_parser_returns_none_when_type_is_not_one_of_valid_values(
            self):
        self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section(
            [
                '\
{                                               \n\
    "configuration" : {                         \n\
        "type": "something-unsupported"         \n\
    }                                           \n\
}                                               \n\
        '
            ])
        self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name,
                                                   self.project_root_directory)
        self.assertEqual(self.cxxd_config_parser.get_configuration_type(),
                         None)
        FileGenerator.close_gen_file(self.cxxd_config)
示例#6
0
    def test_if_cxxd_config_parser_returns_none_when_for_inexisting_target_section(
            self):
        self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section(
            [
                '\
{                                               \n\
    "configuration" : {                         \n\
        "type": "compilation-database",         \n\
        "compilation-database" : {              \n\
        }                                       \n\
     }                                          \n\
}                                               \n\
        '
            ])
        self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name,
                                                   self.project_root_directory)
        self.assertEqual(
            self.cxxd_config_parser.get_configuration_for_target('whatever'),
            None)
        FileGenerator.close_gen_file(self.cxxd_config)
示例#7
0
    def test_if_cxxd_config_parser_returns_none_when_auto_discovery_does_not_contain_any_search_paths(
            self):
        self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section(
            [
                '\
{                                               \n\
    "configuration" : {                         \n\
        "type": "auto-discovery",               \n\
        "auto-discovery" : {                    \n\
        }                                       \n\
     }                                          \n\
}                                               \n\
        '
            ])
        self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name,
                                                   self.project_root_directory)
        self.assertEqual(self.cxxd_config_parser.get_configuration_type(),
                         'auto-discovery')
        self.assertEqual(
            self.cxxd_config_parser.get_configuration_for_target('whatever'),
            None)
        FileGenerator.close_gen_file(self.cxxd_config)
示例#8
0
    def test_if_cxxd_config_parser_returns_config_found_in_auto_discovery_search_path(
            self):
        self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section(
            [
                '\
{                                               \n\
    "configuration" : {                         \n\
        "type": "auto-discovery",               \n\
        "auto-discovery" : {                    \n\
            "search-paths" : ["/tmp"]           \n\
        }                                       \n\
     }                                          \n\
}                                               \n\
        '
            ])
        self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name,
                                                   self.project_root_directory)
        self.assertEqual(self.cxxd_config_parser.get_configuration_type(),
                         'auto-discovery')
        self.assertEqual(
            self.cxxd_config_parser.get_configuration_for_target('whatever'),
            self.json_compilation_database.name)
        FileGenerator.close_gen_file(self.cxxd_config)
示例#9
0
    def test_if_cxxd_config_parser_returns_none_configuration_when_config_for_selected_type_is_missing(
            self):
        self.cxxd_config = FileGenerator.gen_cxxd_config_filename_with_invalid_section(
            [
                '\
{                                               \n\
    "configuration" : {                         \n\
        "type" : "compilation-database",        \n\
        "compile-flags" : {                     \n\
            "target" : {                        \n\
                "rel" : "/rel"                  \n\
            }                                   \n\
        }                                       \n\
     }                                          \n\
}                                               \n\
        '
            ])
        self.cxxd_config_parser = CxxdConfigParser(self.cxxd_config.name,
                                                   self.project_root_directory)
        self.assertEqual(self.cxxd_config_parser.get_configuration_type(),
                         'compilation-database')
        self.assertEqual(
            self.cxxd_config_parser.get_configuration_for_target('rel'), None)
        FileGenerator.close_gen_file(self.cxxd_config)
示例#10
0
 def tearDownClass(cls):
     FileGenerator.close_gen_file(cls.cxxd_config)
     FileGenerator.close_gen_file(cls.empty_cxxd_config)
示例#11
0
 def tearDownClass(cls):
     FileGenerator.close_gen_file(cls.file_to_be_built)
     FileGenerator.close_gen_file(cls.cxxd_config)
示例#12
0
 def tearDownClass(cls):
     FileGenerator.close_gen_file(cls.file_to_perform_clang_tidy_on)
     FileGenerator.close_gen_file(cls.json_compilation_database)
     FileGenerator.close_gen_file(cls.cxxd_config_with_json_comp_db)
 def tearDownClass(cls):
     FileGenerator.close_gen_file(cls.file_to_be_built)
     FileGenerator.close_gen_file(cls.json_compilation_database)
示例#14
0
 def tearDownClass(cls):
     FileGenerator.close_gen_file(cls.file_to_perform_clang_tidy_on)
示例#15
0
 def tearDownClass(cls):
     FileGenerator.close_gen_file(cls.file_to_perform_clang_format_on)
     FileGenerator.close_gen_file(cls.clang_format_config_file)
     FileGenerator.close_gen_file(cls.cxxd_config)
示例#16
0
 def tearDownClass(cls):
     FileGenerator.close_gen_file(cls.txt_compilation_database)
示例#17
0
 def tearDownClass(cls):
     FileGenerator.close_gen_file(cls.json_compilation_database)
     FileGenerator.close_gen_file(cls.cxxd_config)
示例#18
0
 def tearDownClass(cls):
     FileGenerator.close_gen_file(cls.test_file)
     FileGenerator.close_gen_file(cls.test_file_edited)
     FileGenerator.close_gen_file(cls.test_file_broken)
     FileGenerator.close_gen_file(cls.test_file_broken_edited)
     FileGenerator.close_gen_file(cls.txt_compilation_database)
示例#19
0
 def tearDownClass(cls):
     FileGenerator.close_gen_file(cls.test_file_with_no_diagnostics)
     FileGenerator.close_gen_file(cls.test_file_with_no_diagnostics_edited)
     FileGenerator.close_gen_file(cls.test_file_with_compile_errors)
     FileGenerator.close_gen_file(cls.test_file_with_compile_errors_edited)
     FileGenerator.close_gen_file(cls.txt_compilation_database)
 def tearDownClass(cls):
     FileGenerator.close_gen_file(cls.test_file)
     FileGenerator.close_gen_file(cls.test_file_with_includes_only)
     FileGenerator.close_gen_file(cls.txt_compilation_database)