Esempio n. 1
0
def check_modified_file(filename, errors):
    """Check each modified file to make sure it adheres to the standards"""
    # skip code that isn't ours
    if filename.find("dependency") != -1 or "/eigen3/" in filename:
        return
    # don't check header guard in template headers
    if filename.find("templates") != -1:
        return
    info = python_tools.get_project_info(filename)
    if filename.endswith('.h') or filename.endswith('.cpp') \
       or filename.endswith('.c'):
        check_c_file(filename, errors)
        # don't check header guard in template headers
        if cpp_format and filename.endswith('.h') and filename.find("templates") == -1:
            cpp_format.check_header_file(
                get_file(filename),
                info["name"],
                errors)
        elif cpp_format and filename.endswith('.cpp'):
            cpp_format.check_cpp_file(
                get_file(filename),
                info["name"],
                errors)
    elif filename.endswith('.py'):
        check_python_file(filename, errors)
Esempio n. 2
0
def check_modified_file(filename, errors):
    """Check each modified file to make sure it adheres to the standards"""
    # skip code that isn't ours
    if filename.find("dependency") != -1 or "/eigen3/" in filename:
        return
    # don't check header guard in template headers
    if filename.find("templates") != -1:
        return
    info = python_tools.get_project_info(filename)
    if filename.endswith('.h') or filename.endswith('.cpp') \
       or filename.endswith('.c'):
        check_c_file(filename, errors)
        # don't check header guard in template headers
        if cpp_format and filename.endswith('.h') and filename.find("templates") == -1:
            cpp_format.check_header_file(
                get_file(filename),
                info["name"],
                errors)
        elif cpp_format and filename.endswith('.cpp'):
            cpp_format.check_cpp_file(
                get_file(filename),
                info["name"],
                errors)
    elif filename.endswith('.py'):
        check_python_file(filename, errors)
Esempio n. 3
0
 def test_check_cpp_file(self):
     """Test check_cpp_file()"""
     def ok_tokenize(fh):
         return ok_header_tokens
     with utils.mocked_function(cpp_format, 'tokenize_file', ok_tokenize):
         errors = []
         cpp_format.check_cpp_file((None, "/foo/bar/test.cpp"),
                                   "IMP.kernel", errors)
         self.assertEqual(errors, [])
Esempio n. 4
0
 def test_check_cpp_file_test(self):
     """Test check_cpp_file() with a test file"""
     def empty_tokenize(fh):
         return []
     with utils.mocked_function(cpp_format, 'tokenize_file', empty_tokenize):
         errors = []
         cpp_format.check_cpp_file((None, "/foo/bar/test_foo.cpp"),
                                   "IMP.kernel", errors)
         self.assertEqual(errors, [])
Esempio n. 5
0
 def test_check_cpp_file(self):
     """Test check_cpp_file()"""
     def ok_tokenize(fh):
         return ok_header_tokens
     with utils.mocked_function(cpp_format, 'tokenize_file', ok_tokenize):
         errors = []
         cpp_format.check_cpp_file((None, "/foo/bar/test.cpp"),
                                   "IMP.kernel", errors)
         self.assertEqual(errors, [])
Esempio n. 6
0
 def test_check_cpp_file_test(self):
     """Test check_cpp_file() with a test file"""
     def empty_tokenize(fh):
         return []
     with utils.mocked_function(cpp_format, 'tokenize_file',
                                empty_tokenize):
         errors = []
         cpp_format.check_cpp_file((None, "/foo/bar/test_foo.cpp"),
                                   "IMP.kernel", errors)
         self.assertEqual(errors, [])