!1244 check工具增加对非兼容性变更检测

Merge pull request !1244 from zhangwu/master
This commit is contained in:
openharmony_ci 2024-08-21 02:30:01 +00:00 committed by Gitee
commit 1e95130f1f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 334 additions and 58 deletions

View File

@ -18,9 +18,11 @@ import os.path
import openpyxl as op
from pathlib import Path
from typedef.check.check import FileDocInfo, check_command_message, CheckErrorMessage
from typedef.check.check_compatibility import check_compatibility_command_message
from coreImpl.check.check_doc import process_comment, process_file_doc_info
from coreImpl.check.check_name import check_file_name, check_api_name
from coreImpl.parser.parser import parser_include_ast
from coreImpl.check.check_compatibility import check_compatibility_entrance
def process_api_json(api_info, file_doc_info, api_result_info_list, parent_kind, command_list):
@ -112,7 +114,7 @@ def write_in_txt(check_result, output_path):
def result_to_json(check_result):
return json.dumps(check_result, default=lambda obj: obj.__dict__, indent=4)
return json.dumps(check_result, default=lambda obj: obj.__dict__, indent=4, ensure_ascii=False)
def get_file_path(txt_file): # 路径装在txt文件用的--获取.h文件路径
@ -134,8 +136,10 @@ def curr_entry(files_path, command: str, output):
return
if command == 'all':
command_list = check_command_message
command_of_compatibility_list = check_compatibility_command_message
else:
command_list = command.split(',')
command_of_compatibility_list = command_list
check_result_list = []
if len(file_list) > 0:
check_result_list = get_check_result_list(file_list, root_path, command_list)
@ -146,6 +150,11 @@ def curr_entry(files_path, command: str, output):
result_list.append(result)
else:
result_list = check_result_list
old_dir = r''
new_dir = r''
if old_dir and new_dir:
compatibility_data = check_compatibility_entrance(old_dir, new_dir, command_of_compatibility_list)
result_list.extend(compatibility_data)
write_in_txt(result_list, output)

View File

@ -0,0 +1,49 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from coreImpl.diff.diff_file import check_diff_entrance
from typedef.check.check import CheckOutPut
from typedef.check.check_compatibility import match_diff_and_check_scene_dict, CheckCompatibilityErrorMessage
def process_each_diff_data(diff_data: list, compatibility_rule: list):
check_compatibility_result_list = []
for element in diff_data:
diff_type_message = element.diff_type.name
match_check_rule = match_diff_and_check_scene_dict.get(diff_type_message)
if (not element.is_compatible) and match_check_rule and match_check_rule in compatibility_rule:
old_different_content = str(element.old_differ_content)
new_different_content = str(element.new_differ_content)
match_check_message = (CheckCompatibilityErrorMessage.get_rule_message(match_check_rule)
.replace('$$', old_different_content).replace('&&', new_different_content))
old_declara = element.old_api_declara
new_declara = element.new_api_declara
content_line = element.api_line
if element.file_doc_line != 0:
content_line = element.file_doc_line
main_buggy_code = 'Old since:{}\nNew since:{}'.format(old_declara, new_declara)
result_obj = CheckOutPut(element.api_file_path, content_line, match_check_rule, match_check_message,
main_buggy_code, content_line)
check_compatibility_result_list.append(result_obj)
return check_compatibility_result_list
def check_compatibility_entrance(old_dir, new_dir, compatibility_rule: list):
diff_data = check_diff_entrance(old_dir, new_dir)
check_compatibility_data_list = process_each_diff_data(diff_data, compatibility_rule)
return check_compatibility_data_list

View File

@ -447,7 +447,7 @@ def process_comment(comment: str, file_doc_info: FileDocInfo, api_info) -> list:
comment_start_line = api_info['location']['location_line'] - comment.count('\n') - 1
for index, item in enumerate(result_json):
if api_info['kind'] == CursorKind.TRANSLATION_UNIT.name and len(item['tags']) > 0 and\
item['tags'][0]['tag'] == '}' and index <= len(api_info['line_list']) - 1:
item['tags'][0]['tag'] == '}' and 'line_list' in api_info and index <= len(api_info['line_list']) - 1:
comment_start_line = api_info['line_list'][index]
api_result_info_list.extend(process_each_comment(item, file_doc_info, api_info, comment_start_line))
if index == len(result_json) - 1:

View File

@ -17,6 +17,7 @@ import filecmp
import json
import os
import stat
import re
from collections import OrderedDict
import openpyxl as op
from coreImpl.parser.parser import diff_parser_include_ast
@ -175,6 +176,12 @@ def start_diff_file(old_dir, new_dir, output_path):
write_in_txt(result_json, output_path_txt)
def check_diff_entrance(old_dir, new_dir):
result_info_list = global_assignment(old_dir, new_dir)
return result_info_list
def disposal_result_data(result_info_list):
data = []
for diff_info in result_info_list:
@ -252,10 +259,14 @@ def get_file_ext(file_name):
def filter_ignore_file(file_path):
ignore_dict = IgnoreFileDirectory.ignore_file_dict
for key in ignore_dict.keys():
if key in file_path:
return False
norm_file_path = os.path.normpath(file_path)
if os.name == 'nt': # Windows
pattern = re.compile(IgnoreFileDirectory.IGNORE_FILE_DIR_wd.value)
else: # Linux / macOS
pattern = re.compile(IgnoreFileDirectory.IGNORE_FILE_DIR_lx.value)
# 检查匹配
if pattern.search(norm_file_path):
return False
return True

View File

@ -68,6 +68,8 @@ def wrap_diff_info(old_info, new_info, diff_info: DiffInfo):
else:
api_declare = old_info['name']
if old_info['kind'] != 'TRANSLATION_UNIT':
diff_info.set_old_api_declara(api_declare)
old_content = '类名:{};\nAPI声明:{};\n差异内容:{}\n'.format(diff_info.class_name, api_declare,
diff_info.old_differ_content)
diff_info.set_old_api_full_text(old_content)
@ -87,6 +89,8 @@ def wrap_diff_info(old_info, new_info, diff_info: DiffInfo):
api_declare = new_info['node_content']['content']
else:
api_declare = new_info['name']
if new_info['kind'] != 'TRANSLATION_UNIT':
diff_info.set_new_api_declara(api_declare)
new_content = '类名:{};\nAPI声明:{};\n差异内容:{}\n'.format(diff_info.class_name, api_declare,
diff_info.new_differ_content)
@ -423,7 +427,7 @@ def process_union_name(old, new, diff_union_list):
if old['name'] != new['name']:
old_union_name = old['name']
new_union_name = new['name']
result_message_obj = get_initial_result_obj(DiffType.STRUCT_MEMBER_NAME_CHANGE,
result_message_obj = get_initial_result_obj(DiffType.UNION_NAME_CHANGE,
old_union_name, new_union_name)
diff_info = wrap_diff_info(old, new, result_message_obj)
diff_union_list.append(diff_info)
@ -437,7 +441,7 @@ def process_union_member(old, new, diff_union_list):
if old_member_result.get(key) is None:
old_member_content = 'NA'
new_member_content = new_member_result.get(key)['node_content']['content']
result_message_obj = get_initial_result_obj(DiffType.STRUCT_MEMBER_NAME_CHANGE,
result_message_obj = get_initial_result_obj(DiffType.UNION_MEMBER_ADD,
old_member_content, new_member_content)
diff_info = wrap_diff_info(old_member_result.get(key), new_member_result.get(key),
@ -446,7 +450,7 @@ def process_union_member(old, new, diff_union_list):
elif new_member_result.get(key) is None:
old_member_content = old_member_result.get(key)['node_content']['content']
new_member_content = 'NA'
result_message_obj = get_initial_result_obj(DiffType.STRUCT_MEMBER_NAME_CHANGE,
result_message_obj = get_initial_result_obj(DiffType.UNION_MEMBER_REDUCE,
old_member_content, new_member_content)
diff_info = wrap_diff_info(old_member_result.get(key), new_member_result.get(key),
@ -978,17 +982,19 @@ def process_tag_file(old_tag, new_tag, old_info, new_info):
def process_tag_library(old_tag, new_tag, old_info, new_info):
diff_info_list = []
if old_tag is None:
diff_info_list.append(
wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_LIBRARY_NA_TO_HAVE, 'NA', new_tag['name'])))
library_result_obj = DiffInfo(DiffType.DOC_TAG_LIBRARY_NA_TO_HAVE, 'NA', new_tag['name'])
set_file_doc_content_snippet(old_tag, new_tag, library_result_obj)
diff_info_list.append(wrap_diff_info(old_info, new_info, library_result_obj))
return diff_info_list
if new_tag is None:
diff_info_list.append(
wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_LIBRARY_HAVE_TO_NA, old_tag['name'], "NA")))
library_result_obj = DiffInfo(DiffType.DOC_TAG_LIBRARY_HAVE_TO_NA, old_tag['name'], "NA")
set_file_doc_content_snippet(old_tag, new_tag, library_result_obj)
diff_info_list.append(wrap_diff_info(old_info, new_info, library_result_obj))
return diff_info_list
if old_tag['name'] != new_tag['name']:
diff_info_list.append(wrap_diff_info(old_info, new_info,
DiffInfo(DiffType.DOC_TAG_LIBRARY_A_TO_B, old_tag['name'],
new_tag['name'])))
library_result_obj = DiffInfo(DiffType.DOC_TAG_LIBRARY_A_TO_B, old_tag['name'], new_tag['name'])
set_file_doc_content_snippet(old_tag, new_tag, library_result_obj)
diff_info_list.append(wrap_diff_info(old_info, new_info, library_result_obj))
return diff_info_list
@ -1013,35 +1019,47 @@ def process_tag_param(old_tag, new_tag, old_info, new_info):
return diff_info_list
def set_file_doc_content_snippet(old_tag, new_tag, diff_obj):
if old_tag is not None:
if old_tag.get('source'):
diff_obj.set_file_doc_line(old_tag.get('source')[0].get('number'))
diff_obj.set_old_api_declara(old_tag.get('source')[0].get('source'))
if new_tag is not None:
if new_tag.get('source'):
diff_obj.set_file_doc_line(new_tag.get('source')[0].get('number'))
diff_obj.set_new_api_declara(new_tag.get('source')[0].get('source'))
def process_tag_permission(old_tag, new_tag, old_info, new_info):
diff_info_list = []
if old_tag is None:
diff_info_list.append(wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_PERMISSION_NA_TO_HAVE,
'NA',
f'{new_tag["name"]} '
f'{new_tag["description"]}')))
permission_result_obj = DiffInfo(DiffType.DOC_TAG_PERMISSION_NA_TO_HAVE, 'NA', f'{new_tag["name"]} '
f'{new_tag["description"]}')
set_file_doc_content_snippet(old_tag, new_tag, permission_result_obj)
diff_info_list.append(wrap_diff_info(old_info, new_info, permission_result_obj))
return diff_info_list
if new_tag is None:
diff_info_list.append(wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_PERMISSION_HAVE_TO_NA,
f'{old_tag["name"]} '
f'{old_tag["description"]}',
'NA')))
permission_result_obj = DiffInfo(DiffType.DOC_TAG_PERMISSION_HAVE_TO_NA, f'{old_tag["name"]} '
f'{old_tag["description"]}', 'NA')
set_file_doc_content_snippet(old_tag, new_tag, permission_result_obj)
diff_info_list.append(wrap_diff_info(old_info, new_info, permission_result_obj))
return diff_info_list
old_permission = f'{old_tag["name"]} {old_tag["description"]}'
new_permission = f'{new_tag["name"]} {new_tag["description"]}'
if old_permission != new_permission:
compare_value = compare_permission(old_permission, new_permission)
if compare_value.state_range == RangeChange.DOWN.value:
diff_info_list.append(wrap_diff_info(old_info, new_info,
DiffInfo(DiffType.DOC_TAG_PERMISSION_RANGE_SMALLER, old_permission,
new_permission)))
permission_result_obj = DiffInfo(DiffType.DOC_TAG_PERMISSION_RANGE_SMALLER, old_permission, new_permission)
set_file_doc_content_snippet(old_tag, new_tag, permission_result_obj)
diff_info_list.append(wrap_diff_info(old_info, new_info, permission_result_obj))
elif compare_value.state_range == RangeChange.UP.value:
diff_info_list.append(wrap_diff_info(old_info, new_info, DiffInfo(
DiffType.DOC_TAG_PERMISSION_RANGE_BIGGER, old_permission, new_permission)))
permission_result_obj = DiffInfo(DiffType.DOC_TAG_PERMISSION_RANGE_BIGGER, old_permission, new_permission)
set_file_doc_content_snippet(old_tag, new_tag, permission_result_obj)
diff_info_list.append(wrap_diff_info(old_info, new_info, permission_result_obj))
elif compare_value.state_range == RangeChange.CHANGE.value:
diff_info_list.append(wrap_diff_info(old_info, new_info,
DiffInfo(DiffType.DOC_TAG_PERMISSION_RANGE_CHANGE, old_permission,
new_permission)))
permission_result_obj = DiffInfo(DiffType.DOC_TAG_PERMISSION_RANGE_CHANGE, old_permission, new_permission)
set_file_doc_content_snippet(old_tag, new_tag, permission_result_obj)
diff_info_list.append(wrap_diff_info(old_info, new_info, permission_result_obj))
return diff_info_list
@ -1075,22 +1093,23 @@ def process_tag_since(old_tag, new_tag, old_info, new_info):
def process_tag_syscap(old_tag, new_tag, old_info, new_info):
diff_info_list = []
if old_tag is None:
diff_info_list.append(wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_SYSCAP_NA_TO_HAVE,
'NA',
f'{new_tag["name"]} '
f'{new_tag["description"]}')))
syscap_result_obj = DiffInfo(DiffType.DOC_TAG_SYSCAP_NA_TO_HAVE, 'NA', f'{new_tag["name"]} '
f'{new_tag["description"]}')
set_file_doc_content_snippet(old_tag, new_tag, syscap_result_obj)
diff_info_list.append(wrap_diff_info(old_info, new_info, syscap_result_obj))
return diff_info_list
if new_tag is None:
diff_info_list.append(wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_SYSCAP_HAVE_TO_NA,
f'{old_tag["name"]} '
f'{old_tag["description"]}',
'NA')))
syscap_result_obj = DiffInfo(DiffType.DOC_TAG_SYSCAP_HAVE_TO_NA, f'{old_tag["name"]} '
f'{old_tag["description"]}', 'NA')
set_file_doc_content_snippet(old_tag, new_tag, syscap_result_obj)
diff_info_list.append(wrap_diff_info(old_info, new_info, syscap_result_obj))
return diff_info_list
old_syscap = f'{old_tag["name"]} {old_tag["description"]}'
new_syscap = f'{new_tag["name"]} {new_tag["description"]}'
if old_syscap != new_syscap:
diff_info_list.append(
wrap_diff_info(old_info, new_info, DiffInfo(DiffType.DOC_TAG_SYSCAP_A_TO_B, old_syscap, new_syscap)))
syscap_result_obj = DiffInfo(DiffType.DOC_TAG_SYSCAP_A_TO_B, old_syscap, new_syscap)
set_file_doc_content_snippet(old_tag, new_tag, syscap_result_obj)
diff_info_list.append(wrap_diff_info(old_info, new_info, syscap_result_obj))
return diff_info_list

View File

@ -49,7 +49,7 @@ class DiffProcessorPermission:
variable_list = [] # 命题集合
@staticmethod
def get_bool_in_list(self, number_list, bin_len):
def get_bool_in_list(number_list, bin_len):
state_list = [bin(i) for i in number_list]
state_list = [x[2:] for x in state_list]
state_list = ['0' * (bin_len - len(x)) + x for x in state_list]
@ -57,7 +57,7 @@ class DiffProcessorPermission:
return tuple(state_list)
@staticmethod
def process_value(self, state_value):
def process_value(state_value):
calculate = CalculateValue()
for state in state_value:
if state_value[state]:

View File

@ -295,7 +295,6 @@ def parser(directory_path): # 目录路径
def parser_include_ast(dire_file_path, include_path: list): # 对于单独的.h解析接口
correct_include_path = []
link_include_path = [dire_file_path]
copy_std_lib(link_include_path, dire_file_path)
copy_self_include(link_include_path, dire_file_path)
for item in include_path:
split_path = os.path.splitext(item)
@ -333,7 +332,7 @@ def get_dir_file_path(dir_path):
link_include_path.append(dir_path)
for file in filenames:
if 'build-tools' not in dir_path and 'sysroot_myself' not in dir_path and file.endswith('.h'):
file_path_list.append(os.path.join(dir_path, file))
file_path_list.append(os.path.normpath(os.path.join(dir_path, file)))
return file_path_list, link_include_path

View File

@ -0,0 +1,177 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import enum
from typedef.diff.diff import DiffType
class CheckCompatibilityErrorMessage(enum.Enum):
API_CHANGE_INCOMPATIBLE_01 = ('API check error of [api compatibility errors]:Deleting [$$] API is prohibited.'
'Please resolve it.')
API_CHANGE_INCOMPATIBLE_02 = ('API check error of [api compatibility errors]:Changing API name [$$] to API name '
'[&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_03 = ('API check error of [api compatibility errors]:Deleting [$$] file is prohibited.'
'Please resolve it.')
API_CHANGE_INCOMPATIBLE_04 = ('API check error of [api compatibility errors]:Changing [$$] file path is prohibited.'
'Please resolve it.')
API_CHANGE_INCOMPATIBLE_05 = ('API check error of [api compatibility errors]:Changing function name [$$] to '
'function name [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_06 = ('API check error of [api compatibility errors]:Changing function return type [$$] '
'to function return type [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_07 = ('API check error of [api compatibility errors]:Changing function param location [$$] '
'to function param location [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_08 = ('API check error of [api compatibility errors]:Adding new function param [&&] is '
'prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_09 = ('API check error of [api compatibility errors]:Deleting function param [$$] is '
'prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_10 = ('API check error of [api compatibility errors]:Changing function param type [$$] '
'to function param type [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_11 = ('API check error of [api compatibility errors]:Changing variable name [$$] to '
'variable name [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_12 = ('API check error of [api compatibility errors]:Changing const name [$$] to const '
'name [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_13 = ('API check error of [api compatibility errors]:Changing variable type [$$] to '
'variable type [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_14 = ('API check error of [api compatibility errors]:Changing const type [$$] to const '
'type [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_15 = ('API check error of [api compatibility errors]:Changing variable [$$] to const [&&] '
'is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_16 = ('API check error of [api compatibility errors]:Changing const [$$] to variable [&&] '
'is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_17 = ('API check error of [api compatibility errors]:Changing variable value [$$] to '
'variable value [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_18 = ('API check error of [api compatibility errors]:Changing const value [$$] to const '
'value [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_19 = ('API check error of [api compatibility errors]:Deleting variable [$$] is prohibited.'
'Please resolve it.')
API_CHANGE_INCOMPATIBLE_20 = ('API check error of [api compatibility errors]:Deleting const [$$] is prohibited.'
'Please resolve it.')
API_CHANGE_INCOMPATIBLE_21 = ('API check error of [api compatibility errors]:Changing macro name [$$] to macro '
'name [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_22 = ('API check error of [api compatibility errors]:Changing macro value [$$] to macro '
'value [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_23 = ('API check error of [api compatibility errors]:Deleting macro define [$$] is '
'prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_24 = ('API check error of [api compatibility errors]:Changing enum name [$$] to enum name '
'[&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_25 = ('API check error of [api compatibility errors]:Changing enum member name [$$] to '
'enum member name [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_26 = ('API check error of [api compatibility errors]:Changing enum member value [$$] to '
'enum member name [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_27 = ('API check error of [api compatibility errors]:Deleting enum [$$] is prohibited.'
'Please resolve it.')
API_CHANGE_INCOMPATIBLE_28 = ('API check error of [api compatibility errors]:Deleting enum member [$$] is '
'prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_29 = ('API check error of [api compatibility errors]:Changing struct name [$$] to struct '
'name [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_30 = ('API check error of [api compatibility errors]:Adding struct member [&&] is '
'prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_31 = ('API check error of [api compatibility errors]:Deleting struct member [$$] is '
'prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_32 = ('API check error of [api compatibility errors]:Changing struct member type [$$] to '
'struct member type [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_33 = ('API check error of [api compatibility errors]:Changing struct member name [$$] to '
'struct member name [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_34 = ('API check error of [api compatibility errors]:Deleting struct [$$] is prohibited.'
'Please resolve it.')
API_CHANGE_INCOMPATIBLE_35 = ('API check error of [api compatibility errors]:Changing struct since [$$] to '
'struct since [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_36 = ('API check error of [api compatibility errors]:Changing union name [$$] to '
'union name [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_37 = ('API check error of [api compatibility errors]:Adding union member [&&] is '
'prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_38 = ('API check error of [api compatibility errors]:Deleting union member [$$] is '
'prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_39 = ('API check error of [api compatibility errors]:Changing union member type [$$] to '
'union member type [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_40 = ('API check error of [api compatibility errors]:Changing union member name [$$] to '
'union member name [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_41 = ('API check error of [api compatibility errors]:Deleting union [$$] is prohibited.'
'Please resolve it.')
API_CHANGE_INCOMPATIBLE_42 = ('API check error of [api compatibility errors]:Changing union since [$$] to union '
'since [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_43 = ('API check error of [api compatibility errors]:Changing the @library in comments '
'from no to [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_44 = ('API check error of [api compatibility errors]:Changing the @library in comments '
'from [$$] to no is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_45 = ('API check error of [api compatibility errors]:Changing the @library in comments '
'from [$$] to [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_46 = ('API check error of [api compatibility errors]:Changing the @permission in comments '
'is prohibited.Add and relation permission.Please resolve it.')
API_CHANGE_INCOMPATIBLE_47 = ('API check error of [api compatibility errors]:Changing the @permission in comments '
'is prohibited.Reduce or relation permission.Please resolve it.')
API_CHANGE_INCOMPATIBLE_48 = ('API check error of [api compatibility errors]:Changing the @permission in comments '
'is prohibited.Permission value change.Please resolve it.')
API_CHANGE_INCOMPATIBLE_49 = ('API check error of [api compatibility errors]:Changing the @syscap in comments '
'from no to [&&] is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_50 = ('API check error of [api compatibility errors]:Changing the @syscap in comments '
'from [$$] to no is prohibited.Please resolve it.')
API_CHANGE_INCOMPATIBLE_51 = ('API check error of [api compatibility errors]:Changing the @syscap in comments '
'from [$$] to [&&] is prohibited.Please resolve it.')
@classmethod
def get_rule_message(cls, rule):
return cls[rule].value if rule in cls.__members__ else 'None'
check_compatibility_command_message = [
member.name for name_compatibility_tool,
member in CheckCompatibilityErrorMessage.__members__.items()
]
match_diff_and_check_scene_dict = {
DiffType.REDUCE_API.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_01.name,
DiffType.REDUCE_FILE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_03.name,
DiffType.FUNCTION_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_05.name,
DiffType.FUNCTION_RETURN_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_06.name,
DiffType.FUNCTION_PARAM_POS_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_07.name,
DiffType.FUNCTION_PARAM_ADD.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_08.name,
DiffType.FUNCTION_PARAM_REDUCE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_09.name,
DiffType.FUNCTION_PARAM_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_10.name,
DiffType.VARIABLE_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_11.name,
DiffType.CONSTANT_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_12.name,
DiffType.VARIABLE_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_13.name,
DiffType.CONSTANT_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_14.name,
DiffType.VARIABLE_CHANGE_TO_CONSTANT.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_15.name,
DiffType.CONSTANT_CHANGE_TO_VARIABLE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_16.name,
DiffType.VARIABLE_VALUE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_17.name,
DiffType.CONSTANT_VALUE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_18.name,
DiffType.DEFINE_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_21.name,
DiffType.DEFINE_TEXT_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_22.name,
DiffType.ENUM_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_24.name,
DiffType.ENUM_MEMBER_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_25.name,
DiffType.ENUM_MEMBER_VALUE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_26.name,
DiffType.ENUM_MEMBER_REDUCE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_28.name,
DiffType.STRUCT_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_29.name,
DiffType.STRUCT_MEMBER_ADD.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_30.name,
DiffType.STRUCT_MEMBER_REDUCE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_31.name,
DiffType.STRUCT_MEMBER_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_32.name,
DiffType.STRUCT_MEMBER_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_33.name,
DiffType.UNION_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_36.name,
DiffType.UNION_MEMBER_ADD.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_37.name,
DiffType.UNION_MEMBER_REDUCE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_38.name,
DiffType.UNION_MEMBER_TYPE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_39.name,
DiffType.UNION_MEMBER_NAME_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_40.name,
DiffType.DOC_TAG_LIBRARY_NA_TO_HAVE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_43.name,
DiffType.DOC_TAG_LIBRARY_HAVE_TO_NA.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_44.name,
DiffType.DOC_TAG_LIBRARY_A_TO_B.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_45.name,
DiffType.DOC_TAG_PERMISSION_RANGE_SMALLER: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_47.name,
DiffType.DOC_TAG_PERMISSION_RANGE_CHANGE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_48.name,
DiffType.DOC_TAG_SYSCAP_NA_TO_HAVE.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_49.name,
DiffType.DOC_TAG_SYSCAP_HAVE_TO_NA.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_50.name,
DiffType.DOC_TAG_SYSCAP_A_TO_B.name: CheckCompatibilityErrorMessage.API_CHANGE_INCOMPATIBLE_51.name,
}

View File

@ -391,6 +391,9 @@ class DiffInfo:
open_close_api: str = ''
is_third_party_api = False
current_api_type: str = ''
old_api_declara: str = ''
new_api_declara: str = ''
file_doc_line: int = 0
def __init__(self, diff_type: DiffType, old_differ_content, new_differ_content):
self.diff_type = diff_type
@ -563,6 +566,24 @@ class DiffInfo:
def get_current_api_type(self):
return self.current_api_type
def set_old_api_declara(self, old_api_declara):
self.old_api_declara = old_api_declara
def get_old_api_declara(self):
return self.old_api_declara
def set_new_api_declara(self, new_api_declara):
self.new_api_declara = new_api_declara
def get_new_api_declara(self):
return self.new_api_declara
def set_file_doc_line(self, file_doc_line):
self.file_doc_line = file_doc_line
def get_file_doc_line(self):
return self.file_doc_line
class OutputJson:
api_name: str = ''
@ -732,15 +753,6 @@ class ApiChangeData:
return self.current_api_type
class IgnoreFileDirectory:
ignore_file_dict = {
'arm-linux-ohos': '',
'aarch64-linux-ohos': '',
'x86_64-linux-ohos': '',
'i686-linux-ohos': '',
'tee': '',
'linux': ''
}
def get_ignore_file_dict(self):
return self.ignore_file_dict
class IgnoreFileDirectory(enum.Enum):
IGNORE_FILE_DIR_lx = r'/(arm-linux-ohos|aarch64-linux-ohos|x86_64-linux-ohos|i686-linux-ohos|linux|tee|)(/|$)'
IGNORE_FILE_DIR_wd = r'\\(arm-linux-ohos|aarch64-linux-ohos|x86_64-linux-ohos|i686-linux-ohos|linux|tee|)(\\|$)'