Positioning method, program product, medium and equipment
By acquiring and filtering the set of commit records in software development, and using binary search iterative testing, the code causing the problem can be quickly located. This solves the problem of time-consuming and difficult code source location in existing technologies, and improves software development efficiency and version stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAXIN GIANTS (HANGZHOU) MICROELECTRONICS CO LTD
- Filing Date
- 2024-10-25
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies make it difficult to quickly locate the source code causing problems in software development, resulting in time-consuming and inefficient testing.
By obtaining several lines of code that caused the software problem and their development order, a set of commit records is generated. Then, a binary search method is used to filter intermediate code, and iterative testing is conducted until the earliest code that caused the problem is located.
It enables rapid and accurate location of the source code of software problems, saving manpower and computing power, and improving software development efficiency and version stability.
Smart Images

Figure CN121935141A_ABST
Abstract
Description
[Technical Field]
[0001] This invention relates to the field of software development technology, and in particular to a positioning method, program product, medium, and device. [Background Technology]
[0002] In the field of software development, due to the complexity of development data, the execution of test cases often takes a long time. For example, smoke testing or regression testing are commonly used. These tests can quickly detect whether the software can run normally, but when problems occur, they cannot pinpoint the exact source of the problem.
[0003] For example, in EDA software (Electronic Design Automation) testing, during daily development using CI (Continuous Integration) workflows, we inevitably encounter situations where defects or problems are introduced into the version. Defects or problems refer to errors in the submitted code itself, causing functional errors in the resulting software version. Typically, in a CI workflow, each code commit by an engineer generates a commit record. If the software were tested after every commit, it would consume a significant amount of time and computing power. Testing the software periodically only detects errors within that specific timeframe, without pinpointing the exact code commit that caused the problem. Furthermore, designers tend to identify the earliest line of code that caused the problem in order to modify the code at its source and ensure the software functions correctly. [Summary of the Invention]
[0004] In order to quickly locate which line of code first caused the software problem, this invention provides a location method, program product, medium, and device.
[0005] To solve the above-mentioned technical problems, the present invention provides the following technical solution: a localization method for quickly locating the code that first causes a software problem in software testing, comprising the following steps:
[0006] Obtain several lines of code that caused the software problem and their development order, and generate a set of commit records from these lines of code;
[0007] Retrieve intermediate code from the commit record set based on the order of development;
[0008] Perform test operations to test whether software problems arise during the development of intermediate code;
[0009] If so, take the code that was developed earlier than the intermediate code and use it as a new set of commit records;
[0010] If not, take the code that is developed later than the intermediate code from a certain number of code lines as a new set of commit records;
[0011] Retrieve intermediate code from the new set of commit records and perform the same conditional operation until only one line of code remains in the new set of commit records;
[0012] Determine whether the remaining line of code causes a software problem;
[0013] If so, then this code is the earliest code to cause the software problem;
[0014] If not, then the code that was developed later than this code is the earliest code to cause the software problem.
[0015] Preferably, obtaining the code that causes the software problem includes:
[0016] Obtain several lines of code in the order they were developed, and determine whether the developed code caused software problems;
[0017] If not, continue developing new code and periodically iterate to determine whether the newly developed code causes software problems;
[0018] If so, the developed code will be used as a set of commit records.
[0019] Preferably, obtaining several lines of code in the order of their development includes:
[0020] A sample software version is generated at preset intervals. All code developed during those preset intervals is obtained, and the code is sorted in the order of its development to obtain a number of lines of code.
[0021] Preferably, obtaining intermediate code from the commit record set based on the development order includes:
[0022] The binary search method is used to filter several lines of code in the set of submission records;
[0023] If the number of code lines is odd, sort them according to the order in which they were developed, obtain the sort number, and then take the code corresponding to the median from the sort number and set that code as the middle code.
[0024] If the number of code lines is even, sort them according to the order in which they were developed, obtain the sort number, and then obtain the two codes corresponding to the sort number when calculating the median. Set either of the two codes as the middle code.
[0025] Preferably, after obtaining the intermediate code from the commit record set based on the development order, the process includes:
[0026] Determine if the intermediate code exists in the archived software version;
[0027] If so, obtain the archiving software version corresponding to the intermediate code, and test the archiving software version to determine if there are any problems with the archiving software version;
[0028] If not, compile the intermediate code to form a compiled software version, and test the compiled software version to determine if there are any problems.
[0029] Preferably, after determining whether the remaining line of code causes a software problem, the process further includes:
[0030] If so, then that code will be considered the earliest code to cause a system problem;
[0031] If not, the code that was developed later than this code will be considered the earliest code to cause a system problem;
[0032] Extract the code that first caused the system problem and generate a system email, then send the system email to complete the notification process.
[0033] Preferably, all code that was developed before the earliest code that caused the system problem is retrieved, and all retrieved code is stored in the commit record set.
[0034] To solve the above-mentioned technical problems, the present invention provides another technical solution as follows: a computer program product, including a computer program / instruction, which implements the above-mentioned positioning method when executed by a processor.
[0035] To solve the above-mentioned technical problems, the present invention provides another technical solution as follows: a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, the computer instructions being used to cause the computer to execute the above-mentioned positioning method.
[0036] To solve the above-mentioned technical problems, the present invention provides another technical solution as follows: a computer device applied to the above-mentioned positioning method, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the above-mentioned computer program to implement the positioning method.
[0037] Compared with the prior art, the positioning method, program product, medium, and device provided by the present invention have the following beneficial effects:
[0038] 1. An embodiment of the present invention provides a localization method for quickly locating the earliest code causing a software problem in software testing, comprising the following steps:
[0039] Obtain several lines of code that caused the software problem and their development order, and generate a set of commit records from these lines of code;
[0040] Retrieve intermediate code from the commit record set based on the order of development;
[0041] Perform test operations to test whether software problems arise during the development of intermediate code;
[0042] If so, take the code that was developed earlier than the intermediate code and use it as a new set of commit records;
[0043] If not, take the code that is developed later than the intermediate code from a certain number of code lines as a new set of commit records;
[0044] Retrieve intermediate code from the new set of commit records and perform the same conditional operation until only one line of code remains in the new set of commit records;
[0045] Determine whether the remaining line of code causes a software problem;
[0046] If so, then this code is the earliest code to cause the software problem;
[0047] If not, then the code that was developed later than this code is the earliest code to cause the software problem. This embodiment can accurately locate the source code that caused the software problem without requiring a large amount of manpower or computing power, and can pinpoint the specific code submission of a certain module.
[0048] 2. The localization method as described in claim 1, characterized in that: obtaining the several lines of code that cause the software problem includes:
[0049] Obtain several lines of code in the order they were developed, and determine whether the developed code caused software problems;
[0050] If not, continue to acquire new code and iteratively determine whether the newly acquired code causes software problems;
[0051] If so, compile a set of commit records for the developed code. This allows for quick identification of the code causing software issues and rapid filtering out code that does not.
[0052] 3. The positioning method as described in claim 2, characterized in that: obtaining several lines of code in the order of development includes:
[0053] A sample software version is built and generated at preset time intervals. All code developed during that preset time period is retrieved, and the code is sorted according to the order of development to obtain a certain number of lines. All code submitted within the preset time period is retrieved, eliminating the need for deliberate code selection, making it simple and convenient.
[0054] 4. The positioning method as described in claim 1, characterized in that: obtaining intermediate code from the commit record set based on the sequential development order includes:
[0055] The binary search method is used to filter several lines of code in the set of submission records;
[0056] If the number of code lines is odd, sort them according to the order in which they were developed, obtain the sort number, and then take the code corresponding to the median from the sort number and set that code as the middle code.
[0057] If the number of code snippets is even, they are sorted according to their development order, and a sort number is obtained. The two codes corresponding to these sort numbers are then used to calculate the median, and either code is designated as the middle code. A binary search method is employed for efficient filtering, quickly identifying the middle value in a set of data, effectively improving the efficiency of problem localization in this embodiment.
[0058] 5. The positioning method as described in claim 1, characterized in that: after obtaining the intermediate code in the commit record set based on the development order, it includes:
[0059] Determine if the intermediate code exists in the archived software version;
[0060] If so, obtain the archiving software version corresponding to the intermediate code, and test the archiving software version to determine if there are any problems with the archiving software version;
[0061] If not, the intermediate code is compiled to form a compiled software version, and this compiled software version is tested to determine if any problems exist. This innovative approach of creating a software version of the intermediate code, regardless of whether an archived software version exists, allows for testing to determine if the intermediate code is causing software issues.
[0062] 6. The location method as described in claim 1, characterized in that: after determining whether the remaining line of code causes a software problem, it further includes:
[0063] If so, then that code will be considered the earliest code to cause a system problem;
[0064] If not, the code that was developed later than this code will be considered the earliest code to cause a system problem;
[0065] Extract the code that first caused the system problem and generate a system email. Send the system email to complete the notification process. Besides notifying engineers to promptly record the code that first caused the software problem, this also allows engineers to record the problematic code so that they can avoid similar errors in subsequent code submissions.
[0066] 7. The location method as described in claim 6, characterized in that: all code developed before the earliest code that caused the system problem is obtained, and all obtained code is stored in a code table. Subsequent engineers can directly call the code in the code table without worrying that the called code will cause software problems, thus offering high convenience.
[0067] 8. The present invention also provides a computer program product that has the same beneficial effects as the above-described positioning method, and will not be described in detail here.
[0068] 9. The present invention also provides a computer-readable storage medium that has the same beneficial effects as the above-described positioning method, and will not be described in detail here.
[0069] 10. The present invention also provides a computer device that has the same beneficial effects as the above-described positioning method, and will not be described in detail here. [Attached Image Description]
[0070] Figure 1 This is a flowchart illustrating the positioning method provided in the first embodiment of the present invention.
[0071] Figure 2 This is a flowchart illustrating the method for obtaining several lines of code that cause software problems, provided in the first embodiment of the present invention.
[0072] Figure 3 This is a flowchart illustrating the order of development of the positioning method provided in the first embodiment of the present invention, sorting by size.
[0073] Figure 4 This is a schematic diagram illustrating the process of testing the software corresponding to the intermediate code of the positioning method provided in the first embodiment of the present invention.
[0074] Figure 5 This is a schematic diagram of the structure of the computer program product provided in the second embodiment of the present invention.
[0075] Figure 6 This is a schematic diagram of the structure of a computer-readable storage medium provided in the third embodiment of the present invention.
[0076] Figure 7 This is a schematic diagram of the structure of the computer device provided in the fourth embodiment of the present invention.
Detailed Implementation Methods
[0077] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0078] In the embodiments provided by this invention, it should be understood that "B corresponding to A" means that B is associated with A, and B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B solely based on A; B can also be determined based on A and / or other information.
[0079] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of the invention. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Those skilled in the art should also recognize that the embodiments described in the specification are optional embodiments, and the actions and modules involved are not necessarily essential to the invention.
[0080] In various embodiments of the present invention, it should be understood that the sequence number of each process does not necessarily imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0081] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It is particularly important to note that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0082] In the field of software development, due to the complexity of development data, the execution of test cases often takes a long time. For example, smoke testing or regression testing are commonly used.
[0083] Smoke testing, conducted before software release, involves running a set of simple test cases to check the system's stability and ensure there are no obvious errors or defects. The purpose of smoke testing is to ensure that critical software functionalities have been fully integrated into the system and that the risk of malfunction due to basic coding errors is low, allowing subsequent testing to proceed more effectively. It primarily focuses on functional modules and may not uncover detailed issues.
[0084] Regression testing refers to retesting modified code to confirm that the changes did not introduce new errors or cause errors in other code. It is an important part of software testing, designed to ensure that the software continues to function as expected after modifications. It detects new problems or errors in the product by re-executing previously passed test cases.
[0085] These tests can quickly detect whether the software can run normally, but when the software has problems, they cannot pinpoint the source of the problem in detail.
[0086] For example, in EDA software (Electronic Design Automation) testing, during daily development using CI (Continuous Integration) processes, defects or issues inevitably arise that introduce problems into the software version. Defects or issues refer to errors in the submitted code itself, causing functional errors in the resulting software version. Typically, in a CI process, each code commit by an engineer generates a corresponding commit history. If smoke testing can detect these defects, we can immediately identify which commit introduced the problem. However, some issues may not be detected in smoke testing but can be discovered during regression testing. Therefore, quickly identifying which code commit caused the problem is crucial.
[0087] However, existing technologies, such as smoke testing or regression testing, are time-consuming and computationally expensive if tested after every code commit. Testing only periodically can detect errors within that specific timeframe, without pinpointing the exact code commit that caused the problem. Furthermore, designers often prefer to identify the earliest code that caused the issue in order to modify the code at its source and ensure proper software operation.
[0088] Please refer to the figure. The first embodiment of the present invention provides a localization method for quickly locating problematic code in software testing, including the following steps:
[0089] S1, obtain several lines of code that caused the software problem and their development order, and generate a set of commit records from these lines of code;
[0090] S2, based on the order of development, retrieves one piece of code from the set of submission records as intermediate code;
[0091] S3 performs test operations on the software to test whether software problems are caused during the development of intermediate code;
[0092] S4, if so, take the code that was developed earlier than the intermediate code as a new set of commit records;
[0093] S5. If not, take the code that is developed later than the intermediate code as a new set of commit records.
[0094] S6, retrieve the intermediate code from the new commit record set and perform the same judgment operation until only one piece of code remains in the new commit record set;
[0095] S7, determine whether the remaining line of code causes a software problem;
[0096] S8, if so, is the earliest code to cause the software problem;
[0097] S9. If not, then the code that was developed later than this code is the earliest code to cause the software problem.
[0098] Typically, when designing software, every piece of code submitted by an engineer carries the risk of causing software problems. However, software testing isn't done after every single line of code is developed; instead, it's done periodically. For example, engineers might test the software every other day to check for issues that day. Software problems can arise from the combined effect of multiple lines of code, or they might be caused by a single line of code. In such cases, designers tend to focus on identifying the earliest line of code that caused the problem. This process involves pinpointing the earliest code that caused the software issue.
[0099] The localization method provided in this implementation first identifies several lines of code that cause the software problem. These lines of code refer to the new code developed by engineers at regular intervals. It should be noted that the amount of new code developed by engineers is enormous. For example, engineers may develop thousands or even tens of thousands of lines of code daily. For instance, if an engineer develops 1000 new lines of code in a day, and a problem is discovered through testing, then some of these 1000 new lines of code will inevitably be the code that caused the software problem. The designer's current requirement is to identify which line of code first caused the software problem. Furthermore, all the newly developed lines of code are grouped into a commit record set, which is a tabular file. Since the code is committed in a strict order, the codes in the commit record set are sorted according to the order in which they were developed.
[0100] Furthermore, intermediate code is obtained from the commit record set based on the development order. It should be noted that the commit record set can be a table containing several lines of code, or a document or data stream containing several lines of code. Additionally, the code within the commit record set is already sorted in chronological order, with the intermediate code referring to the middle line of code in the table. For example, if the commit record set has 9 lines, the intermediate code refers to the code from the fifth development iteration. If the commit record set has 10 lines, the intermediate code could be the code from the fifth or sixth development iteration. In some possible implementations, the definition of intermediate code may not be the first or last line of code in the commit record set.
[0101] Furthermore, the software undergoes testing. Testing refers to performing tests on the software. Specific methods may include smoke testing, etc. The purpose of testing is to detect whether the current software has any problems. Specifically, after each code commit, a corresponding version of the software is generated. That is, before the intermediate code is tested, other code in the commit record set that was developed earlier than the intermediate code has already been committed and generated corresponding software versions. When the intermediate code is tested, a new software version is generated for that intermediate code. For example, assuming the intermediate code is the fifth commit, and the software version after the first four commits is V1.4, then the software version after the intermediate code is developed will become V1.5. This embodiment will test whether this new software version (i.e., version V1.5) has any software problems. If problems exist, developing the intermediate code will cause software problems. Otherwise, developing the intermediate code will not cause software problems.
[0102] Specifically, after determining whether the intermediate code causes software problems, if so, the code that was developed earlier than the intermediate code is used as a new set of commit records; if not, the code that was developed later than the intermediate code is used as a new set of commit records.
[0103] It should be understood that, as a possibility, if developing intermediate code causes software problems, it indicates that the intermediate code is already code that can cause software problems. However, it does not confirm that the intermediate code is the earliest code to cause software problems. Therefore, it is necessary to confirm whether the code that caused the earliest software problems is among the code developed earlier than the intermediate code. Therefore, code developed earlier than the intermediate code can be considered as a new set of commit records.
[0104] As another possibility, if the development of intermediate code does not cause software problems, it indicates that intermediate code is not the type of code that will cause software problems, and it can be confirmed that code developed earlier than the intermediate code will not cause software problems. Therefore, the code that first caused software problems must be among the code developed later than the intermediate code. Therefore, code developed later than the intermediate code can be considered as a new set of commit records.
[0105] Furthermore, after obtaining the new set of commit records, the same steps as steps S2 to S5 can be performed, namely, obtaining the intermediate code in the new set of commit records and performing the same judgment operation, until only one line of code remains in the new set of commit records. It should be noted that step S6 is an iterative step; its iterative purpose is to continuously iterate through the code in the new set of commit records until only one line of code remains. The remaining line of code will have only two outcomes: either it will cause a software problem, or it will not cause a software problem.
[0106] Furthermore, determine whether the remaining line of code causes a software problem. If so, this line of code is the earliest to cause a software problem; if not, the line of code developed after this line is the earliest to cause a software problem. It should be understood that since this is the last remaining line of code, all lines of code, whether developed earlier or later, have undergone testing in previous iterations. That is, if the last remaining line of code causes a software problem, then the line of code developed earlier will not cause a software problem, and the last remaining line becomes the earliest line of code the designer wants to identify as causing a software problem. If the last remaining line of code does not cause a software problem, then the line of code developed later will inevitably cause a software problem. Therefore, the line of code developed later than the last remaining line is the earliest line of code the designer wants to identify as causing a software problem.
[0107] It should be understood that this embodiment obtains several lines of code that cause software problems and locates the intermediate code among them. By determining whether the intermediate code causes the software problem, iteratively filters the code in the commit record set until only one line of code remains. Ideally, by judging the last remaining code, the earliest code that caused the software problem can be located. This embodiment locates the problematic code quickly, rapidly identifying the source of the software problem. Even if developers cannot immediately fix the problem, they can quickly roll back the corresponding commit, ensuring the stability and continued operability of the version. Furthermore, this embodiment saves a significant amount of testing and development manpower. The methods provided in this embodiment are all executed automatically, requiring only simple configuration, no manual supervision, and no manual querying or analysis, saving software developers a considerable amount of time. Unlike existing technologies, this embodiment, without relying on large amounts of manpower or computing power, can accurately locate the source code that causes the software problem, precisely pinpointing the specific code commit of a certain module, and directly notifying developers of the code that ultimately caused the software problem and related test cases, facilitating the reproduction and fixing of problems in subsequent versions.
[0108] In step S1 above, obtaining several lines of code that cause the software problem includes:
[0109] S11: Obtain several lines of code in the order of their development and determine whether the developed code has caused a software problem.
[0110] S12, if not, continue to obtain new code and iteratively determine whether the newly obtained code causes software problems;
[0111] S13, if so, treat the developed code as a set of commit records.
[0112] It should be understood that "several lines of code" refers to the new code added by engineers at regular intervals. The amount of code added by engineers is very large. In fact, software problems only arise if the newly added code contains issues. That is, if the newly added code is problem-free, it will not cause software problems, and therefore, there is no problem that this implementation needs to solve. Therefore, in this embodiment, the newly added code is first tested to determine whether it causes software problems. If it does not, it indicates that the developed code is problem-free. Then, new code is developed, and the process iteratively checks whether the newly developed code causes software problems. If it does, it means that there must be code among the developed code that causes software problems. Therefore, based on the order of development, the newly added code is grouped into a commit record set.
[0113] Specifically, in step S11, obtaining several lines of code in the order of development includes:
[0114] A sample software version is built and generated at preset time intervals. All code developed within that preset time period is obtained and sorted according to the order of development to obtain a set of code snippets. It should be understood that engineers typically do not perform software testing after every code submission, but rather develop a set of code snippets within a preset time period. In this embodiment, all code developed by the engineer within the preset time period is sorted according to the order of development to obtain a set of code snippets. This facilitates the subsequent generation of a submission record set based on the development order.
[0115] In step S2 above, obtaining intermediate code from the commit record set based on the development order includes:
[0116] The binary search method is used to filter several lines of code in the set of submission records;
[0117] If the number of code lines is odd, sort them according to the order in which they were developed, obtain the sort number, and then take the code corresponding to the median from the sort number and set that code as the middle code.
[0118] If the number of code lines is even, sort them according to the order in which they were developed, obtain the sort number, and then obtain the two codes corresponding to the sort number when calculating the median. Set either of the two codes as the middle code.
[0119] It should be understood that, in one possible implementation, using a binary search to filter several lines of code in the submission record set is more efficient. Binary search is a search algorithm for finding a specific element in an ordered array. This method is also known as binary search or logarithmic search. Its basic idea is to extract the middle element of the array and continue searching within the remaining half of the array based on this middle element, thereby gradually narrowing the search range until the final target value is found. Specifically, in this embodiment, a middle value is first selected from several lines of code based on the binary search method. The selection of the middle value is related to the number of lines of code and the development order of the code.
[0120] Please see Figure 3 In one possible implementation, the number of codes is odd. For example, there are 11 codes. First, the codes are sorted from 1 to 11 according to their order of development. After sorting, corresponding sort numbers are generated. For example, the sort number of the first developed code is 1, the sort number of the second developed code is 2, and the sort number of the last developed code is 9. Then, the code corresponding to the median calculated from the sort numbers is obtained, that is, the code with sort number 6 is obtained, and this code is used as the intermediate code.
[0121] In one possible implementation, the number of codes is even; for example, there are 10 codes. First, the codes are sorted from 1 to 10 according to their order of development. This sorting generates corresponding sort numbers; for example, the first code developed has a sort number of 1, the second developed code has a sort number of 2, and the last developed code has a sort number of 10. Next, the two codes corresponding to the median of the sort numbers are obtained. When there are 10 codes, the sort numbers used to calculate the median are 5 and 6. Therefore, the code corresponding to sort number 5 and the code corresponding to sort number 6 are obtained and used as intermediate code.
[0122] It should be understood that the advantage of the binary search method lies in its efficiency. The binary search method can quickly filter out the middle value in a set of data, which can effectively improve the efficiency of problem location in this embodiment.
[0123] Furthermore, please refer to the following: Figure 4 In step S2 above, after obtaining the intermediate code from the commit record set based on the development order, the following steps are included:
[0124] Determine if the intermediate code exists in the archived software version;
[0125] If so, obtain the archiving software version corresponding to the intermediate code, and test the archiving software version to determine if there are any problems with the archiving software version;
[0126] If not, compile the intermediate code to form a compiled software version, and test the compiled software version to determine if there are any problems.
[0127] Please understand that this should also be consulted. Figure 4 Typically, software version creation is based on the amount of code an engineer develops or the time frame. For example, an engineer might save a software version each day they complete their work. Or, an engineer might save a software version every time they complete a certain amount of code. Therefore, engineers don't create a software version for every code commit. In this embodiment, when locating the code causing the software problem, the first step is to determine if an archived software version exists for the intermediate code. An archived software version refers to the software version actively saved by the engineer. If an archived software version exists for the intermediate code, there's no need to create a separate software version; the archived software version can be tested directly. Alternatively, if an archived software version doesn't exist for the intermediate code, the intermediate code is compiled to create a compiled software version, which is then tested. This embodiment innovatively creates software versions for the intermediate code, allowing testing to determine whether the intermediate code is causing software problems regardless of whether an archived software version exists.
[0128] Furthermore, step S6 above is actually an iterative execution of steps S2 to S5. Its purpose is to continuously filter out new intermediate code from the new set of commit records using a binary search method until only one piece of code remains. The remaining code will have only two outcomes: either it will cause a software problem, or it will not. In other words, this embodiment uses an iterative binary search method to filter out the last piece of code from several pieces, and then identifies the earliest code that caused the software problem by checking whether the last piece of code causes one. This method is simple and convenient.
[0129] Furthermore, determining whether the remaining line of code causes a software problem also includes:
[0130] If so, then that code will be considered the earliest code to cause a system problem;
[0131] If not, the code that was developed later than this code will be considered the earliest code to cause a system problem;
[0132] Extract the code that first caused the system problem and generate a system email, then send the system email to complete the notification process.
[0133] It should be understood that once the earliest code that caused the system problem is identified, a system email can be generated. The purpose of the system email is not only to notify engineers to record the earliest code that caused the software problem, but also to record the code that caused the software problem so that engineers can avoid the same error when submitting code in the future, thereby improving the accuracy of software code submission.
[0134] Furthermore, retrieve all code that was developed before the earliest code that caused the system problem, and store all retrieved code in a code table. It should be understood that if the earliest code that caused the system problem is identified, then all code developed before that is problem-free. This problem-free code can then be stored. For example, it can be stored in a code table, allowing engineers to directly call the code in the table without worrying about it causing software problems, thus offering high convenience.
[0135] Please see Figure 5 The second embodiment of the present invention also provides a computer program product, including a computer program / instruction, which implements the above-described positioning method when executed by a processor.
[0136] The computer program product includes an acquisition module, a build module, a test module, and a notification module. The acquisition module acquires intermediate code from the commit record set. The build module builds the software version. For example, if an archived software version exists for the intermediate code, there's no need to build a corresponding software version; otherwise, the intermediate code is compiled to form a compiled software version. The test module tests the software version corresponding to the intermediate code. It can test both the archived and compiled software versions. It should be noted that the last remaining line of code is also acquired through steps S2 to S6, meaning it is essentially intermediate code as well. The notification module extracts the code that first caused the system problem, generates a system email, and sends the email to complete the notification process.
[0137] Please see Figure 6 The third embodiment of the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions for causing the computer to perform the above-described positioning method.
[0138] Please see Figure 7 The fourth embodiment of the present invention also provides a computer device applied to the above-described positioning method, characterized in that it includes a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the positioning method.
[0139] The foregoing has provided a detailed description of a positioning method, program product, medium, and device disclosed in the embodiments of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention. Any modifications, equivalent substitutions, and improvements made within the principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A localization method for quickly locating the earliest code causing a software problem in software testing, characterized in that: Includes the following steps: Obtain several lines of code that caused the software problem and their development order, and generate a set of commit records from these lines of code; Retrieve intermediate code from the commit record set based on the order of development; Perform test operations to test whether software problems arise during the development of intermediate code; If so, take the code that was developed earlier than the intermediate code and use it as a new set of commit records; If not, take the code that is developed later than the intermediate code from a certain number of code lines as a new set of commit records; Retrieve intermediate code from the new set of commit records and perform the same conditional operation until only one line of code remains in the new set of commit records; Determine whether the remaining line of code causes a software problem; If so, then this code is the earliest code to cause the software problem; If not, then the code that was developed later than this code is the earliest code to cause the software problem.
2. The positioning method as described in claim 1, characterized in that: Retrieving several lines of code that caused the software problem includes: Obtain several lines of code in the order they were developed, and determine whether the developed code caused software problems; If not, continue to acquire new code and iteratively determine whether the newly acquired code causes software problems; If so, the developed code will be used as a set of commit records.
3. The positioning method as described in claim 2, characterized in that: The code snippets obtained in chronological order of development include: A sample software version is generated at preset intervals. All code developed during those preset intervals is obtained, and the code is sorted in the order of its development to obtain a number of lines of code.
4. The positioning method as described in claim 1, characterized in that: The intermediate code retrieved from the commit record set based on the development order includes: The binary search method is used to filter several lines of code in the set of submission records; If the number of code lines is odd, sort them according to the order in which they were developed, obtain the sort number, and then take the code corresponding to the median from the sort number and set that code as the middle code. If the number of code lines is even, sort them according to the order in which they were developed, obtain the sort number, and then obtain the two codes corresponding to the sort number when calculating the median. Set either of the two codes as the middle code.
5. The positioning method as described in claim 1, characterized in that: After retrieving intermediate code from the commit record set based on the development order, it includes: Determine if the intermediate code exists in the archived software version; If so, obtain the archiving software version corresponding to the intermediate code, and test the archiving software version to determine if there are any problems with the archiving software version; If not, compile the intermediate code to form a compiled software version, and test the compiled software version to determine if there are any problems.
6. The positioning method as described in claim 1, characterized in that: After determining whether the remaining line of code causes a software problem, the following steps are also included: If so, then that code will be considered the earliest code to cause a system problem; If not, the code that was developed later than this code will be considered the earliest code to cause a system problem; Extract the code that first caused the system problem and generate a system email, then send the system email to complete the notification process.
7. The positioning method as described in claim 6, characterized in that: Retrieve all code that was developed before the code that first caused the system problem, and store all the retrieved code in a commit history set.
8. A computer program product comprising a computer program / instructions, characterized in that: When the computer program / instruction is executed by the processor, it implements the positioning method as described in any one of claims 1 to 7.
9. A computer-readable storage medium, wherein, The computer-readable storage medium stores computer instructions for causing the computer to perform the positioning method according to any one of claims 1 to 7.
10. A computer device, applied to the positioning method as described in any one of claims 1 to 7, characterized in that: It includes a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the positioning method.