Code change influence surface determination method and device, equipment, storage medium and program product

By combining target test cases and function call links to analyze the impact scope of code changes, the problem of low accuracy in existing technologies is solved, a more efficient code change impact assessment is achieved, and software stability and development efficiency are ensured.

CN120743276APending Publication Date: 2025-10-03DAWNING INT INFORMATION IND CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510688129.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-26
Publication Date
2025-10-03

AI Technical Summary

Technical Problem

Existing code change impact analysis methods have low accuracy and are difficult to comprehensively assess the impact of code changes.

Method used

By testing the initial code text according to the target test case, the function call link corresponding to the code change is determined, and the coverage between the function call link and the link corresponding to the target test case is analyzed. The impact of the code change is judged based on the coverage ratio.

Benefits of technology

It improves the accuracy and efficiency of judging the impact of code changes, enables more fine-grained assessment of the impact of changes, reduces potential risks, and ensures software stability and development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120743276A_ABST
    Figure CN120743276A_ABST
Patent Text Reader

Abstract

The invention relates to a code change influence surface determination method and device, equipment, a storage medium and a program product, and the method comprises the steps: testing an initial code text according to a target test case to obtain a test code text, determining a first function call link corresponding to code change according to the test code text and the initial code text, and determining a code change influence surface according to the first function call link. And determining a code change influence result according to a coverage condition between the first function call link and a second function call link corresponding to the target test case. In the method, the target test case is designed for the initial code text and covers the use conditions of the code in various common scenes, so that the target test case is used for testing, each functional module and logic branch of the code can be comprehensively covered, and the accuracy and efficiency of code change influence surface judgment are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, device, storage medium, and program product for determining the impact of a code change. Background Art

[0002] With the rapid development of the software industry, the scale and complexity of software systems are increasing, and code changes have become an integral part of the software development cycle. However, code changes often come with potential risks, such as functional failures, performance degradation, or security vulnerabilities. To ensure software quality, testing teams must conduct comprehensive testing on every code change to verify its impact and address potential issues.

[0003] Currently, code change impact analysis methods mainly rely on manual assessment of the impact of code changes or analysis based on simple code dependencies. However, these code change impact analysis methods have the problem of low accuracy. Summary of the Invention

[0004] Based on this, it is necessary to provide a method, device, equipment, storage medium and program product for determining the impact of code changes that can improve accuracy in order to address the above technical issues.

[0005] In a first aspect, the present application provides a method for determining the impact of a code change, the method comprising:

[0006] Testing the initial code text according to the target test case to obtain the test code text;

[0007] Determine a first function call link corresponding to the code change based on the test code text and the initial code text;

[0008] The code change impact result is determined based on the coverage between the first function call link and the second function call link corresponding to the target test case.

[0009] The method for determining the impact of code changes provided in the embodiment of the present application is to test the initial code text according to the target test case to obtain the test code text, determine the first function call link corresponding to the code change according to the test code text and the initial code text, and determine the code change impact result according to the coverage between the first function call link and the second function call link corresponding to the target test case. In the above method, on the one hand, since the target test case is designed for the initial code text and covers the usage of the code in various common scenarios, the target test case is used for testing, which can comprehensively cover the various functional modules and logical branches of the code, thereby effectively improving the accuracy and efficiency of the judgment of the impact of the code change. On the other hand, when the code changes, its impact is not limited to the part that is directly changed, but will spread to other related codes along the function call link. By analyzing the coverage between the affected call link and the corresponding link of the target test case, the impact range of the code change can be comprehensively evaluated, thereby improving the accuracy of the test.

[0010] In some embodiments, determining the code change impact based on coverage between the first function call link and the second function call link corresponding to the target test case includes:

[0011] Determine a coverage ratio between the first function call link and the second function call link;

[0012] Determine the impact of code changes based on coverage ratio.

[0013] In some embodiments, determining the code change impact according to the coverage ratio includes:

[0014] If the coverage ratio is greater than the first ratio value, determining the code change impact result includes that the code change impact surface is a code function layer;

[0015] If the coverage ratio is not greater than the first ratio value, determining the code change impact result includes that the code change impact surface is the code business layer.

[0016] In some embodiments, the code business layer includes a first-level business aspect and a second-level business aspect, and determining the code change impact result includes that the code change impact aspect is the code business layer, including:

[0017] If the coverage ratio is within the first ratio range, determining that the code change impact result includes the code change impact surface being a first-level business surface;

[0018] If the coverage ratio is within the second ratio range, determining the code change impact result includes that the code change impact surface is a second-level business surface.

[0019] The method described in the embodiments of the present application, by analyzing the code impact surface in combination with function call links and different coverage ratios, can evaluate the impact of changes in a more fine-grained manner, thereby improving test accuracy; moreover, for changes in the code function layer, unit testing can be performed on the affected functions to ensure the correctness of their functions; for changes in business aspects at different levels, the affected business processes can be comprehensively tested, thereby reducing potential risks introduced by code changes and improving software stability.

[0020] In some embodiments, determining a first function call link corresponding to a code change based on the test code text and the initial code text includes:

[0021] Compare the test code text with the initial code text to determine the code change location in the initial code text;

[0022] The first function call link corresponding to the code change is determined according to the code change position and the third function call link corresponding to the initial code text.

[0023] The method described in the embodiments of this application can accurately locate the code changes in the initial code text by comparing the test code text with the initial code text, allowing developers to focus directly on the modified code and avoid meaningless troubleshooting in a large amount of unmodified code, thereby greatly shortening debugging time and improving development efficiency. Moreover, code changes often not only affect the currently modified function, but may also have a chain reaction on other functions that call the function and sub-functions called by the function. By determining the first function call link, the above method can comprehensively assess the impact range of the code change and improve test accuracy.

[0024] In some embodiments, the method further comprises:

[0025] Compiling the initial code text to obtain a compiled code text and a third function call link;

[0026] Compare the test code text with the original code text to determine the code change locations in the original code text, including:

[0027] Compare the test code text with the compiled code text to determine the code change location in the compiled code text.

[0028] The method described in the embodiment of the present application performs a plug-in process when compiling the initial code text, and can subsequently quickly and accurately determine the code change location based on the location marked by the plug-in, thereby quickly determining the impact of the code change.

[0029] In a second aspect, the present application further provides a device for determining the impact of a code change, the device comprising:

[0030] The test module is used to test the initial code text according to the target test case to obtain the test code text.

[0031] The first determining module is used to determine a first function call link corresponding to the code change according to the test code text and the initial code text.

[0032] The second determination module is used to determine the code change impact result according to the coverage between the first function call link and the second function call link corresponding to the target test case.

[0033] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0034] Testing the initial code text according to the target test case to obtain the test code text;

[0035] Determine a first function call link corresponding to the code change based on the test code text and the initial code text;

[0036] The code change impact result is determined based on the coverage between the first function call link and the second function call link corresponding to the target test case.

[0037] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0038] Testing the initial code text according to the target test case to obtain the test code text;

[0039] Determine a first function call link corresponding to the code change based on the test code text and the initial code text;

[0040] The code change impact result is determined based on the coverage between the first function call link and the second function call link corresponding to the target test case.

[0041] In a fifth aspect, the present application further provides a computer program product, the computer program product comprising a computer program, which, when executed by a processor, implements the following steps:

[0042] Testing the initial code text according to the target test case to obtain the test code text;

[0043] Determine a first function call link corresponding to the code change based on the test code text and the initial code text;

[0044] The code change impact result is determined based on the coverage between the first function call link and the second function call link corresponding to the target test case.

[0045] The above-mentioned method, device, equipment, storage medium and program product for determining the impact of code changes, the method tests the initial code text according to the target test case to obtain the test code text, determines the first function call link corresponding to the code change according to the test code text and the initial code text, and determines the code change impact result according to the coverage between the first function call link and the second function call link corresponding to the target test case. In the above method, on the one hand, since the target test case is designed for the initial code text and covers the use of the code in various common scenarios, the use of the target test case for testing can fully cover the various functional modules and logical branches of the code, thereby effectively improving the accuracy and efficiency of the judgment of the impact of the code change. On the other hand, when the code changes, its impact is not limited to the part that is directly changed, but will spread to other related codes along the function call link. By analyzing the coverage between the affected call link and the corresponding link of the target test case, the impact range of the code change can be comprehensively evaluated, thereby improving the accuracy of the test. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 is a diagram of the internal structure of a computer device in some embodiments;

[0047] Figure 2 This is a flowchart of a method for determining the impact of a code change in some embodiments;

[0048] Figure 3 This is a second flow chart of a method for determining the impact of a code change in some embodiments;

[0049] Figure 4 This is a third flowchart of a method for determining the impact of a code change in some embodiments;

[0050] Figure 5 This is a fourth flowchart of a method for determining the impact of a code change in some embodiments;

[0051] Figure 6 FIG5 is a flowchart of a method for determining the impact of a code change in some embodiments;

[0052] Figure 7 FIG6 is a flowchart of a method for determining the impact of a code change in some embodiments;

[0053] Figure 8 FIG7 is a flowchart of a method for determining the impact of a code change in some embodiments;

[0054] Figure 9 4 is a structural block diagram of a device for determining a code change impact surface in some embodiments. DETAILED DESCRIPTION

[0055] In the embodiments of this application, the term "and / or" describes the association relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.

[0056] In the embodiments of the present application, the term "plurality" refers to two or more than two, and other quantifiers are similar.

[0057] In the embodiments of the present application, the term "at least one" means one or more. For example, at least one of A, B and C can mean the following six situations: A exists alone, B exists alone, C exists alone, A and B exist at the same time, A and C exist at the same time, B and C exist at the same time, and A, B and C exist at the same time.

[0058] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0059] With the rapid development of the software industry, the scale and complexity of software systems are increasing, and code changes have become an integral part of the software development cycle. However, code changes often come with potential risks, such as functional failures, performance degradation, or security vulnerabilities. To ensure software quality, testing teams need to conduct comprehensive testing on each code change to verify its impact and remediate potential issues. Currently, methods for analyzing the impact of code changes rely primarily on manual assessment of the scope of the change or analysis based on simple code dependencies. However, these methods suffer from low accuracy.

[0060] In view of this, the embodiments of the present application propose a method, apparatus, device, storage medium and program product for determining the impact of code changes. By combining test cases and function call links, the impact scope of code changes can be comprehensively evaluated, thereby effectively improving the accuracy and efficiency of judging the impact of code changes.

[0061] It should be noted that the beneficial effects or technical problems solved by the embodiments of the present application are not limited to this one, but may also include other implicit or related problems. For details, please refer to the description of the following embodiments.

[0062] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0063] In some embodiments, the method for determining the code change impact surface provided in the embodiments of the present application can be applied to Figure 1 In the computer device shown, the computer device can be a terminal or a server, and its internal structure can be as shown in FIG. Figure 1 As shown, the computer device includes a processor, memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, memory, and input / output interface are connected via a system bus, while the communication interface, display unit, and input device are connected to the system bus via the input / output interface. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operating system and computer programs stored in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals via wired or wireless means, and the wireless means may be implemented via Wi-Fi, a mobile cellular network, NFC (near-field communication), or other technologies. When executed by the processor, the computer program implements a method for determining the impact of a code change. The display unit of the computer device is used to produce a visual display and may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse.

[0064] Those skilled in the art will understand that Figure 1 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0065] In some embodiments, as Figure 2 As shown, a method for determining the impact of code changes is provided, and this method is applied to Figure 1 The computer device in the example is used to illustrate the process, including the following steps:

[0066] S201, testing the initial code text according to the target test case to obtain the test code text.

[0067] The target test case is the test case in the test case library that corresponds to the initial code text. The test case includes a function call chain, that is, the order in which functions are executed when the code text is executed. The initial code text can be user-uploaded code text or code text with specific location changes to the user-uploaded code text. The test code text is the code text generated after the initial code text is executed according to the target test case; the test code text includes at least one of the following: the number of file calls, the number of function calls, and the number of line calls.

[0068] In an embodiment of the present application, a computer device can receive an initial code text uploaded by a user through a user interface set thereon; optionally, the computer device can obtain a storage path corresponding to the initial code text through the user interface, and then obtain the initial code text through the storage path; optionally, the computer can obtain the code text after the last test of the initial code text, and use it as the current initial code text; optionally, after receiving the initial code text uploaded by the user, the computer device can change the code segment at a specific location before each test. When there are multiple specific locations, the multiple specific locations can be changed at one time, or the multiple specific locations can be changed multiple times, and the changed code text can be used as the new initial code text; it should be noted that the specific location can be marked by the user in the initial code text, and the computer device can analyze the initial code text; optionally, the computer device can obtain the specific location input by the user through the user interface; optionally, the computer device uses the correspondence between the type of the initial code text and the specific location to determine the specific location corresponding to the type of the initial code text; optionally, the computer device can randomly change the code segment at the specific location.

[0069] After obtaining the initial code text, the computer device can analyze the initial code text to obtain one or more functions that the initial code text can achieve, and then search for a test case corresponding to the function in the preset test case library, and use the test case as the target test case; if the initial code text corresponds to multiple functions, then the test cases corresponding to the multiple functions can be found in the preset test case library, and multiple target test cases can be obtained. It should be noted that the preset test case library is used to characterize the correspondence between functions and test cases. After obtaining the initial code text and the target test case corresponding to the initial code text, the computer device can execute the initial code text according to the target test case. Specifically, if the initial code text corresponds to one function, then corresponding to one target test case, the computer device can execute the initial code text according to the function execution order in the target test case, test the initial code text, and obtain the test code text; if the initial code text corresponds to multiple functions, then corresponding to multiple target test cases, the computer device can first determine the order of each function according to the position of the code segment corresponding to each function in the initial code text, and then determine the order of the target test cases corresponding to each function according to the order of each function, and finally execute each target test case in the order of the target test case, test the initial code text, and obtain the test code text.

[0070] S202: Determine a first function call link corresponding to the code change based on the test code text and the initial code text.

[0071] The first function call link is a function call link affected when the code is changed.

[0072] In an embodiment of the present application, after the computer device obtains the test code text and the initial code text based on the above steps, it can determine the position of the code change based on the test code text and the initial code text, and then generate a first function call link based on the position sequence corresponding to the position of the code change. Specifically, if the position of the code change is one, then the first function call link can be generated by the position of this code change, that is, the first function call link is composed of the code function corresponding to the position of this code change; if the position of the code change is multiple, then the position sequence corresponding to the multiple code change positions can be determined first, for example, the order of the change can be used as the position sequence, or the position sequence can be randomly generated, and then the code functions corresponding to the multiple code change positions can be determined, and finally the first function call link can be generated according to the position sequence and the code function corresponding to each position; for example, the positions of the multiple code changes are positions 1, 3, and 4, the code function corresponding to position 1 is A, the code function corresponding to position 3 is C, and the code function corresponding to position 4 is D, then the first function call link is ACD. It should be noted that the code function corresponding to each position can be the function code in the test code text or the function code in the initial code text.

[0073] S203: Determine the code change impact result based on the coverage between the first function call link and the second function call link corresponding to the target test case.

[0074] The second function call link is the function call link in the target test case. The code change impact includes the code function layer and the code business layer. Furthermore, when the code change impact is at the code business layer, it may specifically include different levels of business aspects. The impact surface corresponding to the code business layer is greater than the impact surface corresponding to the code function layer.

[0075] In an embodiment of the present application, after obtaining the target test case, the computer device can generate a second function call link based on the code function in the target test case, and then when the computer device obtains the first function call link corresponding to the code change based on the above steps, it can determine the coverage of the second call link on the first call link, and then determine the impact of the code change based on the coverage of the second call link on the first call link. Specifically, the first function call link and the second call link can be input into a preset analysis model or a preset analysis algorithm, and the coverage of the second call link on the first call link can be analyzed by the preset analysis model or the preset analysis algorithm; optionally, an interception link related to the first call link can be intercepted from the second call link, and then the similarity between the interception link and the first call link is compared, and then the coverage is determined by the similarity between the interception link and the first call link. For example, the first function call link consists of EFGH, and the second function call link includes functions such as AEBCDEFGHIJK. Then, the E function can be used as the first code function, and the corresponding number of intercepted links in the second function call link can be intercepted as EBCD and EFGH. Then, the similarity between EFGH and EBCD and EFGH is calculated respectively, and the coverage is determined based on the similarity.

[0076] The method for determining the impact of code changes provided in the embodiment of the present application is to test the initial code text according to the target test case to obtain the test code text, determine the first function call link corresponding to the code change according to the test code text and the initial code text, and determine the code change impact result according to the coverage between the first function call link and the second function call link corresponding to the target test case. In the above method, on the one hand, since the target test case is designed for the initial code text and covers the usage of the code in various common scenarios, the target test case is used for testing, which can comprehensively cover the various functional modules and logical branches of the code, thereby effectively improving the accuracy and efficiency of the judgment of the impact of the code change. On the other hand, when the code changes, its impact is not limited to the part that is directly changed, but will spread to other related codes along the function call link. By analyzing the coverage between the affected call link and the corresponding link of the target test case, the impact range of the code change can be comprehensively evaluated, thereby improving the accuracy of the test.

[0077] In some embodiments, a specific implementation method for determining the impact of code changes based on coverage is also provided, such as Figure 3 As shown, the above-mentioned S203 of "determining the code change impact result according to the coverage between the first function call link and the second function call link corresponding to the target test case" includes:

[0078] S301: Determine a coverage ratio between a first function call link and a second function call link.

[0079] The coverage ratio represents the overlap ratio of each code function in the first function call link and the second function call link.

[0080] In an embodiment of the present application, after obtaining the first function call link and the second function call link, the computer device can first determine the first code function in the first function call link and the number of code functions after the first code function, and then determine whether the first code function exists in the second function call link. If the first code function exists in the second function call link, the target function call link will be intercepted with the first code function as the starting position and the code functions separated by the number of code functions. Finally, the similarity between the code function at each position in the target function call link and the code function at the corresponding position in the first function call link is calculated, and the similarity is used as the coverage ratio to obtain the coverage of the first function call link by the second function call link. If the first code function does not exist in the second function call link, the next code function of the first code function in the first function call link is used as the first code function, and the number of code functions after the next code function is used as the number of code functions after the first code function, and the step of determining whether the first code function exists in the second function call link is returned to execute, so as to obtain the coverage between the first function call link and the second function call link corresponding to the target test case, and then determine the code change impact result based on the coverage. For example, in the above example, after calculating the similarity between EFGH and EBCD and between EFGH, the maximum similarity can be used as the coverage ratio. For another example, if the first function call chain consists of BCDH and the second function call chain includes functions such as ACDEFGHIJK, then function B can be used as the first code function. However, the first code function B does not exist in the second function call chain, so C needs to be used as the new first code function. When it is determined that code function C exists in the second function call chain, three code functions are intercepted from the second function call chain, namely CDE. Finally, the similarity between CDH and CDE is calculated and used as the coverage ratio.

[0081] S302: Determine the impact of the code change according to the coverage ratio.

[0082] Among them, the impact of code changes includes the code function layer and the code business layer. There is a one-to-many relationship between the code business layer and the code function layer, that is, one code business layer includes multiple code function layers; for example, the code business layer is an application, then the code function layer can include at least one of the registration function, login function, update function, etc.

[0083] In an embodiment of the present application, after the computer device obtains the coverage ratio based on the above steps, it can determine the code change impact type corresponding to the current coverage ratio based on the correspondence between the coverage ratio and the code change impact type, and use the code change impact type as the code change impact result. Among them, the code change impact type includes the code function layer and the code business layer. It should be noted that the correspondence between the coverage ratio and the code change impact type can be pre-constructed and stored in a preset path. When the computer device needs to determine the code change impact surface, the correspondence between the coverage ratio and the code change impact type can be obtained from the preset path.

[0084] Optional, such as Figure 4 As shown, the above S302 “determining the code change impact result according to the coverage ratio” may include:

[0085] S401: If the coverage ratio is greater than a first ratio value, determining the code change impact result includes that the code change impact surface is a code function layer.

[0086] The first ratio value may be determined based on actual needs. For example, if the first ratio value is 99, the coverage ratio may be considered to be full coverage.

[0087] In an embodiment of the present application, after obtaining the coverage ratio between the first function call link and the second function call link, the computer device can compare the coverage ratio with the first ratio value to obtain a comparison result. If the comparison result indicates that the coverage ratio is greater than the first ratio value, it is determined that the code change impact result includes the code change impact surface being the code function layer.

[0088] S402: If the coverage ratio is not greater than the first ratio value, determining the code change impact result includes that the code change impact surface is the code business layer.

[0089] In the embodiment of the present application, if the computer device determines that the comparison result indicates that the coverage ratio is not greater than the first ratio value, then determining the code change impact result includes that the code change impact surface is the code business layer.

[0090] Optional, such as Figure 5 As shown, the code business layer includes a first-level business plane and a second-level business plane. On this basis, the above S402 "determining the impact of the code change according to the coverage ratio" may include:

[0091] S501: If the coverage ratio is within a first ratio range, determining that the code change impact result includes that the code change impact surface is a first-level business surface.

[0092] The code business layer includes a first-level business plane and a second-level business plane. The first ratio range can be determined according to actual needs, for example, the first ratio range can be 60%-first ratio value.

[0093] In an embodiment of the present application, when the computer device determines based on the above steps that the coverage ratio is not greater than the first ratio value, it can further determine the ratio range of the coverage ratio. If the computer device determines that the current coverage ratio is within the first ratio range, it determines that the code change impact result includes the code change impact surface being the first-level business surface.

[0094] S502: If the coverage ratio is within the second ratio range, determining that the code change impact result includes that the code change impact surface is a second-level service surface.

[0095] The second ratio range may be determined according to actual needs. For example, the second ratio range may be below 60%.

[0096] In an embodiment of the present application, if the computer device determines that the current coverage ratio is within the first ratio range, then it is determined that the code change impact result includes the code change impact surface being the first-level business surface. Optionally, a correspondence between the ratio range and the business surface of the corresponding level can be established in advance. For example, the correspondence includes the business surface of the ratio range 1-1 level, the business surface of the ratio range 2-2 level, ..., the business surface of the ratio range nn level, and the correspondence is stored as a preset mapping relationship under the target path. After the computer device obtains the coverage ratio between the first function call link and the second function call link based on the aforementioned steps, it can further determine that the coverage ratio is within the target ratio range, and then query the business surface of the level corresponding to the target ratio range from the preset mapping relationship, and use the business surface of this level as the business surface of the target level.

[0097] It should be noted that the code business layer in this embodiment is a two-level business plane, which is only an exemplary description. In actual applications, the code business layer can be divided more finely according to actual needs. For example, the code business layer can include multiple (greater than 2) levels of business planes. Correspondingly, for different levels of business planes, corresponding proportion ranges can be set. Optionally, the business planes of the same level can also be divided more finely. For example, the business plane can include multiple (greater than 2) levels of sub-business planes. Optionally, an application plane above the code business layer can also be set, and the application plane can include at least one business plane.

[0098] The method described in the embodiments of the present application, by analyzing the code impact surface in combination with function call links and different coverage ratios, can evaluate the impact of changes in a more fine-grained manner, thereby improving test accuracy; moreover, for changes in the code function layer, unit testing can be performed on the affected functions to ensure the correctness of their functions; for changes in business aspects at different levels, the affected business processes can be comprehensively tested, thereby reducing potential risks introduced by code changes and improving software stability.

[0099] In some embodiments, as Figure 6 As shown, a specific implementation method for determining the first function call link corresponding to the code change is also provided. The "determining the first function call link corresponding to the code change based on the test code text and the initial code text" in the above S202 includes:

[0100] S601: Compare the test code text with the initial code text to determine the code change position in the initial code text.

[0101] The code change position is the position where the test code text is different from the initial code text when compared.

[0102] In an embodiment of the present application, after the computer device obtains the test code text and the initial code text based on the above steps, it can compare the code segment in the test code text with the corresponding code segment in the initial code text to determine the different code segments in the corresponding positions in the test code text and the initial code text, and then determine the code change position in the initial code text based on the position of the different code segments. Optionally, the code segment in the test code text and the corresponding code segment in the initial code text can be compared line by line to determine the different code segments between the two, and then determine the code change position. Specifically, the test code text and the initial code text can be compared by writing or calling commands such as git diff, and the code change position in the initial code text can be obtained by combining line offset and line alignment technology. Optionally, the initial code text is tested using the target test case to obtain a first version of the test code text, and the first version of the test code text can be tested again using the target test case to obtain a second version of the test code text. The above steps can be repeated to obtain multiple versions of the test code text corresponding to a preset number of times, and then the changed positions in the multiple versions of the test code text are merged to obtain a merged test code text. Finally, the merged test code text is compared with the initial code text to determine the code change position in the initial code text.

[0103] S602: Determine a first function call link corresponding to the code change according to the code change position and the third function call link corresponding to the initial code text.

[0104] The third function call link is a function call link in the initial code text.

[0105] In an embodiment of the present application, after the computer device obtains the code change position in the initial code text based on the above steps, it can intercept a section of the function call link near the code change position in the third function call link as the first function call link corresponding to the code change. Optionally, the call depth can be obtained, and then the first function call link corresponding to the code change can be determined based on the call depth, the code change position, and the third function call link corresponding to the initial code text; specifically, after the computer device obtains the code change position in the initial code text, it can intercept a section of the function call link with the call depth before and after the code change position in the third function call link as the first function call link corresponding to the code change; for example, if the third function call link is ABCDEFGH, the code change position is C, and the call depth is 2, then it can be determined that the first function call link is ABCDE.

[0106] The method described in the embodiments of this application can accurately locate the code changes in the initial code text by comparing the test code text with the initial code text, allowing developers to focus directly on the modified code and avoid meaningless troubleshooting in a large amount of unmodified code, thereby greatly shortening debugging time and improving development efficiency. Moreover, code changes often not only affect the currently modified function, but may also have a chain reaction on other functions that call the function and sub-functions called by the function. By determining the first function call link, the above method can comprehensively assess the impact range of the code change and improve test accuracy.

[0107] In some embodiments, as Figure 7 As shown, before S601 or S201, the method for determining the impact area of ​​the code change further includes:

[0108] S701, compile the initial code text to obtain the compiled code text and the third function call link.

[0109] The compiled code text includes basic block information of each function in the initial code text, and the basic block information includes at least one of the starting and ending positions of each basic block, an instruction sequence in the basic block, and the like.

[0110] In an embodiment of the present application, after obtaining the initial code text, the computer device may use a preset algorithm or a preset model to compile the initial code text to obtain the compiled code text and the third function call link. Specifically, the computer device may call a tool such as LLVM or GCC to compile the initial code text, and specifically perform abstract syntax analysis on the initial code text to obtain the third function call link. During the compilation process, each basic block may be instrumented according to the instrumentation logic to obtain the instrumented code text, i.e., the compiled code text.

[0111] Correspondingly, when the computer device executes S601 "comparing the test code text with the initial code text to determine the code change position in the initial code text", it specifically executes S702 to compare the test code text with the compiled code text to determine the code change position in the compiled code text.

[0112] In an embodiment of the present application, after the computer device obtains the compiled code text based on the above steps, it can compare the code segment in the test code text with the corresponding code segment in the compiled code text, determine the code segment in the test code text and the corresponding position in the compiled code text that is different, and then determine the code change position in the compiled code text based on the position of the different code segment. Optionally, the code segment in the test code text and the corresponding code segment in the compiled code text can be compared to determine the different code segments between the two, and then determine the code change position, and then determine the first function call link corresponding to the code change based on the code change position and the third function call link corresponding to the compiled code text. Specifically, the computer device can compare the test code text with the compiled code text, and after determining the code change position in the initial code text, it can determine the function basic block to which the code change position belongs, that is, determine the affected basic block, and then analyze the affected basic block to determine the code change position in the compiled code text. Optionally, when executing S201 "testing the initial code text according to the target test case to obtain the test code text," the computer device specifically performs: testing the compiled code text according to the target test case to obtain the test code text. Specifically, the computer device may test the compiled code text according to the target test case to obtain the test code text.

[0113] The method described in the embodiment of the present application performs a plug-in process when compiling the initial code text, and can subsequently quickly and accurately determine the code change location based on the location marked by the plug-in, thereby quickly determining the impact of the code change.

[0114] In summary of all the above embodiments, a method for determining the impact of code changes is also provided, such as Figure 8 As shown, the method includes:

[0115] S801, compile the initial code text to obtain the compiled code text and the third function call link.

[0116] S802: Testing the compiled code text according to the target test case to obtain a test code text.

[0117] S803: Compare the test code text with the compiled code text to determine the code change position in the compiled code text.

[0118] S804: Determine a first function call link corresponding to the code change according to the code change position and the third function call link.

[0119] S805: Determine the coverage ratio between the first function call link and the second function call link.

[0120] S806: If the coverage ratio is greater than the first ratio value, determining the code change impact result includes that the code change impact surface is a code function layer.

[0121] S807: If the coverage ratio is not greater than the first ratio value, determine the code change impact result according to the ratio range of the coverage ratio.

[0122] S808: If the coverage ratio is within the first ratio range, determining the code change impact result includes that the code change impact surface is a first-level business surface.

[0123] S809: If the coverage ratio is within the second ratio range, determining that the code change impact result includes that the code change impact surface is a second-level service surface.

[0124] In the method described in the embodiment of the present application, since the target test case is designed for the initial code text and covers the usage of the code in various common scenarios, the target test case is used for testing, which can fully cover the various functional modules and logical branches of the code, thereby effectively improving the accuracy and efficiency of the judgment of the impact of code changes. Moreover, when the code changes, its impact is not limited to the part that is directly changed, but will spread to other related codes along the function call link. By analyzing the coverage between the affected call link and the corresponding link of the target test case, the impact range of the code change can be fully evaluated, thereby improving the accuracy of the test. In addition, after obtaining a specific instrumentation package, it is integrated with the existing test case library. By executing the test process, not only the precise execution of the test case is achieved, but also a high-precision mapping mechanism between the code text and the test case is established. This mapping relationship is systematically stored, providing a solid foundation for subsequent code change impact analysis, significantly improving test efficiency and accuracy. At the same time, the establishment of this mapping mechanism also greatly facilitates the maintenance and updating of test cases, ensuring the continuity and effectiveness of test coverage. In addition, data from different devices, systems, accounts, and environments can all be used as system input. The above method can distinguish between changed codes, non-changed codes, and change-impact path codes, etc., and evaluate the impact of changes in a more fine-grained manner with higher accuracy.

[0125] The methods described in the above steps are all described in the above embodiments. Please refer to the above description for details and will not be repeated here.

[0126] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.

[0127] Based on the same inventive concept, embodiments of the present application also provide a device for determining the impact of a code change, for implementing the aforementioned method for determining the impact of a code change. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations of one or more embodiments of the device for determining the impact of a code change provided below can be found in the aforementioned method for determining the impact of a code change, and will not be further elaborated here.

[0128] In some embodiments, as Figure 9 As shown, a device for determining the impact area of ​​a code change is provided, comprising:

[0129] The test module is used to test the initial code text according to the target test case to obtain the test code text.

[0130] A first determining module is configured to determine a first function call link corresponding to the code change based on the test code text and the initial code text.

[0131] The second determining module is used to determine the code change impact result according to the coverage between the first function call link and the second function call link corresponding to the target test case.

[0132] In some embodiments, the second determining module includes:

[0133] The first determining unit is configured to determine a coverage ratio between the first function call link and the second function call link.

[0134] The second determining unit is configured to determine the code change impact result according to the coverage ratio.

[0135] In some embodiments, the second determining unit includes:

[0136] The first determining subunit is configured to determine, if the coverage ratio is greater than a first ratio value, that the code change impact result includes that the code change impact surface is a code function layer.

[0137] The second determining subunit is configured to determine, if the coverage ratio is not greater than the first ratio value, that the code change impact result includes that the code change impact surface is a code service layer.

[0138] In some embodiments, the above-mentioned second determination subunit is specifically used to determine that the code change impact result includes the code change impact surface being the first-level business surface if the coverage ratio is within the first ratio range; if the coverage ratio is within the second ratio range, determine that the code change impact result includes the code change impact surface being the second-level business surface.

[0139] In some embodiments, the first determining module includes:

[0140] The comparison unit is used to compare the test code text with the initial code text to determine the code change position in the initial code text.

[0141] The third determining unit is configured to determine a first function call link corresponding to the code change according to the code change position and a third function call link corresponding to the initial code text.

[0142] In some embodiments, the first determining module further includes:

[0143] The compiling unit is used to compile the initial code text to obtain the compiled code text and the third function call link.

[0144] Correspondingly, the comparison unit is specifically used to compare the test code text and the compiled code text to determine the code change position in the compiled code text.

[0145] Each module in the aforementioned apparatus for determining the impact of a code change can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.

[0146] In some embodiments, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0147] Testing the initial code text according to the target test case to obtain the test code text;

[0148] Determining a first function call link corresponding to the code change according to the test code text and the initial code text;

[0149] The code change impact result is determined based on the coverage between the first function call link and the second function call link corresponding to the target test case.

[0150] In some embodiments, when the processor executes the computer program, it further implements the following steps:

[0151] Determining a coverage ratio between the first function call link and the second function call link;

[0152] The code change impact result is determined according to the coverage ratio.

[0153] In some embodiments, when the processor executes the computer program, it further implements the following steps:

[0154] If the coverage ratio is greater than a first ratio value, determining that the code change impact result includes that the code change impact surface is a code function layer;

[0155] If the coverage ratio is not greater than the first ratio value, determining that the code change impact result includes that the code change impact surface is the code business layer.

[0156] In some embodiments, when the processor executes the computer program, it further implements the following steps:

[0157] If the coverage ratio is within a first ratio range, determining that the code change impact result includes that the code change impact surface is a service surface of the first level;

[0158] If the coverage ratio is within a second ratio range, determining that the code change impact result includes that the code change impact surface is a service surface of the second level.

[0159] In some embodiments, when the processor executes the computer program, it further implements the following steps:

[0160] Comparing the test code text with the initial code text to determine a code change position in the initial code text;

[0161] A first function call link corresponding to the code change is determined according to the code change position and the third function call link corresponding to the initial code text.

[0162] In some embodiments, when the processor executes the computer program, it further implements the following steps:

[0163] Compiling the initial code text to obtain a compiled code text and the third function call link;

[0164] The comparing the test code text with the initial code text to determine the code change position in the initial code text includes:

[0165] The test code text and the compiled code text are compared to determine the code change position in the compiled code text.

[0166] The computer device provided in the above embodiment has an implementation principle and technical effects similar to those of the above method embodiment, and will not be described in detail here.

[0167] In some embodiments, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0168] Testing the initial code text according to the target test case to obtain the test code text;

[0169] Determining a first function call link corresponding to the code change according to the test code text and the initial code text;

[0170] The code change impact result is determined based on the coverage between the first function call link and the second function call link corresponding to the target test case.

[0171] In some embodiments, when the computer program is executed by a processor, the following steps are further implemented:

[0172] Determining a coverage ratio between the first function call link and the second function call link;

[0173] The code change impact result is determined according to the coverage ratio.

[0174] In some embodiments, when the computer program is executed by a processor, the following steps are further implemented:

[0175] If the coverage ratio is greater than a first ratio value, determining that the code change impact result includes that the code change impact surface is a code function layer;

[0176] If the coverage ratio is not greater than the first ratio value, determining that the code change impact result includes that the code change impact surface is the code business layer.

[0177] In some embodiments, when the computer program is executed by a processor, the following steps are further implemented:

[0178] If the coverage ratio is within a first ratio range, determining that the code change impact result includes that the code change impact surface is a service surface of the first level;

[0179] If the coverage ratio is within a second ratio range, determining that the code change impact result includes that the code change impact surface is a service surface of the second level.

[0180] In some embodiments, when the computer program is executed by a processor, the following steps are further implemented:

[0181] Comparing the test code text with the initial code text to determine a code change position in the initial code text;

[0182] A first function call link corresponding to the code change is determined according to the code change position and the third function call link corresponding to the initial code text.

[0183] In some embodiments, when the computer program is executed by a processor, the following steps are further implemented:

[0184] Compiling the initial code text to obtain a compiled code text and the third function call link;

[0185] The comparing the test code text with the initial code text to determine the code change position in the initial code text includes:

[0186] The test code text and the compiled code text are compared to determine the code change position in the compiled code text.

[0187] The above embodiment provides a computer-readable storage medium, whose implementation principle and technical effects are similar to those of the above method embodiment, and will not be repeated here.

[0188] In some embodiments, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:

[0189] Testing the initial code text according to the target test case to obtain the test code text;

[0190] Determining a first function call link corresponding to the code change according to the test code text and the initial code text;

[0191] The code change impact result is determined based on the coverage between the first function call link and the second function call link corresponding to the target test case.

[0192] In some embodiments, when the computer program is executed by a processor, the following steps are further implemented:

[0193] Determining a coverage ratio between the first function call link and the second function call link;

[0194] The code change impact result is determined according to the coverage ratio.

[0195] In some embodiments, when the computer program is executed by a processor, the following steps are further implemented:

[0196] If the coverage ratio is greater than a first ratio value, determining that the code change impact result includes that the code change impact surface is a code function layer;

[0197] If the coverage ratio is not greater than the first ratio value, determining that the code change impact result includes that the code change impact surface is the code business layer.

[0198] In some embodiments, when the computer program is executed by a processor, the following steps are further implemented:

[0199] If the coverage ratio is within a first ratio range, determining that the code change impact result includes that the code change impact surface is a service surface of the first level;

[0200] If the coverage ratio is within a second ratio range, determining that the code change impact result includes that the code change impact surface is a service surface of the second level.

[0201] In some embodiments, when the computer program is executed by a processor, the following steps are further implemented:

[0202] Comparing the test code text with the initial code text to determine a code change position in the initial code text;

[0203] A first function call link corresponding to the code change is determined according to the code change position and the third function call link corresponding to the initial code text.

[0204] In some embodiments, when the computer program is executed by a processor, the following steps are further implemented:

[0205] Compiling the initial code text to obtain a compiled code text and the third function call link;

[0206] The comparing the test code text with the initial code text to determine the code change position in the initial code text includes:

[0207] The test code text and the compiled code text are compared to determine the code change position in the compiled code text.

[0208] The above embodiment provides a computer program product, whose implementation principle and technical effects are similar to those of the above method embodiment, and will not be repeated here.

[0209] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments. In particular, any reference to memory, database, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), data processing logic devices based on quantum computing, and the like.

[0210] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0211] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.

Claims

1. A method for determining the impact of a code change, characterized in that: The method comprises: Testing the initial code text according to the target test case to obtain the test code text; Determining a first function call link corresponding to the code change according to the test code text and the initial code text; The code change impact result is determined based on the coverage between the first function call link and the second function call link corresponding to the target test case.

2. The method according to claim 1, characterized in that The determining the code change impact result according to the coverage between the first function call link and the second function call link corresponding to the target test case includes: Determining a coverage ratio between the first function call link and the second function call link; The code change impact result is determined according to the coverage ratio.

3. The method according to claim 2, characterized in that The determining the code change impact result according to the coverage ratio includes: If the coverage ratio is greater than a first ratio value, determining that the code change impact result includes that the code change impact surface is a code function layer; If the coverage ratio is not greater than the first ratio value, determining that the code change impact result includes that the code change impact surface is the code business layer.

4. The method according to claim 3, characterized in that The code business layer includes a first-level business plane and a second-level business plane, and determining that the code change impact result includes that the code change impact plane is the code business layer includes: If the coverage ratio is within a first ratio range, determining that the code change impact result includes that the code change impact surface is a service surface of the first level; If the coverage ratio is within a second ratio range, determining that the code change impact result includes that the code change impact surface is a service surface of the second level.

5. The method according to any one of claims 1 to 4, characterized in that The determining, based on the test code text and the initial code text, a first function call link corresponding to the code change includes: Comparing the test code text with the initial code text to determine a code change position in the initial code text; A first function call link corresponding to the code change is determined according to the code change position and the third function call link corresponding to the initial code text.

6. The method according to claim 5, characterized in that The method further comprises: Compiling the initial code text to obtain a compiled code text and the third function call link; The comparing the test code text with the initial code text to determine the code change position in the initial code text includes: The test code text and the compiled code text are compared to determine the code change position in the compiled code text.

7. A device for determining the impact of a code change, characterized in that: The device comprises: A test module is used to test the initial code text according to the target test case to obtain the test code text; A first determining module is configured to determine a first function call link corresponding to the code change based on the test code text and the initial code text; The second determining module is used to determine the code change impact result according to the coverage between the first function call link and the second function call link corresponding to the target test case.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.