CN118409950A - Method, device, equipment and storage medium for detecting consistency of model and code - Google Patents
Method, device, equipment and storage medium for detecting consistency of model and code Download PDFInfo
- Publication number
- CN118409950A CN118409950A CN202410197700.8A CN202410197700A CN118409950A CN 118409950 A CN118409950 A CN 118409950A CN 202410197700 A CN202410197700 A CN 202410197700A CN 118409950 A CN118409950 A CN 118409950A
- Authority
- CN
- China
- Prior art keywords
- code
- detected
- model
- file
- line
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/368—Test management for test version control, e.g. updating test cases to a new software version
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/73—Program documentation
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Library & Information Science (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a method, a device, equipment and a storage medium for detecting consistency of a model and a code, and relates to the technical field of software development. The method for detecting the consistency of the model and the code comprises the following steps: under an SVN environment, a model to be detected and a code to be detected are obtained; responding to an instruction for consistency check, automatically compiling and generating an original code based on a configuration file in a model to be detected, and generating a difference file based on the code to be detected and the original code generated by automatic compiling; and identifying a change line identifier and an annotation line identifier in the difference file to obtain an identification result, and determining that the model to be detected is consistent with the code to be detected when the code change line number is 0 according to the identification result.
Description
Technical Field
The present invention relates to the field of software development technologies, and in particular, to a method, an apparatus, a device, and a storage medium for detecting consistency between a model and a code.
Background
Model and code consistency is one of the important inspection items when code is published. In the process of developing software, a plurality of models are involved, each model needs to be changed according to the requirement to regenerate codes for integration due to the change of version, and related Bug appears in the follow-up test because the fact that codes are not timely integrated after the model is modified is avoided in the process, so that the consistency of the models and the codes is necessary to be checked, and the codes are transmitted after the check is correct, so that the fault tolerance rate of the codes is higher.
In the related art, a software project usually has tens or hundreds of models, and before the code of the project is released, each model and the corresponding code are checked for consistency by manpower, which requires a long checking time or more manpower, and has high cost.
Disclosure of Invention
The present invention aims to solve at least one of the technical problems in the related art to some extent. Therefore, the invention provides a method, a device, equipment and a storage medium for detecting the consistency of a model and a code, which do not need to be checked by multiple persons and have longer checking time, thereby reducing the cost.
In a first aspect, this embodiment provides a method for detecting consistency between a model and a code, including:
under an SVN environment, a model to be detected and a code to be detected are obtained;
Responding to an instruction for consistency check, automatically compiling and generating an original code based on a configuration file in the model to be detected, and generating a difference file based on the code to be detected and the original code generated by automatic compiling;
And identifying a change line identifier and an annotation line identifier in the difference file to obtain an identification result, and determining that the model to be detected is consistent with the code to be detected when the code change line number is 0 according to the identification result.
In some embodiments, determining the number of code change lines based on the identification result includes:
when the change line identifier corresponds to the target line and the annotation line identifier exists, cutting the target line to obtain a code part and an annotation part of the target line;
if the code part of the target line is changed, the code change line number count is increased by one;
And if the annotation part of the target line is changed and the code part of the target line is not changed, the code change line number is not counted.
In some embodiments, determining the number of code change lines according to the identification result further includes:
And when the annotation line identifier does not exist in the target line corresponding to the change line identifier, the code change line count is increased by one.
In some embodiments, the code to be detected corresponds to a plurality of code files;
when the number of code change lines is determined to be 0 according to the identification result, determining that the model to be detected is consistent with the code to be detected includes:
when the code change line number of each code file is determined to be 0 according to the identification result, determining that the model to be detected is consistent with the code to be detected;
the consistency detection method further comprises the following steps:
and if the number of code change lines of at least one code file is not 0, determining that the model to be detected is inconsistent with the code to be detected.
In some embodiments, the consistency detection method further comprises:
Displaying the file information of each code file and the code change line number of the code file; wherein the file information includes at least one of: file name, file path.
In some embodiments, the automatically compiling generating the source code based on the configuration file of the model to be detected in response to the instructions for performing the consistency check includes:
responding to an instruction for consistency check, and respectively acquiring the model to be detected and version information of the code to be detected;
And when the model to be detected and the code to be detected are determined to be the latest versions based on the version information of the model to be detected and the code to be detected, automatically compiling and generating the original code based on the configuration file of the model to be detected.
In some embodiments, the generating a difference file based on the code to be detected and the original code generated by automatic compiling includes:
The original codes generated by automatic compiling are arranged in a target folder under the path of the model to be detected;
and comparing the original codes in the target folder with the codes to be detected to obtain a difference file.
In a second aspect, the present embodiment provides a device for detecting consistency between a model and a code, including:
The acquisition unit is used for acquiring a model to be detected and a code to be detected in an SVN environment;
The generating unit is used for responding to an instruction for consistency check, automatically compiling and generating an original code based on a configuration file in the model to be detected, and generating a difference file based on the code to be detected and the original code generated by automatic compiling;
And the determining unit is used for identifying the change line identifier and the annotation line identifier in the difference file to obtain an identification result, and determining that the model to be detected is consistent with the code to be detected when the code change line number is 0 according to the identification result.
In a third aspect, the present embodiment provides an electronic device, including:
A processor; and
A memory for storing executable instructions of the processor;
wherein the processor is configured to perform the method of any of the preceding claims via execution of the executable instructions.
In a fourth aspect, the present embodiment provides a computer readable storage medium storing a computer program which, when executed by a processor, implements a method as claimed in any preceding claim.
According to the method for detecting the consistency of the model and the code, the model to be detected and the code to be detected are obtained in an SVN environment; responding to an instruction for consistency check, automatically compiling and generating an original code based on a configuration file in a model to be detected, and generating a difference file based on the code to be detected and the original code generated by automatic compiling; and identifying a change line identifier and an annotation line identifier in the difference file, and determining that the model to be detected is consistent with the code to be detected when the code change line is 0 according to the identification result. Therefore, before the code is transmitted, the consistency of the batched detection model and the code can be realized, the occurrence of low-level Bug of inconsistent models and codes in a test stage is avoided, the quality of software is further improved, meanwhile, multiple people are not required to carry out inspection and longer inspection time, and the cost is reduced.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Drawings
FIG. 1 is a flow chart of a method for detecting consistency of a model and code provided by an exemplary embodiment;
FIG. 2 is a graphical user interface schematic provided by an exemplary embodiment;
FIG. 3 is a schematic diagram of a device for detecting consistency of a model and a code according to an exemplary embodiment;
Fig. 4 is a schematic structural diagram of an electronic device according to an exemplary embodiment.
Detailed Description
Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the drawings are illustrative and intended to explain the present invention and should not be construed as limiting the invention.
FIG. 1 is a flow chart of a method for detecting consistency of a model and code according to an exemplary embodiment.
Referring to fig. 1, the present embodiment provides a method for detecting consistency of a model and a code, which includes steps S101 to S103 as follows:
s101, acquiring a model to be detected and a code to be detected in an SVN environment.
S102, responding to an instruction for consistency check, automatically compiling and generating an original code based on a configuration file in a model to be detected, and generating a difference file based on the code to be detected and the original code generated by automatic compiling.
S103, identifying a change line identifier and an annotation line identifier in the difference file to obtain an identification result, and determining that the model to be detected is consistent with the code to be detected when the code change line number is 0 according to the identification result.
In step S101, the SVN environment needs to be downloaded first, and is built by creating a compiling environment variable, so that the SVN can be used to generate the difference file. Wherein SVN is an abbreviation of subversion, which is a version control system of open source code.
After the SVN environment is started, a graphical user interface is displayed to the user. Referring to fig. 2, a first interface of the graphical user interface has buttons 1, 2, 3, 4, and 5. In other examples, the graphical user interface may also have a second interface to display other content, etc., as desired.
Wherein, the button 1 can be displayed as a rectangular frame, and identifiers such as '…' or 'ˇ' or 'v' are displayed in the rectangular frame; a character identifier such as "selection model" or "selection model path" is displayed near the button 1. Button 2 may be displayed as a rectangular frame and within the rectangular frame identifiers such as "…" or "ˇ" or "v" are displayed; an identifier such as "selection code" or "selection code path" is displayed near the button 2. The regions 3 and 4 may be arranged side by side, and the regions 3 and 4 may each be rectangular. The button 5 may be displayed as a rectangular frame, and an identifier such as "consistency check" or "check model code consistency" is displayed within the rectangular frame.
The buttons 1 and 2 may be disposed near the upper side of the first interface, the button 1 may be disposed above the button 2, the buttons 1 and 2 may also be disposed near the right side of the first interface, an identifier of "select model path" may be displayed on the left side of the button 1, and an identifier of "select code path" may be displayed on the left side of the button 2; region 3 is located to the left of region 4 and button 5, and button 5 is located in the middle below region 4.
In response to the user clicking the button 1, all folders in which the model is located are displayed in the area 3, and the user can select the folder in which the model to be detected is located in the area 3. Wherein the user may select the folder in which one or more models are located in region 3.
In response to the user clicking on button 2, all folders in which the code is located are displayed in area 3, and the user can select the folder in which the code to be detected is located in area 3. Wherein the code to be detected corresponds to the model to be detected.
In specific implementation, a user can click the button 1 to select a model where the model to be detected is located so as to obtain the model to be detected, and then click the button 2 to select a folder where the code to be detected is located so as to obtain the code to be detected; the code to be detected can be obtained by clicking the button 2, and then the model to be detected can be obtained by clicking the button 1.
In step S102, in response to the user clicking on the button 5, the configuration file in the folder in which the selected model is located is automatically opened and the model is automatically compiled to generate the original code. The configuration file may be ARXML configuration file under the AUTOSAR architecture. The original code is used for comparing with the code to be detected to generate a difference file.
After generating the original code, taking the original code generated by automatic compiling as an original file, taking the code to be detected as a modification file, and generating a difference file. The difference file is used for reflecting the modification of the code to be detected compared with the original code.
In step S103, in the difference file, a changed line identifier is displayed on a line of the code to be detected that is modified (i.e., changed) compared with the original code; if not, the change line identifier is not displayed. The change identifier may be displayed on the right or left side of the corresponding row. The change identifier may include at least one of: "+", "-"; where the code of the "+" row has an increase and the code of the "-" row has a decrease.
The line where there is an annotation in the code to be detected will display the annotation line identifier. The annotation row identifier may be displayed on the right or left side of the corresponding row. The change line identifier and the comment line identifier may be located on the same side of the line or on different sides when the corresponding line displays both the change line identifier and the comment line identifier. The change row identifier may include at least one of: "/", "/"; wherein "/" denotes annotating a multi-line code; "//" indicates annotating a single line of code; ". X" is used to describe classes and methods.
It will be appreciated that: the specific kind and specific display position of the change line identifier and the comment line identifier are not limited thereto, and may be set as needed.
According to the results of the change line identifier and the comment line identifier in the identified difference file, when the code change line number is 0, the code to be detected is not changed compared with the original code generated by automatic compiling based on the configuration file in the model to be detected, and therefore the model to be detected is determined to be consistent with the code to be detected.
According to the method for detecting the consistency of the model and the code, the model to be detected and the code to be detected are obtained in an SVN environment; responding to an instruction for consistency check, automatically compiling and generating an original code based on a configuration file in a model to be detected, and generating a difference file based on the code to be detected and the original code generated by automatic compiling; and identifying a change line identifier and an annotation line identifier in the difference file, and determining that the model to be detected is consistent with the code to be detected when the code change line is 0 according to the identification result. Therefore, before the code is transmitted, the consistency of the batched detection model and the code can be realized, the occurrence of low-level Bug of inconsistent models and codes in a test stage is avoided, the quality of software is further improved, meanwhile, multiple people are not required to carry out inspection and longer inspection time, and the cost is reduced.
In some embodiments, step S103, determining the number of code change lines according to the identification result, includes the following steps a1 to a4:
Step a1: when the target line corresponding to the line identifier is changed and the annotation line identifier exists, cutting the target line to obtain a code part and an annotation part of the target line;
Step a2: if the code part of the target line is changed, the code change line number count is increased by one;
step a3: if the annotation part of the target line is changed and the code part of the target line is not changed, the number of the code change lines is not counted;
Step a4: when the annotation line identifier does not exist in the target line corresponding to the change line identifier, the code change line count is incremented by one.
In step a1, upon identifying a target line for which a change line identifier exists, it is further identified whether the annotation line identifier exists for the target line. If the comment line identifier does not exist, it is determined that the code of the target line has been changed, and step a4 is executed to change the code by +1. If the annotation line identifier exists, the target line is segmented and the target line is divided into a code portion and an annotation portion to further determine whether the code portion or the annotation portion has been altered.
In step a2, it is determined whether the code portion of the target line has been changed. Specifically, the part of the code to be detected, which corresponds to the code part of the target line, is compared with the part of the original code, which corresponds to the code part of the target line. If the code parts are inconsistent, the code part of the target line is determined to be changed, and the number of the code change lines is +1. If the code portions of the target line are consistent, the code portions of the target line are determined to be unchanged.
In step a3, it is determined whether the comment section of the target line has been changed. Specifically, comparing the part corresponding to the annotation part of the target line in the code to be detected with the part corresponding to the annotation part of the target line in the original code, and if the part is inconsistent with the part corresponding to the annotation part of the target line and the code part of the target line is not changed, determining that the annotation part of the target line is changed and the code part is not changed and determining that the number of the code change lines is unchanged.
The execution sequence of the comparison process based on the annotation part of the target line in the step a3 and the comparison process based on the code part of the target line in the step a2 can be set according to actual needs. Optionally, the comparison process based on the code portion of the target line in step a2 is executed first, and if it is determined that the code portion of the target line is changed according to the comparison result, the number of code change lines will be +1 no matter whether the code portion of the target line is changed or not. In other examples, the comparison process of the code portion based on the target line in step a2 and the comparison process of the comment portion based on the target line in step a3 may also be performed simultaneously; or the comparison process of the annotation part based on the target line in the step a3 is executed first, and then the comparison process of the code part based on the target line in the step a2 is executed.
In step a3, according to the comparison result of the part corresponding to the annotation part of the target line in the code to be detected and the part corresponding to the annotation part of the target line in the original code, if the comparison result is consistent with the comparison result, determining that the annotation part of the target line is unchanged. At this time, if it is determined that the code portion of the target line is not changed according to the comparison result in step a2, a fault notification message is generated. The code part and the annotation part of the target line are not changed, and the change line identifier is displayed at the target line, so that the fault is determined to exist, and fault prompt information can be generated to prompt a user that the fault exists in the current detection process, so that the user can conveniently conduct fault troubleshooting and repairing in time, and the user can conveniently conduct detection in time by adopting modes such as manual detection and the like.
In this embodiment, through the above arrangement, the number of lines where the code is changed can be determined under the condition that the model is inconsistent with the code, and visual and reliable references are provided for subsequent correction of the model or the code.
In some embodiments, the code to be detected corresponds to at least one code file. That is, the code to be detected may be a code in one code file or may be a code in a plurality of code files.
In step S103, when the number of code change lines is determined to be 0 according to the identification result, determining that the model to be detected is consistent with the code to be detected includes: and when the code change line number of each code file is determined to be 0 according to the identification result, determining that the model to be detected is consistent with the code to be detected.
That is, when the code to be detected is a code in one code file, if the number of code change lines in the code file is 0, it is determined that the model to be detected is consistent with the code to be detected. When the code to be detected is the code in the plurality of code files, if the number of the code change lines in the plurality of code files is 0, determining that the model to be detected is consistent with the code to be detected; if the number of code change lines in at least one code file is not 0, determining that the model to be detected is inconsistent with the code to be detected.
In some examples, to facilitate the user to intuitively understand the detection result, the method for detecting consistency between the model and the code further includes: displaying the file information of each code file and the code change line number of each code file; wherein the file information includes at least one of: file name, file path.
For example, the file information of each code file and the number of code change lines thereof may be displayed in the form of a list. For example, the left side of the list may display the file name or file path of each code file, and the right side of the list may display the number of code change lines for each code file. The number of code change lines may be 0, 1, 2, or the like.
In some embodiments, in response to the instruction for consistency check in step S102, the raw code is automatically compiled based on the configuration file of the model to be detected, including the following steps b1 to b2:
step b1: responding to an instruction for consistency check, and respectively acquiring a model to be detected and version information of a code to be detected;
Step b2: and when the model to be detected and the code to be detected are determined to be the latest versions based on the version information of the model to be detected and the code to be detected, automatically compiling and generating the original code based on the configuration file of the model to be detected.
In step b1, in response to the user clicking the button 5, version information of the model to be detected and the code to be detected may be obtained, where the version information includes a modification time or a version number, so as to determine whether the model to be detected and the code to be detected are the latest versions.
In step b2, when the modification time of the model to be detected and the code to be detected is closest to the current time, or when the version numbers of the model to be detected and the code to be detected meet the rule of the latest number, determining that the model to be detected and the code to be detected are both the latest versions.
If the model to be detected is not the latest version, the model to be detected needs to be updated until the model to be detected is the latest version. Similarly, if it is determined that the code to be detected is not the latest version, the code to be detected needs to be updated until the code to be detected is the latest version.
Optionally, when it is determined that the model to be detected or the code to be detected is not the latest version, version prompt information may be generated, where the version prompt information is used to prompt that the model to be detected or the code to be detected is not the latest version, and prompt that updating is to be performed; if the user refusing the updating instruction is not received within the preset time period, the model to be detected or the code to be detected is updated to the latest version.
When the model to be detected and the code to be detected are both determined to be the latest versions, the original code can be directly generated by automatic compiling based on the configuration file of the model to be detected. Or in response to the user clicking the button 5 again, the original code is automatically compiled based on the configuration file of the model to be detected.
And generating interrupt prompt information and interrupting to remind a user to process in time when a problem occurs in the process of updating a model to be detected or a code to be detected or when a problem occurs in the process of automatically compiling and generating an original code. After the resolution, in response to the operation of clicking the button 5 by the user, the corresponding operation is continued.
In some examples, in step S102, a difference file is generated based on the code to be detected and the original code generated by automatic compilation, including the following steps b3 to b4:
step b3, arranging the original codes generated by automatic compiling into target folders under the path of the model to be detected;
and b4, comparing the original codes in the target folder with the codes to be detected and obtaining a difference file.
In step b3, judging whether a target folder exists in the path of the detected model, if so, pasting the original code generated by automatic compiling into the target folder; if the target folder does not exist, creating the target folder, and pasting the original code generated by automatic compiling into the target folder. The name of the target folder may be set according to actual needs, for example, the name of the target folder may be code_all.
In step b4, in the generated difference file, a change line identifier is correspondingly generated on the line where the code or the annotation is changed; the annotated line identifier is generated corresponding to the line where the annotation exists.
It will be appreciated that: in the steps b1 to b4, if the user is interrupted by accident in any step, a corresponding prompt message is generated to prompt the user to process in time, and after the fault is eliminated, the user is responded to click the button 5 to continue to execute the corresponding operation until the difference file is obtained.
The following illustrates the implementation steps of the consistency detection method of the present example.
Acquiring an SVN environment on the network, and constructing the SVN environment by a method for creating compiling environment variables; in response to the operation of clicking the button 1 by the user, displaying all folders of the model in the area 3, wherein the user can select the folder in which the model to be detected is located in the area 3; in response to the user clicking the button 2, displaying all folders of the code in the area 3, wherein the user can select the folder in which the code to be detected is located in the area 3; in response to an operation of clicking the button 5 by the user, the coincidence detection is performed.
In the consistency detection process, firstly, the model to be detected and the SVN of the Code to be detected are updated, if a problem occurs to interrupt and prompt an interrupt position, after the problem of interrupt is overcome, the ARXML configuration files of ALL the selected models are automatically opened and the models are automatically compiled to generate the original codes in response to the operation of clicking the button 5 by a user, and ALL the original codes are arranged under the target folder of the next called code_ALL of the model path (if not, the original codes are automatically created). And then pasting all the generated original codes under the target folder, and generating a difference file by controlling the SVN. Then, the generated difference file is analyzed, if the difference file has-or+ as a change line, but whether the change line is an annotation line needs to be judged, if the change line has// or// as an annotation line, if the line half is a code half, whether the code is changed or the annotation is changed needs to be further judged, and if the code is changed, the code change line number is +1. Finally, the code file and how many lines the code has been changed are displayed in area 4, and if the code change lines of each code file are all 0 lines, the model and the code are consistent.
In this embodiment, after the difference file is generated by means of the SVN, the change points in the difference file are analyzed, so as to determine the consistency between the model to be detected and the code to be detected. The present embodiment can be to perform consistency of the batch consistency check model with the code. The embodiment can also avoid the occurrence of low-level Bug of inconsistent model and code in the test stage, thereby improving the quality of software, simultaneously avoiding the need of multiple people to check, and reducing the checking time and the labor cost.
In order to facilitate better implementation of the method for detecting the consistency of the model and the code in the embodiment of the application, the embodiment of the application also provides a device for detecting the consistency of the model and the code. Fig. 3 is a schematic structural diagram of a device for detecting consistency of a model and a code according to an embodiment of the present application. Referring to fig. 3, the device for detecting consistency between a model and a code provided in this embodiment includes:
an obtaining unit 31, configured to obtain a model to be detected and a code to be detected in an SVN environment;
A generating unit 32, configured to automatically compile and generate an original code based on a configuration file in a model to be detected, and generate a difference file based on the code to be detected and the original code generated by automatic compiling, in response to an instruction for performing consistency check;
And a determining unit 33, configured to identify the change line identifier and the comment line identifier in the difference file, obtain an identification result, and determine that the model to be detected is consistent with the code to be detected when determining that the code change line number is 0 according to the identification result.
In some embodiments, the determining unit 33 is specifically configured to:
if the annotation part of the target line is changed and the code part of the target line is not changed, the number of the code change lines is not counted;
When the target line corresponding to the line identifier is changed and the annotation line identifier exists, cutting the target line to obtain a code part and an annotation part of the target line;
if the code part of the target line is changed, the code change line number count is increased by one.
In some embodiments, the determining unit 33 is specifically configured to:
When the annotation line identifier does not exist in the target line corresponding to the change line identifier, the code change line count is incremented by one.
In some embodiments, the code to be detected corresponds to a plurality of code files; the determining unit 33 is specifically configured to:
When the code change line number of each code file is determined to be 0 according to the identification result, determining that the model to be detected is consistent with the code to be detected;
If the number of code change lines of at least one code file is not 0, determining that the model to be detected is inconsistent with the code to be detected.
In some embodiments, the device for detecting consistency of the model and the code further comprises:
The display unit is used for displaying the file information of each code file and the code change line number of each code file; wherein the file information includes at least one of: file name, file path.
In some embodiments, the generating unit 32 is specifically configured to:
Responding to an instruction for consistency check, and respectively acquiring a model to be detected and version information of a code to be detected;
and when the model to be detected and the code to be detected are determined to be the latest versions based on the version information of the model to be detected and the code to be detected, automatically compiling and generating the original code based on the configuration file of the model to be detected.
In some embodiments, the generating unit 32 is specifically configured to:
The original codes generated by automatic compiling are arranged in a target folder under the path of the model to be detected;
and comparing the original codes in the target folder with the codes to be detected and obtaining a difference file.
The respective units in the above-described model and code consistency detection apparatus may be implemented in whole or in part by software, hardware, and combinations thereof. The above units may be embedded in hardware or may be independent of a processor in the electronic device, or may be stored in software in a memory in the electronic device, so that the processor may call and execute operations corresponding to the above units.
The device for detecting the consistency between the model and the code may be integrated in a terminal or a server having a memory and a processor and having an arithmetic capability, or the device for detecting the consistency between the model and the code may be the terminal or the server.
In some embodiments, fig. 4 is a schematic structural diagram of an electronic device according to another embodiment of the present application, as shown in fig. 4, where the electronic device provided in this embodiment may include: a processor 401, a memory 402, an input device 403 and an output device 404. The number of processors 401 in the device may be one or more. In some embodiments, the processor 401, memory 402, input device 403, and output device 404 may be connected by a bus or other means.
The memory 402 may be used to store software programs and modules, and the processor 401 executes various functional applications of the device and data processing by executing the software programs and modules stored in the memory 402. The memory 402 may mainly include a storage program area that may store an operating system, application programs required for at least one function, and the like, and a storage data area. In addition, memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. The input device 403 may be used to receive input numeric or character information.
In particular, in this embodiment, the processor 401 loads executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 executes the application programs stored in the memory 402, so as to implement the functions of the above method.
In some embodiments, the present application also provides a computer-readable storage medium having a computer program stored thereon. The computer readable storage medium may be applied to an electronic device, and the computer program causes the electronic device to execute a corresponding flow in the method for detecting consistency of a model and a code in the embodiment of the present application, which is not described herein for brevity.
In some embodiments, the present application also provides a computer program product comprising a computer program stored in a computer readable storage medium. The processor of the electronic device reads the computer program from the computer readable storage medium, and the processor executes the computer program, so that the electronic device executes a corresponding flow in the method for detecting the consistency of the model and the code in the embodiment of the present application, which is not described herein for brevity.
In some embodiments, the present application also provides a computer program comprising a computer program stored in a computer readable storage medium. The processor of the electronic device reads the computer program from the computer readable storage medium, and the processor executes the computer program, so that the electronic device executes a corresponding flow in the method for detecting the consistency of the model and the code in the embodiment of the present application, which is not described herein for brevity.
In the present embodiment, the term "module" or "unit" refers to a computer program or a part of a computer program having a predetermined function and working together with other relevant parts to achieve a predetermined object, and may be implemented in whole or in part by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Also, a processor (or multiple processors or memories) may be used to implement one or more modules or units. Furthermore, each module or unit may be part of an overall module or unit that incorporates the functionality of the module or unit.
It should be noted that the logic and/or steps represented in the flowcharts or otherwise described herein, for example, may be considered as a ordered listing of executable instructions for implementing logical functions, and may be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). In addition, the computer readable medium may even be paper or other suitable medium on which the program is printed, as the program may be electronically captured, via, for instance, optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner, if necessary, and then stored in a computer memory.
It is to be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above-described embodiments, the various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, may be implemented using any one or combination of the following techniques, as is well known in the art: discrete logic circuits having logic gates for implementing logic functions on data signals, application specific integrated circuits having suitable combinational logic gates, programmable Gate Arrays (PGAs), field Programmable Gate Arrays (FPGAs), and the like.
In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiments or examples. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
Furthermore, the terms "first," "second," and the like, as used in embodiments of the present invention, are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or as implying any particular number of features in the present embodiment. Thus, a feature of an embodiment of the invention that is defined by terms such as "first," "second," etc., may explicitly or implicitly indicate that at least one such feature is included in the embodiment. In the description of the present invention, the word "plurality" means at least two or more, for example, two, three, four, etc., unless explicitly defined otherwise in the embodiments.
While embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and not to be construed as limiting the invention, and that variations, modifications, alternatives and variations may be made to the above embodiments by one of ordinary skill in the art within the scope of the invention.
Claims (10)
1. A method for detecting consistency of a model and a code, comprising:
under an SVN environment, a model to be detected and a code to be detected are obtained;
Responding to an instruction for consistency check, automatically compiling and generating an original code based on a configuration file in the model to be detected, and generating a difference file based on the code to be detected and the original code generated by automatic compiling;
And identifying a change line identifier and an annotation line identifier in the difference file to obtain an identification result, and determining that the model to be detected is consistent with the code to be detected when the code change line number is 0 according to the identification result.
2. The method according to claim 1, wherein determining the number of code change lines based on the identification result includes:
when the change line identifier corresponds to the target line and the annotation line identifier exists, cutting the target line to obtain a code part and an annotation part of the target line;
if the code part of the target line is changed, the code change line number count is increased by one;
And if the annotation part of the target line is changed and the code part of the target line is not changed, the code change line number is not counted.
3. The method of claim 2, wherein determining the number of code change lines based on the identification result, further comprises:
And when the annotation line identifier does not exist in the target line corresponding to the change line identifier, the code change line count is increased by one.
4. The method of claim 1, wherein the code to be detected corresponds to a plurality of code files;
when the number of code change lines is determined to be 0 according to the identification result, determining that the model to be detected is consistent with the code to be detected includes:
when the code change line number of each code file is determined to be 0 according to the identification result, determining that the model to be detected is consistent with the code to be detected;
the consistency detection method further comprises the following steps:
and if the number of code change lines of at least one code file is not 0, determining that the model to be detected is inconsistent with the code to be detected.
5. The method of claim 4, further comprising:
Displaying the file information of each code file and the code change line number of the code file; wherein the file information includes at least one of: file name, file path.
6. The method of claim 1, wherein the automatically compiling generating the source code based on the profile of the model to be detected in response to the instructions for performing the consistency check comprises:
responding to an instruction for consistency check, and respectively acquiring the model to be detected and version information of the code to be detected;
And when the model to be detected and the code to be detected are determined to be the latest versions based on the version information of the model to be detected and the code to be detected, automatically compiling and generating the original code based on the configuration file of the model to be detected.
7. The method according to claim 1, wherein the generating a difference file based on the code to be detected and the original code generated by automatic compiling includes:
The original codes generated by automatic compiling are arranged in a target folder under the path of the model to be detected;
and comparing the original codes in the target folder with the codes to be detected to obtain a difference file.
8. A device for detecting consistency of a model and a code, comprising:
The acquisition unit is used for acquiring a model to be detected and a code to be detected in an SVN environment;
The generating unit is used for responding to an instruction for consistency check, automatically compiling and generating an original code based on a configuration file in the model to be detected, and generating a difference file based on the code to be detected and the original code generated by automatic compiling;
And the determining unit is used for identifying the change line identifier and the comment line identifier in the difference file to obtain an identification result, and determining that the model to be detected is consistent with the code to be detected when the code change line number is 0 according to the identification result.
9. An electronic device, comprising:
A processor; and
A memory for storing executable instructions of the processor;
Wherein the processor is configured to perform the method of any one of claims 1 to 7 via execution of the executable instructions.
10. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program which, when executed by a processor, implements the method of any one of claims 1 to 7.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410197700.8A CN118409950A (en) | 2024-02-21 | 2024-02-21 | Method, device, equipment and storage medium for detecting consistency of model and code |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410197700.8A CN118409950A (en) | 2024-02-21 | 2024-02-21 | Method, device, equipment and storage medium for detecting consistency of model and code |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN118409950A true CN118409950A (en) | 2024-07-30 |
Family
ID=91990136
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202410197700.8A Pending CN118409950A (en) | 2024-02-21 | 2024-02-21 | Method, device, equipment and storage medium for detecting consistency of model and code |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN118409950A (en) |
-
2024
- 2024-02-21 CN CN202410197700.8A patent/CN118409950A/en active Pending
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN111324540B (en) | Interface testing method and device | |
| CN111881054B (en) | User interface automated testing methods, systems, equipment and storage media | |
| CA2388073A1 (en) | Method for semantic verification of supporting programming artefacts | |
| US5826078A (en) | Job re-execution system and controlling method thereof | |
| CN118312391A (en) | Distributed database fault testing method, device, electronic equipment and storage medium | |
| CN111008031A (en) | Component updating method and device, electronic equipment and computer readable storage medium | |
| CN118409950A (en) | Method, device, equipment and storage medium for detecting consistency of model and code | |
| KR101252358B1 (en) | Apparatus and method for testing plc command | |
| CN118152277B (en) | Bootloader writing method, bootloader writing device, bootloader writing equipment and Bootloader writing medium | |
| CN118051218A (en) | Visual execution method and device for terminal command, electronic equipment and storage medium | |
| CN111352610A (en) | Interface return value modification method and device, electronic equipment and storage medium | |
| CN118535470A (en) | Automatic testing method, system, equipment and storage medium for visual equipment | |
| CN117171036A (en) | Use cases identify methods, apparatus, electronic equipment and media | |
| JP2765549B2 (en) | Operation evaluation system in computer system | |
| JP2009169573A (en) | Analysis result output device and analysis result output method | |
| EP0801348A1 (en) | Method of monitoring the operation of a computer | |
| JPH09114649A (en) | Program operating environment confirmation method | |
| CN119107290B (en) | Industrial vision detection modularized control method and related equipment | |
| WO2014083646A1 (en) | Programmable indicator and program | |
| CN113010406A (en) | Management method, device, equipment and medium of code analysis tool | |
| CN116339732A (en) | View page drawing method, device, equipment and storage medium | |
| EP4345627A1 (en) | Method and apparatus for detecting software system, and electronic device and storage medium | |
| JPS62159243A (en) | Automatic computer test equipment | |
| EP1868099A1 (en) | Bug management tool | |
| JPH09265385A (en) | Software integrity management method |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |