Programming language coverage rate determination method and device, equipment and storage medium

By inserting coverage collection code that matches the runtime environment of each version into the application's source code, the impact of code differences between different PHP versions is resolved, achieving comprehensiveness and accuracy of coverage and ensuring the reliability of test analysis results.

CN120909918APending Publication Date: 2025-11-07广州三七极耀网络科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510831676.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-20
Publication Date
2025-11-07

AI Technical Summary

Technical Problem

Existing technologies cannot effectively address the impact of code differences between different PHP versions on coverage collection, resulting in the inability to fully integrate coverage data from various version environments and provide comprehensive and reliable test analysis results.

Method used

By inserting coverage collection code that matches the runtime environment of each version into the application's source code, responding to requests to determine the execution code and writing it to the container's temporary directory, merging the execution code to determine the coverage results, and taking into account the differences in code execution between different versions.

Benefits of technology

It improves the comprehensiveness and accuracy of coverage collection, ensuring comprehensive and reliable test analysis results in multi-version environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120909918A_ABST
    Figure CN120909918A_ABST
Patent Text Reader

Abstract

The invention discloses a programming language coverage rate determination method and device, equipment and a storage medium, and relates to the technical field of computers. The method comprises the steps that when an application program is constructed, based on different version operation environments of the application program, coverage rate collection codes matched with all version operation environments of the application program are inserted into source codes of the application program through instrumentation operation; the coverage rate collection code is used for collecting execution codes; in response to a request for accessing the application program, collecting codes according to a version operation environment corresponding to the request and the corresponding coverage rate, determining an execution code covered by the request, and writing the execution code into a file of a preset container temporary directory; under the condition that the request is executed, executing codes in a preset container temporary directory are merged; and based on the merged execution code, determining a coverage rate result of the application program before instrumentation. According to the invention, the comprehensiveness and accuracy of the collection coverage rate are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a programming language coverage determination method and device, equipment and storage medium. BACKGROUND

[0002] With the development of software technology, code coverage as an important indicator to measure the effectiveness of software testing is increasingly valued by the development team. It provides an objective evaluation basis for test effectiveness by quantitatively analyzing the proportion relationship between the executed part and the total code amount of the tested code. PHP, as a programming language widely used in the Web field, often has multiple versions coexisting in actual project development due to historical legacy systems, diverse business requirements, and technical evolution and other factors, in order to adapt to the compatibility requirements of different clients. However, the change of syntax rules between different PHP versions (such as type declaration strengthening, function deprecation, etc.) leads to different execution positions of the same code base in different running environments, which makes the traditional coverage collection technology face challenges.

[0003] However, the existing technical solutions for code coverage collection are mostly designed for single version running environment. When the application needs to be tested in multiple different version running environments, the influence of code differences between different versions on coverage collection cannot be effectively solved, and it is difficult to comprehensively integrate coverage data under each version environment, resulting in the inability to provide comprehensive and reliable test analysis results. SUMMARY

[0004] The present application provides a programming language coverage determination method, device, equipment and storage medium, which solves the problem that the existing coverage collection method cannot effectively solve the influence of code differences between different versions on coverage collection, and it is difficult to comprehensively integrate coverage data under each version environment, resulting in the inability to provide comprehensive and reliable test analysis results, and improves the comprehensiveness and accuracy of collecting coverage.

[0005] In order to achieve the above purpose, the present application adopts the following technical solutions: In a first aspect, the present application provides a programming language coverage determination method, comprising: When building an application, based on different version running environments of the application, insert coverage collection code matching each version running environment of the application in the source code of the application through a patching operation; wherein the coverage collection code is used to collect execution code; In response to a request to access the application, according to the version running environment corresponding to the request and the corresponding coverage collection code, determine the execution code covered by the request, and write the execution code covered by the request into a file in a pre-set container temporary directory; In a case where the request is executed, the execution code in the preset container temporary directory is merged to obtain merged execution code; Based on the merged execution code, a coverage result before the application program is instrumented is determined.

[0006] Optionally, before the instrumenting operation, the method further comprises: Determine the position of the instrumenting operation for inserting the coverage collection code into the optimal position in the source code; Correspondingly, the method of determining the position of the instrumenting operation comprises: Analyze the structural information of the source code in the application program to identify the key positions where the coverage collection code can be inserted; wherein the key positions include function entry, loop structure start, and conditional judgment branch; According to a preset rule, the key positions are matched and screened; The key positions after matching and screening are sorted according to a preset priority, and based on the sorting, the optimal insertion position is determined.

[0007] Optionally, the method of determining the execution code covered by the request based on the version running environment corresponding to the request and the coverage collection code corresponding to the request comprises: Analyze the request for accessing the application program to determine the version running environment identifier corresponding to the request and the type identifier of the request; According to the version running environment identifier, locate the coverage collection code set in the application program that matches the version running environment identifier; According to the request type identifier, filter out the coverage collection code subset related to the request type identifier from the coverage collection code set; Monitor the execution of the code corresponding to the coverage collection code subset, and in a case where the code is executed, determine that the code is execution code.

[0008] Optionally, the method of writing the execution code covered by the request into a file in a preset container temporary directory comprises: According to the version running environment identifier, construct a target file name in the container temporary directory; Write the execution code covered by the request into the file with the target file name to obtain the coverage data file corresponding to each version running environment.

[0009] Optionally, the method of merging the execution code in the preset container temporary directory to obtain merged execution code comprises: traverse the coverage data files corresponding to the version run-time environments in the container temporary directory, extract the version run-time environment identifier and the execution code in each of the coverage data files; perform a union set processing on the execution code in the coverage data files corresponding to the version run-time environments, to obtain the merged execution code.

[0010] Optionally, the performing a union set processing on the execution code in the coverage data files corresponding to the version run-time environments, to obtain the merged execution code, comprises: determining the code difference of the pre-instrumentation source code under different version run-time environments; constructing a version difference mapping table according to the code difference; converting the execution code corresponding to the version run-time environments into a unified version code format according to the version difference mapping table, to obtain converted version execution code; performing a union set processing on the converted version execution code, to obtain the merged execution code.

[0011] Optionally, the determining the coverage result of the application before being instrumented based on the merged execution code, comprises: obtaining the total code amount of the pre-instrumentation source code of the application; calculating the execution code amount in the merged execution code as the covered code amount; calculating the ratio of the covered code amount and the total code amount, to obtain the coverage result of the application before being instrumented.

[0012] In a second aspect, the present application provides a programming language coverage determination apparatus, comprising: an instrumentation module, configured to insert, when the application is constructed, the coverage collection code matched with the version run-time environments of the application in the source code of the application through an instrumentation operation based on the different version run-time environments of the application; wherein the coverage collection code is used to collect the execution code; a writing module, configured to, in response to a request to access the application, determine the execution code covered by the request according to the version run-time environment corresponding to the request and the coverage collection code corresponding to the request, and write the execution code covered by the request into a file in a preset container temporary directory; a merging module, configured to, in the case that the request is executed, merge the execution code in the preset container temporary directory, to obtain the merged execution code; a determination module, configured to determine the coverage result of the application before being instrumented based on the merged execution code.

[0013] In a third aspect, the present application provides a programming language coverage determination device, comprising: one or more processors; a memory storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the programming language coverage determination method according to the first aspect.

[0014] In a fourth aspect, the present application provides a storage medium containing computer executable instructions for executing the programming language coverage determination method according to the first aspect when executed by a computer processor.

[0015] In summary, compared with the prior art, the technical scheme provided by the present application has at least the following effective effects: In the present application, when the application program is constructed, the coverage collection code matched with the running environment of each version of the application program is inserted into the source code of the application program through the patching operation based on the different running environments of the application program of each version; wherein the coverage collection code is used to collect the execution code; in response to the request for accessing the application program, the execution code covered by the request is determined according to the version running environment corresponding to the request and the corresponding coverage collection code, and the execution code covered by the request is written into the file in the preset container temporary directory; in the case where the request is executed, the execution code in the preset container temporary directory is merged to obtain the merged execution code; based on the merged execution code, the coverage result of the application program before patching is determined. In the above technical means, the patching operation is implemented according to the different running environments of the application program, and the coverage collection code matched with each version of the running environment is inserted into the source code, which avoids the situation that part of the code cannot be effectively collected due to the difference between the versions; and after the request is executed, the execution code data generated under each version of the running environment is integrated, and the coverage result of the application program before patching is determined based on the merged execution code, which fully considers the difference in code execution under different versions of the running environment, thereby improving the comprehensiveness and accuracy of the collected coverage. BRIEF DESCRIPTION OF DRAWINGS

[0016] Figure 1 is a flowchart of a programming language coverage determination method provided by an embodiment of the present application; Figure 2 is a flowchart of determining the position of the patching operation provided by an embodiment of the present application; Figure 3 is a flowchart of determining the execution code covered by the request provided by an embodiment of the present application; Figure 4 is a flowchart of writing the execution code covered by the request into the file in the preset container temporary directory provided by an embodiment of the present application; Figure 5 is a flowchart provided by an embodiment of the present application for merging execution codes; Figure 6 is a flowchart provided by an embodiment of the present application for union processing of execution codes corresponding to respective versions of a running environment; Figure 7 is a flowchart provided by an embodiment of the present application for determining coverage results before an application program is instrumented; Figure 8 is a structural schematic diagram of a programming language coverage determination device provided by an embodiment of the present application; Figure 9 is a structural schematic diagram of a programming language coverage determination device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0017] In order to make the objects, technical solutions and advantages of the present application clearer, the following further describes specific embodiments of the present application with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only used to explain the present application and not to limit the present application. In addition, it should be noted that, for the convenience of description, only parts related to the present application are shown in the drawings and not all contents. Before discussing the example embodiments in more detail, it should be mentioned that some example embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the operations (or steps) as sequential processes, many of the operations can be implemented in parallel, concurrently or simultaneously. In addition, the order of the operations can be rearranged. The process can be terminated when the operations are completed, but can also have additional steps not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.

[0018] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that the data used in this way can be exchanged under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than that illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of a kind and do not limit the number of objects, for example, the first object can be one or more. In addition, "and / or" in the specification and claims indicates at least one of the connected objects, and the character " / ", generally indicates that the objects before and after are in an "or" relationship.

[0019] The technical solutions of the existing code coverage collection are mostly designed for a single version running environment. When the application program needs to be tested in multiple different versions of the running environment, the influence of the code difference between different versions on the coverage collection cannot be effectively solved, the coverage data under each version environment cannot be comprehensively integrated, and therefore, a comprehensive and reliable test analysis result cannot be provided.

[0020] To solve the problem that the influence of the code difference between different versions on the coverage collection cannot be effectively solved, the coverage data under each version environment cannot be comprehensively integrated, and therefore, a comprehensive and reliable test analysis result cannot be provided in the existing coverage collection mode, the embodiment provides a programming language coverage determination method. The method performs a patching operation according to different versions of the running environment of the application program, inserts the coverage collection code that is adapted to each version of the running environment into the source code, and avoids the situation that part of the code cannot be effectively collected due to the version difference. After the execution is requested to be completed, the execution code data generated under each version of the running environment is integrated, the coverage result of the application program before being patched is determined based on the merged execution code, the code execution difference under different versions of the running environment is fully considered, and therefore, the comprehensiveness and accuracy of the collected coverage are improved.

[0021] The programming language coverage determination method provided in the embodiment can be executed by a programming language coverage determination device. The programming language coverage determination device can be implemented in the form of software and / or hardware. The programming language coverage determination device can be composed of two or more physical entities or one physical entity.

[0022] The programming language coverage determination device is installed with at least one type of operating system. The operating system includes but is not limited to an Android system, a Linux system, and a Windows system. The programming language coverage determination device can install at least one application program based on the operating system. The application program can be an application program provided by the operating system or an application program downloaded from a third-party device or a server. In the embodiment, the programming language coverage determination device has at least one application program that can execute the programming language coverage determination method.

[0023] The technical solutions provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0024] Figure 1 A flowchart of a programming language coverage determination method provided by an embodiment of the present application is given. Please refer to Figure 1 The programming language coverage determination method specifically includes: S110, in constructing the application program, based on different version running environments of the application program, inserting coverage collection code matched with the version running environments of the application program into the source code of the application program through a patching operation; wherein the coverage collection code is used to collect execution code.

[0025] Wherein, the application program refers to a software collection composed of computer code and capable of realizing specific functions, and its essence is a sequence of instructions written according to the syntax rules of a programming language, which can be executed in a specific running environment to complete data processing, user interaction and other tasks. Patching can be understood as inserting specific monitoring code into the source code of the target program, and capturing execution code information through these monitoring codes during program execution.

[0026] Since the application program has different versions, and the running environments of different versions are different, the program code will also be different, therefore, in order to accurately collect the execution code covered by each version in its respective running environment, the patching operation needs to be based on the different version running environments of the application program in the embodiments of the present application.

[0027] Optionally, in the embodiments of the present application, before the patching operation, the position of the patching operation is also determined, which is used to insert the coverage collection code into the optimal position in the source code. Figure 2 The flow chart for determining the position of the patching operation provided by the embodiments of the present application is shown in Figure 2 The step of determining the position of the patching operation specifically includes S1101-S1103: S1101, analyzing the structure information of the source code in the application program, and identifying the key positions where the coverage collection code can be inserted; wherein the key positions include function entry, loop structure starting point, and conditional judgment branch.

[0028] Further, the entire application program source code is systematically scanned and analyzed to deeply understand its syntax structure, semantic logic and the association relationship between the codes, so as to identify the function entry, loop structure starting point and conditional judgment branch.

[0029] S1102, matching and screening the key positions according to the preset rules.

[0030] For example, based on the influence of the inserted coverage collection code on the performance of the application, the preset rule in the embodiments of the present application is used to match and screen the key positions. Specifically, for each key position, the additional running time overhead and resource occupation (such as CPU, memory, etc.) caused by the insertion of the code into each key position are estimated, and the additional running time overhead and resource occupation caused by the insertion of the estimated code into each key position are compared with the preset threshold. If the additional running time overhead and resource occupation caused by the insertion of the estimated code into each key position are greater than the preset threshold, the key position is excluded. For example, in an application with relatively high real-time requirements, if the stub code is inserted at the entrance of the key video decoding function, it is estimated that the application will cause a stall (i.e., the response time exceeds 500 milliseconds) or the memory occupation will sharply increase by more than 500 MB. Therefore, the position is a position with relatively large performance influence, and should be screened and excluded. Conversely, if the performance data of the key position after the insertion of the stub code is still within the set threshold range, the position can be retained as a candidate insertable position.

[0031] S1103, sort the key positions after the matching and screening according to a preset priority, and determine the optimal insertion position based on the sorting.

[0032] Specifically, the candidate insertable positions are sorted according to the size of the additional running time overhead and resource occupation caused by the insertion of the coverage collection code into the candidate insertable positions, so as to screen out the candidate insertable position with the smallest additional running time overhead and resource occupation caused by the insertion of the coverage collection code into the candidate insertable position as the optimal insertion position.

[0033] In the embodiments of the present application, the identified insertable key positions are screened and sorted based on the running time and resource occupation, so as to screen out the optimal insertion position. That is, when determining the stub insertion position, the influence of the insertion of the coverage collection code on the performance of the application is fully considered, the key positions that will have a relatively large negative influence on the performance are excluded, and the optimal position with the smallest performance influence is selected for stub insertion. Therefore, the normal implementation of the coverage collection function can be ensured while the interference with the normal operation of the application is minimized, and the application can still maintain good performance after being stubbed.

[0034] S120, in response to a request to access the application, determining the execution code covered by the request according to the version running environment corresponding to the request and the coverage collection code corresponding to the request, and writing the execution code covered by the request into a file in a preset container temporary directory.

[0035] The request in the embodiment of the application refers to an access request initiated by a client to an application program of a server side through an HTTP protocol. After receiving the HTTP request, the server calls corresponding application program code to process the request according to a requested URL (Uniform Resource Locator, used to specify a resource to be accessed), a request method and request parameters (that is, to determine which code in the application program to call to process the request). In the process of processing the HTTP request, the application program executes a series of code logic (such as function calling, conditional judgment, loop operation and the like). The code segments executed are the execution code covered by the request.

[0036] Optionally, Figure 3 is a flowchart provided by the embodiment of the application for determining execution code covered by a request. As shown in Figure 3 , the step of determining execution code covered by the request specifically includes S1201-S1204: S1201, analyze a request for accessing the application program, determine a version running environment identifier corresponding to the request and a type identifier of the request.

[0037] When the client initiates an access request to the application program of the server side through the HTTP protocol, the server receives the request and analyzes information such as a URL of the request, a request method and request parameters of the request. Through the analysis of the request information, the version running environment identifier corresponding to the request and the type identifier of the request are obtained, and then it is determined how to process the request.

[0038] S1202, according to the version running environment identifier, locate the coverage collection code set in the application program that matches the version running environment identifier.

[0039] S1203, according to the request type identifier, filter out a coverage collection code subset related to the request type identifier from the coverage collection code set.

[0040] Specifically, different request types correspond to different business logic and execution code, so through the request type identifier, the code part related to the request can be quickly located, so as to realize coverage collection of specific code.

[0041] S1204, monitor execution of the code corresponding to the coverage collection code subset, and determine the code as execution code in the case that the code is executed.

[0042] Optionally, Figure 4 is a flowchart provided by the embodiment of the application for writing execution code covered by a request into a file in a preset container temporary directory. As shown in Figure 4As shown, the step of writing the execution code covered by the request into a file in the preset container temporary directory specifically includes S1205-S1206: S1205, according to the version running environment identifier, a target file name is constructed in the container temporary directory.

[0043] S1206, the execution code covered by the request is written into the file of the target file name, and the coverage data file corresponding to each version running environment is obtained.

[0044] According to the version running environment identifier, the embodiment of the application constructs a file name, and stores the execution code coverage data under different versions of the running environment separately, so that the execution code under different versions of the running environment is facilitated to be distinguished and managed subsequently.

[0045] S130, in the case where the request is executed, the execution code in the preset container temporary directory is merged to obtain the merged execution code.

[0046] Specifically, the server has performed the processing operation on the request initiated by the client to access the application, and in the case where the corresponding code logic called by the request has been executed, all the execution code in the preset container temporary directory is merged.

[0047] Optionally, Figure 5 is a flowchart provided by the embodiment of the application for merging the execution code. As shown, Figure 5 the step of merging the execution code specifically includes S1301-S1302: S1301, the version running environment identifier and the execution code in each coverage data file are extracted by traversing the coverage data file corresponding to each version running environment in the container temporary directory.

[0048] S1302, the execution code in the coverage data file corresponding to each version running environment is processed by set union to obtain the merged execution code.

[0049] In the embodiment of the application, the set union processing can be understood as integrating the execution code under different versions of the running environment together, and the execution code is not repeated. For example, the execution code in version 1 includes execution code A and execution code B; the execution code in version 2 includes execution code A, execution code B and execution code C, and the merged execution code obtained after the set union processing is: execution code A, execution code B and execution code C.

[0050] Optionally, Figure 6 is a flowchart provided by the embodiment of the application for processing the execution code corresponding to each version running environment by set union. As shown,Figure 6 As shown, the step of performing set processing on the execution codes corresponding to the respective versions of the running environments specifically includes S1303-S1306: S1303, determining the code differences of the source code before instrumentation under different versions of the running environments.

[0051] Specifically, the source code before instrumentation under different versions of the running environments is compared, and the changes of functions or classes, changes of variables or data structures, etc. in the corresponding codes of the two versions are analyzed, and the specific differences between the source codes of each version are recorded.

[0052] S1304, constructing a version difference mapping table according to the code differences.

[0053] The mapping table is used to describe the corresponding relationship between the source codes under different versions of the running environments; for example, taking version 1 as the benchmark, if a function in version 2 is renamed, the mapping table will record the name correspondence of the function in version 1 and version 2.

[0054] S1305, converting the execution codes corresponding to the respective versions of the running environments into a unified version of the code format according to the version difference mapping table, to obtain converted execution codes of each version.

[0055] The execution codes recorded under different versions of the running environments are converted by using the version difference mapping table, so that they conform to the unified version format in the representation form; for example, if the mapping table records that the name of a variable in version 1 and version 2 is different, taking version 1 as the benchmark, the variable name in version 2 is converted to the variable name in version 1, so as to eliminate the influence of the code differences between versions on the subsequent set processing.

[0056] S1306, performing set processing on the converted execution codes of each version to obtain merged execution codes.

[0057] S140, determining the coverage result of the application program before instrumentation based on the merged execution codes.

[0058] Optionally, Figure 7 is a flowchart provided by the embodiment of the present application for determining the coverage result of the application program before instrumentation. As shown, Figure 7 the step of determining the coverage result of the application program before instrumentation specifically includes S1401-S1403: S1401, obtaining the total code amount of the source code of the application program before instrumentation.

[0059] S1402, calculating the execution code amount in the merged execution codes as the covered code amount.

[0060] S1403, calculate a ratio of the covered code amount and the total code amount, to obtain a coverage result before the application is instrumented.

[0061] In summary, the embodiment of the present application provides a programming language coverage determination method. When an application is built, coverage collection code matching different version running environments of the application is inserted into source code of the application through instrumenting operation based on the different version running environments of the application. The coverage collection code is used to collect execution code. In response to a request to access the application, execution code covered by the request is determined according to a version running environment corresponding to the request and corresponding coverage collection code, and the execution code covered by the request is written into a file in a preset container temporary directory. In a case where the request is executed, execution code in the preset container temporary directory is merged to obtain merged execution code. Based on the merged execution code, a coverage result before the application is instrumented is determined. In the above technical means, instrumenting operation is implemented according to different version running environments of the application, and coverage collection code matching each version running environment is inserted into the source code, thereby avoiding the situation that part of the code cannot be effectively collected due to version difference. After the request is executed, execution code data generated under each version environment is integrated, and the coverage result before the application is instrumented is determined based on the merged execution code, thereby fully considering code execution difference under different version running environments, and improving comprehensiveness and accuracy of collected coverage.

[0062] Figure 8 A structural schematic diagram of a programming language coverage determination device provided by the embodiment of the present application is shown in FIG. 2. As shown in FIG. 2, the device includes an instrumenting module 21, a writing module 22, a merging module 23 and a determining module 24. Figure 8 The instrumenting module 21 is configured to, when an application is built, insert coverage collection code matching each version running environment of the application into source code of the application through instrumenting operation based on different version running environments of the application. The coverage collection code is used to collect execution code.

[0063] The instrumenting module 21 is configured to, when an application is built, insert coverage collection code matching each version running environment of the application into source code of the application through instrumenting operation based on different version running environments of the application. The coverage collection code is used to collect execution code. The writing module 22 is configured to, in response to a request to access the application, determine execution code covered by the request according to a version running environment corresponding to the request and corresponding coverage collection code, and write the execution code covered by the request into a file in a preset container temporary directory. The merging module 23 is configured to, in a case where the request is executed, merge the execution code in the preset container temporary directory to obtain merged execution code. The determining module 24 is configured to determine a coverage result of the application before being instrumented based on the merged execution code.

[0064] On the basis of the above embodiment, the instrumenting module 21 comprises an instrumenting position determining unit configured to determine a position of the instrumenting operation and insert the coverage collection code into an optimal position in the source code.

[0065] On the basis of the above embodiment, the instrumenting position determining unit comprises: An identifying subunit configured to analyze structural information of the source code in the application and identify key positions where the coverage collection code can be inserted; wherein the key positions comprise function entrances, loop structure starting positions, and conditional judgment branch positions. A screening subunit configured to match and screen the key positions according to a preset rule. An optimal position determining subunit configured to sort the key positions after being matched and screened according to a preset priority and determine an optimal insertion position based on the sorting.

[0066] On the basis of the above embodiment, the writing module 22 comprises: A request analyzing unit configured to analyze a request for accessing the application, determine a version running environment identifier corresponding to the request and a type identifier of the request. A code collection matching unit configured to locate, according to the version running environment identifier, the coverage collection code collection in the application that matches the version running environment identifier. A code subset screening unit configured to screen, according to the request type identifier, a coverage collection code subset related to the request type identifier from the coverage collection code collection. An execution code determining unit configured to monitor execution of a code corresponding to the coverage collection code subset and determine the code as execution code in a case where the code is executed.

[0067] On the basis of the above embodiment, the writing module 22 further comprises: A naming building unit configured to build a target file name according to the version running environment identifier in the container temporary directory. A code writing unit configured to write the execution code covered by the request into a file with the target file name to obtain a coverage data file corresponding to each version running environment.

[0068] On the basis of the above embodiment, the merging module 23 comprises: An extracting unit configured to traverse the coverage data files corresponding to each version running environment in the container temporary directory, extract a version running environment identifier and execution code in each coverage data file. a merging unit configured to perform a union operation on the execution code in the coverage data files corresponding to the respective versions of the running environment to obtain merged execution code.

[0069] In the above embodiment, the merging unit comprises: a difference determination subunit configured to determine the code difference of the source code before the instrumentation under different versions of the running environment; a mapping table construction subunit configured to construct a version difference mapping table according to the code difference; a code conversion subunit configured to convert the execution code corresponding to the respective versions of the running environment into a unified version of the code format according to the version difference mapping table to obtain converted execution code of the respective versions; a union operation subunit configured to perform a union operation on the converted execution code of the respective versions to obtain merged execution code.

[0070] In the above embodiment, the determination module 24 comprises: a total code amount acquisition unit configured to acquire the total code amount of the source code before the instrumentation of the application program; a covered code amount calculation unit configured to calculate the execution code amount in the merged execution code as the covered code amount; a coverage calculation unit configured to calculate the ratio of the covered code amount to the total code amount to obtain the coverage result before the instrumentation of the application program.

[0071] In summary, the programming language coverage determination apparatus provided in the embodiments of the present application inserts coverage collection code matched with the running environments of different versions of the application program into the source code of the application program through a patching operation when the application program is constructed, based on the running environments of different versions of the application program. The coverage collection code is used to collect the execution code. In response to a request for accessing the application program, the execution code covered by the request is determined according to the version running environment corresponding to the request and the corresponding coverage collection code, and the execution code covered by the request is written into a file in a preset container temporary directory. In the case where the request is executed, the execution code in the preset container temporary directory is merged to obtain merged execution code. The coverage result of the application program before being patched is determined based on the merged execution code. In the above technical means, the patching operation is implemented according to the running environments of different versions of the application program, and the coverage collection code matched with the running environments of different versions is inserted into the source code, so that the situation that part of the code cannot be effectively collected due to version difference is avoided. After the request is executed, the execution code data generated under different version environments is integrated, the coverage result of the application program before being patched is determined based on the merged execution code, the code execution difference under different version running environments is fully considered, and therefore the comprehensiveness and accuracy of the collected coverage are improved.

[0072] The programming language coverage determination apparatus provided in the embodiments of the present application can be used to execute the programming language coverage determination method provided in the above embodiments, and has corresponding functions and advantages.

[0073] Figure 9 FIG. 1 is a structural schematic diagram of a programming language coverage determination device provided in the embodiments of the present application. As shown in FIG. 1, the programming language coverage determination device includes a processor 31, a memory 32, a communication device 33, an input device 34, and an output device 35. Figure 9 The number of processors 31 in the programming language coverage determination device can be one or more, and the number of memories 32 in the programming language coverage determination device can be one or more. The processor 31, the memory 32, the communication device 33, the input device 34, and the output device 35 of the programming language coverage determination device can be connected through a bus or other means.

[0074] The memory 32, as a computer readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules of the programming language coverage determination method of any embodiment of the present application (for example, the instrumentation module 21, the writing module 22, the merging module 23 and the determination module 24 in the programming language coverage determination apparatus). The memory 32 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and application programs required by at least one function; and the data storage area can store data created according to the use of the device and the like. In addition, the memory 32 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device or other non-volatile solid-state memory device. In some examples, the memory can further include a memory remotely arranged with respect to the processor, which can be connected to the device through a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.

[0075] The communication apparatus 33 is used for data transmission.

[0076] The processor 31 executes various function applications and data processing of the device by running the software programs, instructions and modules stored in the memory 32, that is, implements the above-mentioned programming language coverage determination method.

[0077] The input apparatus 34 can be used to receive input digital or character information, and generate key signal input related to user settings and function control of the device. The output apparatus 35 can include a display device such as a display screen.

[0078] The above-mentioned programming language coverage determination device can be used to execute the programming language coverage determination method provided by the above-mentioned embodiments, and has corresponding functions and advantages.

[0079] The embodiment of the present application also provides a storage medium containing computer executable instructions, which are used to execute a programming language coverage determination method when executed by a computer processor. The programming language coverage determination method comprises the following steps: when an application program is constructed, based on different version running environments of the application program, inserting coverage collection codes matched with the version running environments of the application program into the source code of the application program through an instrumentation operation; wherein the coverage collection codes are used to collect execution codes; in response to a request for accessing the application program, determining the execution codes covered by the request according to the version running environment corresponding to the request and the corresponding coverage collection codes, and writing the execution codes covered by the request into a file in a preset container temporary directory; in the case that the request is executed, merging the execution codes in the preset container temporary directory to obtain merged execution codes; and determining a coverage result of the application program before being instrumented based on the merged execution codes.

[0080] Storage medium – any type of memory device or storage device. The term “storage medium” is intended to include: mounting media, such as CD-ROM, floppy disk, or magnetic tape devices; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. Storage medium may also include other types of memory or combinations thereof. Furthermore, storage medium may reside in a first computer system in which the program is executed, or it may reside in a different second computer system connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term “storage medium” can include two or more storage media residing in different locations (e.g., in different computer systems connected via a network). Storage medium may store program instructions (e.g., specifically implemented as a computer program) executable by one or more processors.

[0081] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the programming language coverage determination method described above, but can also perform related operations in the programming language coverage determination method provided in any embodiment of this application.

[0082] The programming language coverage determination device, storage medium, and programming language coverage determination equipment provided in the above embodiments can execute the programming language coverage determination method provided in any embodiment of this application. For technical details not described in detail in the above embodiments, please refer to the programming language coverage determination method provided in any embodiment of this application.

[0083] The above description is merely a preferred embodiment and the technical principles employed in this application. This application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions that can be made by those skilled in the art will not depart from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application. The scope of this application is determined by the scope of the claims.

Claims

1. A method of determining coverage of a programming language, characterized by, The application comprises the following steps: During the construction of an application program, coverage collection codes matching different version running environments of the application program are inserted into the source code of the application program through a patching operation, based on the different version running environments of the application program; wherein the coverage collection codes are used to collect execution codes; In response to a request to access the application program, the execution codes covered by the request are determined according to the version running environment corresponding to the request and the corresponding coverage collection codes, and the execution codes covered by the request are written into a file in a preset container temporary directory; In the case where the request is executed, the execution codes in the preset container temporary directory are merged to obtain merged execution codes; Based on the merged execution codes, the coverage result of the application program before patching is determined.

2. The programming language coverage determination method according to claim 1, characterized in that, Before the patching operation, the following steps are further included: The position of the patching operation is determined, which is used to insert the coverage collection codes into the optimal position in the source code; Correspondingly, the determination of the position of the patching operation comprises the following steps: The structural information of the source code in the application program is analyzed to identify key positions where the coverage collection codes can be inserted; wherein the key positions include function entrances, loop structure starting points, and conditional judgment branch points; The key positions are matched and screened according to a preset rule; The key positions after the matching and screening are sorted according to a preset priority, and the optimal insertion position is determined based on the sorting.

3. The programming language coverage determination method according to claim 1, characterized in that, The determination of the execution codes covered by the request according to the version running environment corresponding to the request and the corresponding coverage collection codes comprises the following steps: The request to access the application program is analyzed to determine the version running environment identifier corresponding to the request and the type identifier of the request; The coverage collection code set matching the version running environment identifier is located in the application program according to the version running environment identifier; The coverage collection code subset related to the request type identifier is screened from the coverage collection code set according to the request type identifier; The execution of the code corresponding to the coverage collection code subset is monitored, and the code is determined as an execution code if the code is executed.

4. The programming language coverage determination method according to claim 3, characterized in that, The writing of the execution codes covered by the request into a file in a preset container temporary directory comprises the following steps: The target file naming is constructed in the container temporary directory according to the version running environment identifier; The execution codes covered by the request are written into the file with the target file naming to obtain coverage data files corresponding to each version running environment.

5. The programming language coverage determination method according to claim 4, characterized in that, The merging of the execution codes in the preset container temporary directory to obtain merged execution codes comprises the following steps: The version running environment identifier and the execution code in each coverage data file are extracted by traversing the coverage data files corresponding to each version running environment in the container temporary directory; The execution codes in the coverage data files corresponding to each version running environment are processed by set union to obtain merged execution codes.

6. The programming language coverage determination method according to claim 5, characterized in that, The union processing of the execution code in the coverage data files corresponding to the respective versions of the running environment obtains merged execution code, including: determining the code difference of the source code before the instrumentation in different versions of the running environment; constructing a version difference mapping table according to the code difference; converting the execution code corresponding to the respective versions of the running environment into a unified version of the code format according to the version difference mapping table to obtain converted respective versions of the execution code; performing union processing on the converted respective versions of the execution code to obtain merged execution code.

7. The programming language coverage determination method according to claim 1, characterized in that, The coverage result of the application program before the instrumentation is determined based on the merged execution code, including: obtaining the total code amount of the source code of the application program before the instrumentation; calculating the execution code amount in the merged execution code as the covered code amount; calculating the ratio of the covered code amount to the total code amount to obtain the coverage result of the application program before the instrumentation.

8. A programming language coverage determination apparatus characterized by comprising: including: an instrumentation module configured to insert, based on different versions of the running environment of the application program, coverage collection code matched with respective versions of the running environment of the application program into the source code of the application program through an instrumentation operation when the application program is constructed, wherein the coverage collection code is configured to collect execution code; a writing module configured to, in response to a request to access the application program, determine the execution code covered by the request according to the version of the running environment corresponding to the request and the corresponding coverage collection code, and write the execution code covered by the request into a file in a preset container temporary directory; a merging module configured to, in a case where the request is executed, merge the execution code in the preset container temporary directory to obtain merged execution code; a determination module configured to determine the coverage result of the application program before the instrumentation based on the merged execution code.

9. A programming language coverage determination device, characterized by, including: one or more processors; a memory storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the programming language coverage determination method according to any one of claims 1-7.

10. A storage medium containing computer-executable instructions, wherein: The computer executable instructions, when executed by a computer processor, are used to perform the programming language coverage determination method according to any one of claims 1-7.